for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace LaravelFr\ApiTesting\Tests\AssertJsonResponse;
use Illuminate\Http\Response;
use PHPUnit_Framework_TestCase;
use LaravelFr\ApiTesting\AssertJsonResponse;
use Illuminate\Foundation\Testing\TestResponse;
use LaravelFr\ApiTesting\Tests\Stubs\JsonSerializableMixedResourcesStub;
class AssertJsonResponseForNewVersionTest extends PHPUnit_Framework_TestCase
{
use AssertJsonResponse;
public function setUp()
if (!class_exists(TestResponse::class)) {
$this->markTestSkipped('Not compatible with this version.');
}
$this->stub = new JsonSerializableMixedResourcesStub;
stub
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;
$this->response = new TestResponse(new Response($this->stub));
response
public function testSeeJsonStructureEquals()
$this->assertTrue(TestResponse::hasMacro('assertJsonStructureEquals'));
$this->response->assertJsonStructureEquals($this->stub->structure());
public function testSeeJsonTypedStructure()
$this->assertTrue(TestResponse::hasMacro('seeJsonTypedStructure'));
$this->response->seeJsonTypedStructure($this->stub->typedStructure());
public function testJsonResponse()
$this->assertTrue(TestResponse::hasMacro('jsonResponse'));
$this->assertEquals(['foobar_foo' => 'foo', 'foobar_bar' => 212], $this->response->jsonResponse('foobar'));
$this->assertEquals(212, $this->response->jsonResponse('foobar.foobar_bar'));
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: