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": {
"classmap": [
"tests"
]
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [

View File

@@ -9,8 +9,12 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>
<testsuite name="Feature Tests">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<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
namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class PromoterLoginTest extends TestCase
{

View File

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

View File

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

View File

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

View File

@@ -1,10 +1,15 @@
<?php
namespace Tests;
use Exception;
use App\Exceptions\Handler;
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.
*
@@ -17,20 +22,6 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
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()
{
$this->app->instance(ExceptionHandler::class, new class extends Handler {

View File

@@ -1,10 +1,9 @@
<?php
namespace Tests\Unit\Billing;
use Tests\TestCase;
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
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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