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

AssertJsonResponseForOldVersionAndBrowserKitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testSeeJsonStructureEquals() 0 9 1
A testJsonResponse() 0 12 1
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