diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 4766531..c449c0e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,7 +2,9 @@ namespace App\Providers; +use App\TicketCodeGenerator; use App\Billing\PaymentGateway; +use App\HashidsTicketCodeGenerator; use App\Billing\StripePaymentGateway; use Illuminate\Support\ServiceProvider; use App\OrderConfirmationNumberGenerator; @@ -31,7 +33,12 @@ class AppServiceProvider extends ServiceProvider return new StripePaymentGateway(config('services.stripe.secret')); }); + $this->app->bind(HashidsTicketCodeGenerator::class, function () { + return new HashidsTicketCodeGenerator(config('app.ticket_code_salt')); + }); + $this->app->bind(PaymentGateway::class, StripePaymentGateway::class); $this->app->bind(OrderConfirmationNumberGenerator::class, RandomOrderConfirmationNumberGenerator::class); + $this->app->bind(TicketCodeGenerator::class, HashidsTicketCodeGenerator::class); } } diff --git a/config/app.php b/config/app.php index ac6eeb9..c89c97f 100644 --- a/config/app.php +++ b/config/app.php @@ -228,4 +228,5 @@ return [ ], + 'ticket_code_salt' => env('TICKET_CODE_SALT'), ]; diff --git a/tests/TestCase.php b/tests/TestCase.php index 9a031c3..1eb1af1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,6 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase protected function setUp() { parent::setUp(); - Mockery::getConfiguration()->allowMockingNonExistentMethods(false); } /** diff --git a/tests/features/PurchaseTicketsTest.php b/tests/features/PurchaseTicketsTest.php index 81438e8..17471b2 100644 --- a/tests/features/PurchaseTicketsTest.php +++ b/tests/features/PurchaseTicketsTest.php @@ -1,6 +1,7 @@ disableExceptionHandling(); OrderConfirmationNumber::shouldReceive('generate')->andReturn('ORDERCONFIRMATION1234'); + TicketCode::shouldReceive('generateFor')->andReturn('TICKETCODE1', 'TICKETCODE2', 'TICKETCODE3'); $concert = factory(Concert::class)->states('published')->create(['ticket_price' => 3250])->addTickets(3);