Skip to content

Commit 08eefbc

Browse files
committed
Organize tests.
1 parent 7b31893 commit 08eefbc

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

composer.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
"database"
2121
],
2222
"psr-4": {
23-
"App\\": "app/"
23+
"App\\": "app/",
24+
"Tests\\": "tests/"
2425
}
2526
},
26-
"autoload-dev": {
27-
"classmap": [
28-
"tests/TestCase.php"
29-
]
30-
},
3127
"scripts": {
3228
"post-root-package-install": [
3329
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""

phpunit.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
processIsolation="false"
1010
stopOnFailure="false">
1111
<testsuites>
12-
<testsuite name="Application Test Suite">
13-
<directory suffix="Test.php">./tests</directory>
12+
<testsuite name="Feature Tests">
13+
<directory suffix="Test.php">./tests/Feature</directory>
14+
</testsuite>
15+
16+
<testsuite name="Unit Tests">
17+
<directory suffix="Test.php">./tests/Unit</directory>
1418
</testsuite>
1519
</testsuites>
1620
<filter>

tests/ExampleTest.php tests/Feature/ExampleTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
<?php
22

3+
namespace Tests\Feature;
4+
5+
use Tests\TestCase;
36
use Illuminate\Foundation\Testing\WithoutMiddleware;
47
use Illuminate\Foundation\Testing\DatabaseMigrations;
58
use Illuminate\Foundation\Testing\DatabaseTransactions;
69

710
class ExampleTest extends TestCase
811
{
912
/**
10-
* A basic functional test example.
13+
* A basic test example.
1114
*
1215
* @return void
1316
*/
14-
public function testBasicExample()
17+
public function testBasicTest()
1518
{
1619
$this->visit('/')
1720
->see('Laravel');

tests/TestCase.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?php
22

3-
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
3+
namespace Tests;
4+
5+
use Illuminate\Contracts\Console\Kernel;
6+
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
7+
8+
abstract class TestCase extends BaseTestCase
49
{
510
/**
611
* The base URL to use while testing the application.
@@ -18,7 +23,7 @@ public function createApplication()
1823
{
1924
$app = require __DIR__.'/../bootstrap/app.php';
2025

21-
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
26+
$app->make(Kernel::class)->bootstrap();
2227

2328
return $app;
2429
}

tests/Unit/ExampleTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Tests\Unit;
4+
5+
use Tests\TestCase;
6+
use Illuminate\Foundation\Testing\WithoutMiddleware;
7+
use Illuminate\Foundation\Testing\DatabaseMigrations;
8+
use Illuminate\Foundation\Testing\DatabaseTransactions;
9+
10+
class ExampleTest extends TestCase
11+
{
12+
/**
13+
* A basic test example.
14+
*
15+
* @return void
16+
*/
17+
public function testBasicTest()
18+
{
19+
$this->assertTrue(true);
20+
}
21+
}

0 commit comments

Comments
 (0)