mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
72 - Extracting a Finder Method
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Reservation;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class OrderTest extends TestCase
|
||||
{
|
||||
@@ -26,6 +27,30 @@ class OrderTest extends TestCase
|
||||
$this->assertEquals(2, $concert->ticketsRemaining());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function retrieving_an_order_by_confirmation_number()
|
||||
{
|
||||
$order = factory(Order::class)->create([
|
||||
'confirmation_number' => 'ORDERCONFIRMATION1234',
|
||||
]);
|
||||
|
||||
$foundOrder = Order::findByConfirmationNumber('ORDERCONFIRMATION1234');
|
||||
|
||||
$this->assertEquals($order->id, $foundOrder->id);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function retrieving_a_nonexistent_order_by_confirmation_number_throws_an_exception()
|
||||
{
|
||||
try {
|
||||
Order::findByConfirmationNumber('NONEXISTENTCONFIRMATIONNUMBER');
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail('No matching order was found for the specified confirmation number, but an exception was not thrown.');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function converting_to_an_array()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user