mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
112 - Refactoring Assertions with Macros
This commit is contained in:
@@ -16,6 +16,23 @@ class ViewConcertListTest extends TestCase
|
||||
{
|
||||
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 */
|
||||
function guests_cannot_view_a_promoters_concert_list()
|
||||
{
|
||||
@@ -39,9 +56,9 @@ class ViewConcertListTest extends TestCase
|
||||
$response = $this->actingAs($user)->get('/backstage/concerts');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertA));
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertB));
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concertD));
|
||||
$this->assertFalse($response->original->getData()['concerts']->contains($concertC));
|
||||
$response->data('concerts')->assertContains($concertA);
|
||||
$response->data('concerts')->assertContains($concertB);
|
||||
$response->data('concerts')->assertContains($concertD);
|
||||
$response->data('concerts')->assertNotContains($concertC);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user