mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Ticket;
|
|
use App\Concert;
|
|
use App\Reservation;
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
class ReservationTest extends TestCase
|
|
{
|
|
/** @test */
|
|
function calculating_the_total_cost()
|
|
{
|
|
$tickets = collect([
|
|
(object) ['price' => 1200],
|
|
(object) ['price' => 1200],
|
|
(object) ['price' => 1200],
|
|
]);
|
|
|
|
$reservation = new Reservation($tickets);
|
|
|
|
$this->assertEquals(3600, $reservation->totalCost());
|
|
}
|
|
|
|
/** @test */
|
|
function retrieving_the_reservations_tickets()
|
|
{
|
|
$tickets = collect([
|
|
(object) ['price' => 1200],
|
|
(object) ['price' => 1200],
|
|
(object) ['price' => 1200],
|
|
]);
|
|
|
|
$reservation = new Reservation($tickets);
|
|
|
|
$this->assertEquals($tickets, $reservation->tickets());
|
|
}
|
|
|
|
/** @test */
|
|
function reserved_tickets_are_released_when_a_reservation_is_cancelled()
|
|
{
|
|
$tickets = collect([
|
|
Mockery::spy(Ticket::class),
|
|
Mockery::spy(Ticket::class),
|
|
Mockery::spy(Ticket::class),
|
|
]);
|
|
|
|
$reservation = new Reservation($tickets);
|
|
|
|
$reservation->cancel();
|
|
|
|
foreach ($tickets as $ticket) {
|
|
$ticket->shouldHaveReceived('release');
|
|
}
|
|
}
|
|
}
|