mirror of
https://github.com/v2board/v2board.git
synced 2025-06-13 13:17:52 +08:00
commit message
This commit is contained in:
42
tests/Bootstrap.php
Executable file
42
tests/Bootstrap.php
Executable file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use PHPUnit\Runner\AfterLastTestHook;
|
||||
use PHPUnit\Runner\BeforeFirstTestHook;
|
||||
|
||||
class Bootstrap implements BeforeFirstTestHook, AfterLastTestHook
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bootstrap The Test Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may specify console commands that execute once before your test is
|
||||
| run. You are free to add your own additional commands or logic into
|
||||
| this file as needed in order to help your test suite run quicker.
|
||||
|
|
||||
*/
|
||||
|
||||
use CreatesApplication;
|
||||
|
||||
public function executeBeforeFirstTest(): void
|
||||
{
|
||||
$console = $this->createApplication()->make(Kernel::class);
|
||||
|
||||
$commands = [
|
||||
'config:cache',
|
||||
'event:cache',
|
||||
];
|
||||
|
||||
foreach ($commands as $command) {
|
||||
$console->call($command);
|
||||
}
|
||||
}
|
||||
|
||||
public function executeAfterLastTest(): void
|
||||
{
|
||||
array_map('unlink', glob('bootstrap/cache/*.phpunit.php'));
|
||||
}
|
||||
}
|
22
tests/CreatesApplication.php
Executable file
22
tests/CreatesApplication.php
Executable 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;
|
||||
}
|
||||
}
|
21
tests/Feature/ExampleTest.php
Executable file
21
tests/Feature/ExampleTest.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
10
tests/TestCase.php
Executable file
10
tests/TestCase.php
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
}
|
19
tests/Unit/ExampleTest.php
Executable file
19
tests/Unit/ExampleTest.php
Executable file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user