mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
87 - Feature Test and JSON Updates
This commit is contained in:
@@ -48,8 +48,10 @@ class Order extends Model
|
|||||||
return [
|
return [
|
||||||
'confirmation_number' => $this->confirmation_number,
|
'confirmation_number' => $this->confirmation_number,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
'ticket_quantity' => $this->ticketQuantity(),
|
|
||||||
'amount' => $this->amount,
|
'amount' => $this->amount,
|
||||||
|
'tickets' => $this->tickets->map(function ($ticket) {
|
||||||
|
return ['code' => $ticket->code];
|
||||||
|
})->all(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use App\Concert;
|
use App\Concert;
|
||||||
use App\Billing\PaymentGateway;
|
use App\Billing\PaymentGateway;
|
||||||
use App\Billing\FakePaymentGateway;
|
use App\Billing\FakePaymentGateway;
|
||||||
|
use App\Facades\OrderConfirmationNumber;
|
||||||
use App\OrderConfirmationNumberGenerator;
|
use App\OrderConfirmationNumberGenerator;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
@@ -52,10 +53,7 @@ class PurchaseTicketsTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->disableExceptionHandling();
|
$this->disableExceptionHandling();
|
||||||
|
|
||||||
$orderConfirmationNumberGenerator = Mockery::mock(OrderConfirmationNumberGenerator::class, [
|
OrderConfirmationNumber::shouldReceive('generate')->andReturn('ORDERCONFIRMATION1234');
|
||||||
'generate' => 'ORDERCONFIRMATION1234',
|
|
||||||
]);
|
|
||||||
$this->app->instance(OrderConfirmationNumberGenerator::class, $orderConfirmationNumberGenerator);
|
|
||||||
|
|
||||||
$concert = factory(Concert::class)->states('published')->create(['ticket_price' => 3250])->addTickets(3);
|
$concert = factory(Concert::class)->states('published')->create(['ticket_price' => 3250])->addTickets(3);
|
||||||
|
|
||||||
@@ -70,8 +68,12 @@ class PurchaseTicketsTest extends TestCase
|
|||||||
$this->seeJsonSubset([
|
$this->seeJsonSubset([
|
||||||
'confirmation_number' => 'ORDERCONFIRMATION1234',
|
'confirmation_number' => 'ORDERCONFIRMATION1234',
|
||||||
'email' => 'john@example.com',
|
'email' => 'john@example.com',
|
||||||
'ticket_quantity' => 3,
|
|
||||||
'amount' => 9750,
|
'amount' => 9750,
|
||||||
|
'tickets' => [
|
||||||
|
['code' => 'TICKETCODE1'],
|
||||||
|
['code' => 'TICKETCODE2'],
|
||||||
|
['code' => 'TICKETCODE3'],
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(9750, $this->paymentGateway->totalCharges());
|
$this->assertEquals(9750, $this->paymentGateway->totalCharges());
|
||||||
|
|||||||
@@ -60,15 +60,23 @@ class OrderTest extends TestCase
|
|||||||
'email' => 'jane@example.com',
|
'email' => 'jane@example.com',
|
||||||
'amount' => 6000,
|
'amount' => 6000,
|
||||||
]);
|
]);
|
||||||
$order->tickets()->saveMany(factory(Ticket::class)->times(5)->create());
|
$order->tickets()->saveMany([
|
||||||
|
factory(Ticket::class)->create(['code' => 'TICKETCODE1']),
|
||||||
|
factory(Ticket::class)->create(['code' => 'TICKETCODE2']),
|
||||||
|
factory(Ticket::class)->create(['code' => 'TICKETCODE3']),
|
||||||
|
]);
|
||||||
|
|
||||||
$result = $order->toArray();
|
$result = $order->toArray();
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'confirmation_number' => 'ORDERCONFIRMATION1234',
|
'confirmation_number' => 'ORDERCONFIRMATION1234',
|
||||||
'email' => 'jane@example.com',
|
'email' => 'jane@example.com',
|
||||||
'ticket_quantity' => 5,
|
|
||||||
'amount' => 6000,
|
'amount' => 6000,
|
||||||
|
'tickets' => [
|
||||||
|
['code' => 'TICKETCODE1'],
|
||||||
|
['code' => 'TICKETCODE2'],
|
||||||
|
['code' => 'TICKETCODE3'],
|
||||||
|
]
|
||||||
], $result);
|
], $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user