110 - Asserting Against View Objects

This commit is contained in:
Adam Wathan
2017-06-06 14:49:48 -04:00
parent 393f9a0a1d
commit eaef0be875
4 changed files with 48 additions and 0 deletions

View 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]));
}
}