Passed
Push — master ( 0ffa51...bdfaa4 )
by Radosław
02:21
created

testExceptionOnTooManyPhotos()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use Radowoj\Yaah\Auction;
5
6
class AuctionFieldIntegrationTest extends TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
9
    /**
10
     * @expectedException Radowoj\Yaah\Exception
11
     * @expectedExceptionMessage Photo files limit exceeded, 8 allowed, 9 given
12
     */
13
    public function testExceptionOnTooManyPhotos()
14
    {
15
        $auction = new Auction();
16
        $auction->setPhotos([
17
            'maximum', 'number', 'of', 'photos', 'is', 'eight', 'so', 'test', 'nine'
18
        ]);
19
    }
20
21
22
    public function testApiRepresentation()
23
    {
24
        $auction = new Auction([
25
            1 => 'test string',
26
            2 => 42,
27
            3 => '05-03-2017',
28
            4 => 12.34,
29
        ]);
30
31
        $apiRepresentation = $auction->toApiRepresentation();
32
33
        $this->assertArrayHasKey('fields', $apiRepresentation);
34
        $this->assertEquals(4, count($apiRepresentation['fields']));
35
36
        $fields = $apiRepresentation['fields'];
37
38
        $testString = array_shift($fields);
39
        $this->assertArrayHasKey('fvalueString', $testString);
40
        $this->assertSame('test string', $testString['fvalueString']);
41
42
        $testInt = array_shift($fields);
43
        $this->assertArrayHasKey('fvalueInt', $testInt);
44
        $this->assertSame(42, $testInt['fvalueInt']);
45
46
        $testDate = array_shift($fields);
47
        $this->assertArrayHasKey('fvalueDate', $testDate);
48
        $this->assertSame('05-03-2017', $testDate['fvalueDate']);
49
50
        $testFloat = array_shift($fields);
51
        $this->assertArrayHasKey('fvalueFloat', $testFloat);
52
        $this->assertSame(12.34, $testFloat['fvalueFloat']);
53
    }
54
}
55