1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
/* |
3
|
|
|
* This file is part of the KleijnWeb\SwaggerBundle package. |
4
|
|
|
* |
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
6
|
|
|
* file that was distributed with this source code. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace KleijnWeb\SwaggerBundle\Tests\Functional; |
10
|
|
|
|
11
|
|
|
use KleijnWeb\SwaggerBundle\Test\ApiTestCase; |
12
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author John Kleijn <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class HydratorPetStoreApiTest extends WebTestCase |
18
|
|
|
{ |
19
|
|
|
use ApiTestCase; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $env = 'hydrator'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @group functional |
28
|
|
|
* @test |
29
|
|
|
*/ |
30
|
|
|
public function canPlaceOrder() |
31
|
|
|
{ |
32
|
|
|
$content = [ |
33
|
|
|
'petId' => 987654321, |
34
|
|
|
'quantity' => 10, |
35
|
|
|
'shipDate' => '2016-01-01T01:00:00Z', |
36
|
|
|
'complete' => false |
37
|
|
|
]; |
38
|
|
|
|
39
|
|
|
$actual = $this->post('/v2/store/order', $content); |
40
|
|
|
$this->assertSame('placed', $actual->status); |
41
|
|
|
$this->assertSame($content['petId'], $actual->petId); |
42
|
|
|
$this->assertSame($content['quantity'], $actual->quantity); |
43
|
|
|
|
44
|
|
|
$this->assertTrue($actual->complete); |
45
|
|
|
$this->assertSame('2016-01-02T01:00:00+00:00', $actual->shipDate); |
46
|
|
|
|
47
|
|
|
$this->assertInternalType('integer', $actual->id); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @group functional |
52
|
|
|
* @test |
53
|
|
|
*/ |
54
|
|
|
public function canPostPet() |
55
|
|
|
{ |
56
|
|
|
$content = [ |
57
|
|
|
'name' => 'fido', |
58
|
|
|
'photoUrls' => ['1', '2'], |
59
|
|
|
'quantity' => 10, |
60
|
|
|
'category' => ['name' => 'dogs'] |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
$actual = $this->post('/v2/pet', $content); |
64
|
|
|
$this->assertSame($content['name'], $actual->name); |
65
|
|
|
$this->assertSame($content['photoUrls'], $actual->photoUrls); |
66
|
|
|
$this->assertInternalType('integer', $actual->id); |
67
|
|
|
$this->assertObjectNotHasAttribute('quantity', $actual); |
68
|
|
|
$this->assertObjectHasAttribute('category', $actual); |
69
|
|
|
$this->assertObjectHasAttribute('id', $actual->category); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|