-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d53bae2
commit eba1858
Showing
4 changed files
with
302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace System\Test\Integrate\Testing; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use System\Http\Response; | ||
use System\Integrate\Testing\TestJsonResponse; | ||
|
||
final class TestJsonResponseTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAsArray() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => 'success', | ||
], | ||
'error' => null, | ||
])); | ||
$response['test'] = 'test'; | ||
|
||
$this->assertEquals('ok', $response['status']); | ||
$this->assertEquals('test', $response['test']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssert() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => 'success', | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$this->assertEquals(['test' => 'success'], $response->getData()); | ||
$this->assertEquals('ok', $response['status']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertEqual() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => 'success', | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertEqual('data.test', 'success'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertTrue() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => true, | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertTrue('data.test'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertFalse() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => false, | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertFalse('data.test'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNull() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => false, | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertNull('error'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNotNull() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => false, | ||
], | ||
'error' => [ | ||
'test' => 'some erroe', | ||
], | ||
])); | ||
|
||
$response->assertNotNull('error'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertEmpty() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertEmpty('error'); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNotEmpty() | ||
{ | ||
$response = new TestJsonResponse(new Response([ | ||
'status'=> 'ok', | ||
'code' => 200, | ||
'data' => [ | ||
'test' => false, | ||
], | ||
'error' => null, | ||
])); | ||
|
||
$response->assertNotEmpty('error'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace System\Test\Integrate\Testing; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use System\Http\Response; | ||
use System\Integrate\Testing\TestResponse; | ||
|
||
final class TestResponseTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssert() | ||
{ | ||
$response = new TestResponse(new Response('test', 200, [])); | ||
|
||
$this->assertEquals('test', $response->getContent()); | ||
$response->assertSee('test'); | ||
$response->assertStatusCode(200); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace System\Test\Integrate\Testing\Traits; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use System\Http\Response; | ||
use System\Integrate\Testing\TestResponse; | ||
|
||
final class ResponseStatusTrait extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertOk() | ||
{ | ||
$response = new TestResponse(new Response('test', 200, [])); | ||
|
||
$response->assertOk(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNoContent() | ||
{ | ||
$response = new TestResponse(new Response('', 204, [])); | ||
|
||
$response->assertNoContent(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNotFound() | ||
{ | ||
$response = new TestResponse(new Response('', 404, [])); | ||
|
||
$response->assertNotFound(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanTestResponeseAssertNotAllowed() | ||
{ | ||
$response = new TestResponse(new Response('', 404, [])); | ||
|
||
$response->assertNotFound(); | ||
} | ||
} |