100 - Namespacing Our Test Suite

This commit is contained in:
Adam Wathan
2017-05-02 15:42:01 -04:00
parent 01602b46d4
commit bed85c66c1
18 changed files with 80 additions and 55 deletions

View File

@@ -29,9 +29,9 @@
} }
}, },
"autoload-dev": { "autoload-dev": {
"classmap": [ "psr-4": {
"tests" "Tests\\": "tests/"
] }
}, },
"scripts": { "scripts": {
"post-root-package-install": [ "post-root-package-install": [

View File

@@ -9,8 +9,12 @@
processIsolation="false" processIsolation="false"
stopOnFailure="false"> stopOnFailure="false">
<testsuites> <testsuites>
<testsuite name="Application Test Suite"> <testsuite name="Feature Tests">
<directory suffix="Test.php">./tests</directory> <directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>

View File

@@ -0,0 +1,22 @@
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
}

View File

@@ -1,10 +1,11 @@
<?php <?php
namespace Tests\Feature;
use App\User; use App\User;
use Tests\TestCase;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class PromoterLoginTest extends TestCase class PromoterLoginTest extends TestCase
{ {

View File

@@ -1,16 +1,16 @@
<?php <?php
namespace Tests\Feature;
use App\Concert; use App\Concert;
use Tests\TestCase;
use App\Facades\TicketCode; use App\Facades\TicketCode;
use App\Billing\PaymentGateway; use App\Billing\PaymentGateway;
use App\Billing\FakePaymentGateway; use App\Billing\FakePaymentGateway;
use App\Mail\OrderConfirmationEmail; use App\Mail\OrderConfirmationEmail;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use App\Facades\OrderConfirmationNumber; use App\Facades\OrderConfirmationNumber;
use App\OrderConfirmationNumberGenerator;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class PurchaseTicketsTest extends TestCase class PurchaseTicketsTest extends TestCase
{ {

View File

@@ -1,10 +1,11 @@
<?php <?php
namespace Tests\Feature;
use App\Concert; use App\Concert;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ViewConcertListingTest extends TestCase class ViewConcertListingTest extends TestCase
{ {

View File

@@ -1,12 +1,13 @@
<?php <?php
namespace Tests\Feature;
use App\Order; use App\Order;
use App\Ticket; use App\Ticket;
use App\Concert; use App\Concert;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ViewOrderTest extends TestCase class ViewOrderTest extends TestCase
{ {

View File

@@ -1,10 +1,15 @@
<?php <?php
namespace Tests;
use Exception;
use App\Exceptions\Handler; use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Debug\ExceptionHandler;
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase abstract class TestCase extends \Illuminate\Foundation\Testing\TestCase
{ {
use CreatesApplication;
/** /**
* The base URL to use while testing the application. * The base URL to use while testing the application.
* *
@@ -17,20 +22,6 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
parent::setUp(); parent::setUp();
} }
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}
protected function disableExceptionHandling() protected function disableExceptionHandling()
{ {
$this->app->instance(ExceptionHandler::class, new class extends Handler { $this->app->instance(ExceptionHandler::class, new class extends Handler {

View File

@@ -1,10 +1,9 @@
<?php <?php
namespace Tests\Unit\Billing;
use Tests\TestCase;
use App\Billing\FakePaymentGateway; use App\Billing\FakePaymentGateway;
use App\Billing\PaymentFailedException;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class FakePaymentGatewayTest extends TestCase class FakePaymentGatewayTest extends TestCase
{ {

View File

@@ -1,5 +1,7 @@
<?php <?php
namespace Tests\Unit\Billing;
use App\Billing\PaymentFailedException; use App\Billing\PaymentFailedException;
trait PaymentGatewayContractTests trait PaymentGatewayContractTests

View File

@@ -1,7 +1,9 @@
<?php <?php
namespace Tests\Unit\Billing;
use Tests\TestCase;
use App\Billing\StripePaymentGateway; use App\Billing\StripePaymentGateway;
use App\Billing\PaymentFailedException;
/** /**
* @group integration * @group integration

View File

@@ -1,13 +1,14 @@
<?php <?php
namespace Tests\Unit;
use App\Order; use App\Order;
use App\Ticket; use App\Ticket;
use App\Concert; use App\Concert;
use Carbon\Carbon; use Carbon\Carbon;
use Tests\TestCase;
use App\Exceptions\NotEnoughTicketsException; use App\Exceptions\NotEnoughTicketsException;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ConcertTest extends TestCase class ConcertTest extends TestCase
{ {

View File

@@ -1,10 +1,10 @@
<?php <?php
namespace Tests\Unit;
use App\Ticket; use App\Ticket;
use Tests\TestCase;
use App\HashidsTicketCodeGenerator; use App\HashidsTicketCodeGenerator;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class HashidsTicketCodeGeneratorTest extends TestCase class HashidsTicketCodeGeneratorTest extends TestCase
{ {

View File

@@ -1,10 +1,10 @@
<?php <?php
namespace Tests\Unit\Mail;
use App\Order; use App\Order;
use Tests\TestCase;
use App\Mail\OrderConfirmationEmail; use App\Mail\OrderConfirmationEmail;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class OrderConfirmationEmailTest extends TestCase class OrderConfirmationEmailTest extends TestCase
{ {

View File

@@ -1,13 +1,13 @@
<?php <?php
namespace Tests\Unit;
use Mockery;
use App\Order; use App\Order;
use App\Ticket; use App\Ticket;
use App\Concert; use Tests\TestCase;
use App\Reservation;
use App\Billing\Charge; use App\Billing\Charge;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
class OrderTest extends TestCase class OrderTest extends TestCase

View File

@@ -1,9 +1,9 @@
<?php <?php
namespace Tests\Unit;
use Tests\TestCase;
use App\RandomOrderConfirmationNumberGenerator; use App\RandomOrderConfirmationNumberGenerator;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class RandomOrderConfirmationNumberGeneratorTest extends TestCase class RandomOrderConfirmationNumberGeneratorTest extends TestCase
{ {

View File

@@ -1,12 +1,14 @@
<?php <?php
namespace Tests\Unit;
use Mockery;
use App\Ticket; use App\Ticket;
use App\Concert; use App\Concert;
use Tests\TestCase;
use App\Reservation; use App\Reservation;
use App\Billing\FakePaymentGateway; use App\Billing\FakePaymentGateway;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ReservationTest extends TestCase class ReservationTest extends TestCase
{ {

View File

@@ -1,13 +1,12 @@
<?php <?php
namespace Tests\Unit;
use App\Order; use App\Order;
use App\Ticket; use App\Ticket;
use App\Concert; use Tests\TestCase;
use Carbon\Carbon;
use App\Facades\TicketCode; use App\Facades\TicketCode;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class TicketTest extends TestCase class TicketTest extends TestCase
{ {