86 - Deleting More Stale Code

This commit is contained in:
Adam Wathan
2017-03-17 13:11:19 -04:00
parent 44db85bdb0
commit e0bfaceb20
4 changed files with 12 additions and 46 deletions

View File

@@ -1,5 +1,7 @@
<?php
use App\Order;
use App\Ticket;
use App\Concert;
use Carbon\Carbon;
use App\Exceptions\NotEnoughTicketsException;
@@ -55,17 +57,6 @@ class ConcertTest extends TestCase
$this->assertFalse($publishedConcerts->contains($unpublishedConcert));
}
/** @test */
function can_order_concert_tickets()
{
$concert = factory(Concert::class)->create()->addTickets(3);
$order = $concert->orderTickets('jane@example.com', 3);
$this->assertEquals('jane@example.com', $order->email);
$this->assertEquals(3, $order->ticketQuantity());
}
/** @test */
function can_add_tickets()
{
@@ -79,21 +70,21 @@ class ConcertTest extends TestCase
/** @test */
function tickets_remaining_does_not_include_tickets_associated_with_an_order()
{
$concert = factory(Concert::class)->create()->addTickets(50);
$concert->orderTickets('jane@example.com', 30);
$concert = factory(Concert::class)->create();
$concert->tickets()->saveMany(factory(Ticket::class, 30)->create(['order_id' => 1]));
$concert->tickets()->saveMany(factory(Ticket::class, 20)->create(['order_id' => null]));
$this->assertEquals(20, $concert->ticketsRemaining());
}
/** @test */
function trying_to_purchase_more_tickets_than_remain_throws_an_exception()
function trying_to_reserve_more_tickets_than_remain_throws_an_exception()
{
$concert = factory(Concert::class)->create()->addTickets(10);
try {
$concert->orderTickets('jane@example.com', 11);
$reservation = $concert->reserveTickets(11, 'john@example.com');
} catch (NotEnoughTicketsException $e) {
$this->assertFalse($concert->hasOrderFor('jane@example.com'));
$this->assertEquals(10, $concert->ticketsRemaining());
return;
}
@@ -101,23 +92,6 @@ class ConcertTest extends TestCase
$this->fail("Order succeeded even though there were not enough tickets remaining.");
}
/** @test */
function cannot_order_tickets_that_have_already_been_purchased()
{
$concert = factory(Concert::class)->create()->addTickets(10);
$concert->orderTickets('jane@example.com', 8);
try {
$concert->orderTickets('john@example.com', 3);
} catch (NotEnoughTicketsException $e) {
$this->assertFalse($concert->hasOrderFor('john@example.com'));
$this->assertEquals(2, $concert->ticketsRemaining());
return;
}
$this->fail("Order succeeded even though there were not enough tickets remaining.");
}
/** @test */
function can_reserve_available_tickets()
{
@@ -135,7 +109,8 @@ class ConcertTest extends TestCase
function cannot_reserve_tickets_that_have_already_been_purchased()
{
$concert = factory(Concert::class)->create()->addTickets(3);
$concert->orderTickets('jane@example.com', 2);
$order = factory(Order::class)->create();
$order->tickets()->saveMany($concert->tickets->take(2));
try {
$concert->reserveTickets(2, 'john@example.com');