Completed
Push — master ( e32dee...621074 )
by Mathieu
01:55
created

testSeeJsonStructureEquals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace LaravelFr\ApiTesting\Tests;
4
5
use LaravelFr\ApiTesting\Tests\Stubs\JsonSerializableMixedResourcesStub;
6
use LaravelFr\ApiTesting\AssertJsonResponse;
7
use PHPUnit_Framework_TestCase;
8
9
class AssertJsonResponseTest extends PHPUnit_Framework_TestCase
10
{
11
    use AssertJsonResponse;
12
13
    public function testSeeJsonStructureEquals()
14
    {
15
        $this->response = new \Illuminate\Http\Response(new JsonSerializableMixedResourcesStub);
16
17
        $this->seeJsonStructureEquals([
18
            'foo',
19
            'baz'    => ['*' => ['bar' => ['*'], 'foo']],
20
            'bars'   => ['*' => ['bar', 'foo']],
21
            'foobar' => ['foobar_foo', 'foobar_bar'],
22
        ]);
23
    }
24
25
    public function testJsonResponse()
26
    {
27
        $this->response = new \Illuminate\Http\Response(new JsonSerializableMixedResourcesStub);
28
29
        $this->assertEquals(
30
            (new JsonSerializableMixedResourcesStub)->jsonSerialize(),
31
            $this->jsonResponse()
32
        );
33
        $this->assertEquals(
34
            ['foobar_foo' => 'foo', 'foobar_bar' => 'bar'],
35
            $this->jsonResponse('foobar')
36
        );
37
        $this->assertEquals('bar', $this->jsonResponse('foobar.foobar_bar'));
38
    }
39
}
40