Completed
Push — master ( 48fd80...29da38 )
by Mathieu
08:18
created

AssertJsonResponseForNewVersionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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