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
|
|
|
|