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

AssertJsonResponseForOldVersionAndBrowserKitTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

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