mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-04 07:48:19 +00:00
110 - Asserting Against View Objects
This commit is contained in:
42
tests/Feature/Backstage/ViewConcertListTest.php
Normal file
42
tests/Feature/Backstage/ViewConcertListTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Backstage;
|
||||
|
||||
use App\User;
|
||||
use App\Concert;
|
||||
use Tests\TestCase;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\TestResponse;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class ViewConcertListTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/** @test */
|
||||
function guests_cannot_view_a_promoters_concert_list()
|
||||
{
|
||||
$response = $this->get('/backstage/concerts');
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_can_view_a_list_of_their_concerts()
|
||||
{
|
||||
$this->disableExceptionHandling();
|
||||
$user = factory(User::class)->create();
|
||||
$concerts = factory(Concert::class, 3)->create(['user_id' => $user->id]);
|
||||
|
||||
$response = $this->actingAs($user)->get('/backstage/concerts');
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concerts[0]));
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concerts[1]));
|
||||
$this->assertTrue($response->original->getData()['concerts']->contains($concerts[2]));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user