93 - Wiring It All Together

This commit is contained in:
Adam Wathan
2017-04-01 14:09:54 -04:00
parent 6023eb3c8f
commit e3f337f377
4 changed files with 10 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -228,4 +228,5 @@ return [
],
'ticket_code_salt' => env('TICKET_CODE_SALT'),
];

View File

@@ -15,7 +15,6 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
protected function setUp()
{
parent::setUp();
Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
}
/**

View File

@@ -1,6 +1,7 @@
<?php
use App\Concert;
use App\Facades\TicketCode;
use App\Billing\PaymentGateway;
use App\Billing\FakePaymentGateway;
use App\Facades\OrderConfirmationNumber;
@@ -54,6 +55,7 @@ class PurchaseTicketsTest extends TestCase
$this->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);