Passed
Push — master ( bdfaa4...00ab5d )
by Radosław
02:20
created

AuctionFieldIntegrationTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 49
rs 10
c 0
b 0
f 0

2 Methods

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