mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-13 10:52:42 +00:00
44 - Cancelling Reservations
This commit is contained in:
@@ -15,4 +15,11 @@ class Reservation
|
|||||||
{
|
{
|
||||||
return $this->tickets->sum('price');
|
return $this->tickets->sum('price');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancel()
|
||||||
|
{
|
||||||
|
foreach ($this->tickets as $ticket) {
|
||||||
|
$ticket->release();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ class PurchaseTicketsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertResponseStatus(422);
|
$this->assertResponseStatus(422);
|
||||||
$this->assertFalse($concert->hasOrderFor('john@example.com'));
|
$this->assertFalse($concert->hasOrderFor('john@example.com'));
|
||||||
|
$this->assertEquals(3, $concert->ticketsRemaining());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
|||||||
@@ -22,4 +22,24 @@ class ReservationTest extends TestCase
|
|||||||
|
|
||||||
$this->assertEquals(3600, $reservation->totalCost());
|
$this->assertEquals(3600, $reservation->totalCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
function reserved_tickets_are_released_when_a_reservation_is_cancelled()
|
||||||
|
{
|
||||||
|
$ticket1 = Mockery::mock(Ticket::class);
|
||||||
|
$ticket1->shouldReceive('release')->once();
|
||||||
|
|
||||||
|
$ticket2 = Mockery::mock(Ticket::class);
|
||||||
|
$ticket2->shouldReceive('release')->once();
|
||||||
|
|
||||||
|
$ticket3 = Mockery::mock(Ticket::class);
|
||||||
|
$ticket3->shouldReceive('release')->once();
|
||||||
|
|
||||||
|
$tickets = collect([$ticket1, $ticket2, $ticket3]);
|
||||||
|
|
||||||
|
$reservation = new Reservation($tickets);
|
||||||
|
|
||||||
|
$reservation->cancel();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user