Completed
Push — master ( 01d609...f0430d )
by Mathieu
11s
created

testSeeJsonStructureEquals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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->stub = new JsonSerializableMixedResourcesStub;
0 ignored issues
show
Bug introduced by
The property stub does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
        $this->response = new Response($this->stub);
19
    }
20
21
    public function testSeeJsonStructureEquals()
22
    {
23
        $this->assertJsonStructureEquals($this->stub->structure());
24
    }
25
26
    public function testJsonResponse()
27
    {
28
        $this->assertEquals(
29
            ['foobar_foo' => 'foo', 'foobar_bar' => 212],
30
            $this->jsonResponse('foobar')
31
        );
32
        $this->assertEquals(212, $this->jsonResponse('foobar.foobar_bar'));
33
    }
34
35
    public function testSeeJsonTypedStructure()
36
    {
37
        $this->seeJsonTypedStructure($this->stub->typedStructure());
38
    }
39
}
40