Use the 2.4 default tests directory structure

parent 35c1d5ba
<?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;
}
}
<?php <?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
...@@ -7,13 +10,14 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; ...@@ -7,13 +10,14 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExampleTest extends TestCase class ExampleTest extends TestCase
{ {
/** /**
* A basic functional test example. * A basic test example.
* *
* @return void * @return void
*/ */
public function testBasicExample() public function testBasicTest()
{ {
$this->visit('/') $response = $this->get('/');
->see('Laravel 5');
$response->assertStatus(200);
} }
} }
<?php <?php
class TestCase extends Illuminate\Foundation\Testing\TestCase namespace Tests;
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
return $app; abstract class TestCase extends BaseTestCase
} {
use CreatesApplication;
} }
<?php
namespace Tests\Unit;
use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$this->assertTrue(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment