Completed
Push — master ( 6fa789...1e4339 )
by Mathieu
06:26
created

testJsonResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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