Completed
Push — master ( ad3b69...02c092 )
by John
09:08 queued 05:48
created

HydratorPetStoreApiTest::canPostPet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
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