mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-19 04:54:35 +00:00
113 - Viewing the Update Form
Just the view, saving changes not yet implemented.
This commit is contained in:
84
tests/Feature/Backstage/EditConcertTest.php
Normal file
84
tests/Feature/Backstage/EditConcertTest.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Backstage;
|
||||
|
||||
use App\User;
|
||||
use App\Concert;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class EditConcertTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/** @test */
|
||||
function promoters_can_view_the_edit_form_for_their_own_unpublished_concerts()
|
||||
{
|
||||
$this->disableExceptionHandling();
|
||||
|
||||
$user = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $user->id]);
|
||||
$this->assertFalse($concert->isPublished());
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$this->assertTrue($response->data('concert')->is($concert));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_cannot_view_the_edit_form_for_their_own_published_concerts()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->states('published')->create(['user_id' => $user->id]);
|
||||
$this->assertTrue($concert->isPublished());
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(403);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_cannot_view_the_edit_form_for_other_concerts()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$otherUser = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $otherUser->id]);
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_see_a_404_when_attempting_to_view_the_edit_form_for_a_concert_that_does_not_exist()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->get("/backstage/concerts/999/edit");
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function guests_are_asked_to_login_when_attempting_to_view_the_edit_form_for_any_concert()
|
||||
{
|
||||
$otherUser = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->create(['user_id' => $otherUser->id]);
|
||||
|
||||
$response = $this->get("/backstage/concerts/{$concert->id}/edit");
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function guests_are_asked_to_login_when_attempting_to_view_the_edit_form_for_a_concert_that_does_not_exist()
|
||||
{
|
||||
$response = $this->get("/backstage/concerts/999/edit");
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/login');
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,6 @@ class ViewConcertListTest extends TestCase
|
||||
{
|
||||
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.");
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Tests;
|
||||
|
||||
use Exception;
|
||||
use App\Exceptions\Handler;
|
||||
use Illuminate\Foundation\Testing\TestResponse;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
|
||||
abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
@@ -20,6 +21,10 @@ abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
TestResponse::macro('data', function ($key) {
|
||||
return $this->original->getData()[$key];
|
||||
});
|
||||
}
|
||||
|
||||
protected function disableExceptionHandling()
|
||||
|
||||
Reference in New Issue
Block a user