mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-20 14:55:12 +00:00
112 - Refactoring Assertions with Macros
This commit is contained in:
@@ -16,6 +16,23 @@ class ViewConcertListTest extends TestCase
|
|||||||
{
|
{
|
||||||
use DatabaseMigrations;
|
use DatabaseMigrations;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
TestResponse::macro('data', function ($key) {
|
||||||
|
return $this->original->getData()[$key];
|
||||||
|
});
|
||||||
|
|
||||||
|
Collection::macro('assertContains', function ($value) {
|
||||||
|
Assert::assertTrue($this->contains($value), "Failed asserting that the collection contains the specified value.");
|
||||||
|
});
|
||||||
|
|
||||||
|
Collection::macro('assertNotContains', function ($value) {
|
||||||
|
Assert::assertFalse($this->contains($value), "Failed asserting that the collection does not contain the specified value.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
function guests_cannot_view_a_promoters_concert_list()
|
function guests_cannot_view_a_promoters_concert_list()
|
||||||
{
|
{
|
||||||
@@ -39,9 +56,9 @@ class ViewConcertListTest extends TestCase
|
|||||||
$response = $this->actingAs($user)->get('/backstage/concerts');
|
$response = $this->actingAs($user)->get('/backstage/concerts');
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertA));
|
$response->data('concerts')->assertContains($concertA);
|
||||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertB));
|
$response->data('concerts')->assertContains($concertB);
|
||||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertD));
|
$response->data('concerts')->assertContains($concertD);
|
||||||
$this->assertFalse($response->original->getData()['concerts']->contains($concertC));
|
$response->data('concerts')->assertNotContains($concertC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user