mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-27 18:45:09 +00:00
38 lines
944 B
PHP
38 lines
944 B
PHP
<?php
|
|
|
|
use App\Ticket;
|
|
use App\Concert;
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
class TicketTest extends TestCase
|
|
{
|
|
use DatabaseMigrations;
|
|
|
|
/** @test */
|
|
function a_ticket_can_be_reserved()
|
|
{
|
|
$ticket = factory(Ticket::class)->create();
|
|
$this->assertNull($ticket->reserved_at);
|
|
|
|
$ticket->reserve();
|
|
|
|
$this->assertNotNull($ticket->fresh()->reserved_at);
|
|
}
|
|
|
|
/** @test */
|
|
function a_ticket_can_be_released()
|
|
{
|
|
$concert = factory(Concert::class)->create();
|
|
$concert->addTickets(1);
|
|
$order = $concert->orderTickets('jane@example.com', 1);
|
|
$ticket = $order->tickets()->first();
|
|
$this->assertEquals($order->id, $ticket->order_id);
|
|
|
|
$ticket->release();
|
|
|
|
$this->assertNull($ticket->fresh()->order_id);
|
|
}
|
|
}
|