刘远航 4 anos atrás
pai
commit
b255b584a2

+ 22 - 0
tests/CreatesApplication.php

xqd
@@ -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 - 0
tests/Feature/ExampleTest.php

xqd
@@ -0,0 +1,21 @@
+<?php
+
+namespace Tests\Feature;
+
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class ExampleTest extends TestCase
+{
+    /**
+     * A basic test example.
+     *
+     * @return void
+     */
+    public function testBasicTest()
+    {
+        $response = $this->get('/');
+
+        $response->assertStatus(200);
+    }
+}

+ 10 - 0
tests/TestCase.php

xqd
@@ -0,0 +1,10 @@
+<?php
+
+namespace Tests;
+
+use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
+
+abstract class TestCase extends BaseTestCase
+{
+    use CreatesApplication;
+}

+ 19 - 0
tests/Unit/ExampleTest.php

xqd
@@ -0,0 +1,19 @@
+<?php
+
+namespace Tests\Unit;
+
+use Tests\TestCase;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+
+class ExampleTest extends TestCase
+{
+    /**
+     * A basic test example.
+     *
+     * @return void
+     */
+    public function testBasicTest()
+    {
+        $this->assertTrue(true);
+    }
+}

+ 29 - 0
tests/bootstrap.php

xqd
@@ -0,0 +1,29 @@
+<?php
+
+use Illuminate\Contracts\Console\Kernel;
+
+require_once __DIR__.'/../vendor/autoload.php';
+
+/*
+|--------------------------------------------------------------------------
+| 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.
+|
+*/
+
+$commands = [
+    'config:cache',
+    'event:cache',
+];
+
+$app = require __DIR__.'/../bootstrap/app.php';
+
+$console = tap($app->make(Kernel::class))->bootstrap();
+
+foreach ($commands as $command) {
+    $console->call($command);
+}