如何在Test:suite

时间:2018-04-29 11:10:44

标签: laravel phpunit

有没有办法在我的整个测试套件之前调用artisan命令?安装Cartalyst扩展需要花费时间,所以我不希望在每次测试之前都这样做但我假设我不能从setUpBeforeClass这样的静态方法调用外观,我收到此错误

  

RuntimeException:尚未设置外观根。 in /Users/lance/Desktop/FastLMS/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:218

<?php

namespace Tests;

use Illuminate\Contracts\Console\Kernel;
use Illuminate\Support\Facades\Artisan;

class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
    public static function setUpBeforeClass()
    {
        parent::setUpBeforeClass();

        Artisan::call('migrate');
        Artisan::call('extension:install');
        Artisan::call('extension:enable');
    }

    public function createApplication()
    {
        $app = require __DIR__.'/../bootstrap/app.php';

        $app->make(Kernel::class)->bootstrap();

        Hash::setRounds(4);

        return $app;
    }

    public function setUp()
    {
        parent::setUp();

        $this->app['Illuminate\Contracts\Http\Kernel']->disableMiddleware();
    }
}

0 个答案:

没有答案