Files
ticketbeast/tests/unit/TicketTest.php
2016-11-20 18:50:04 -05:00

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