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

AssertJsonResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testJsonResponse() 0 14 1
A testSeeJsonStructureEquals() 0 11 1
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