mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-10 03:51:16 +00:00
123 - Creating Published Concerts
This commit is contained in:
51
tests/Feature/Backstage/PublishConcertTest.php
Normal file
51
tests/Feature/Backstage/PublishConcertTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Backstage;
|
||||
|
||||
use App\User;
|
||||
use App\Concert;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class PublishConcertTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/** @test */
|
||||
function a_promoter_can_publish_their_own_concert()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->states('unpublished')->create([
|
||||
'user_id' => $user->id,
|
||||
'ticket_quantity' => 3,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->post('/backstage/published-concerts', [
|
||||
'concert_id' => $concert->id,
|
||||
]);
|
||||
|
||||
$response->assertRedirect('/backstage/concerts');
|
||||
$concert = $concert->fresh();
|
||||
$this->assertTrue($concert->isPublished());
|
||||
$this->assertEquals(3, $concert->ticketsRemaining());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function a_concert_can_only_be_published_once()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$concert = \ConcertFactory::createPublished([
|
||||
'user_id' => $user->id,
|
||||
'ticket_quantity' => 3,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->post('/backstage/published-concerts', [
|
||||
'concert_id' => $concert->id,
|
||||
]);
|
||||
|
||||
$response->assertStatus(422);
|
||||
$this->assertEquals(3, $concert->fresh()->ticketsRemaining());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user