Laravel 5.3 - Win10 - PHPUnit - 测试代码或测试代码没有(仅)关闭自己的输出缓冲区

时间:2016-11-23 16:00:27

标签: php laravel phpunit

Laravel 5.3,Windows 10,VS代码。 PHPUnit将最简单的测试标记为'冒险'。 有什么想法吗?

我已经尝试了各种各样的PHPUnit设置来切换那个'Risky'输出缓冲区错误,这是最简单的测试,所以我不确定从哪里开始它为什么会发生。

VS Code终端输出......

C:/Source/laravel/vendor/bin/phpunit.bat -v -c
C:/Source/laravel/phpunit.xml ./laravel/tests/ExampleTest.php PHPUnit
5.6.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.12 with Xdebug 2.4.1 Configuration:
C:\Source\laravel\phpunit.xml R                                       
1 / 1 (100%) Time: 562 ms, Memory: 28.00MB There was 1 risky test: 1)
ExampleTest::testBasicExample Test code or tested code did not (only)
close its own output buffers

控制器。

    <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class TestController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
    }

    public function index()
    {
        return 'OK';
    }
}

测试

    <?php

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

class ExampleTest extends TestCase
{
    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    { 
        $this->visitRoute('test')
              ->seeText('OK');
    }
}

路线:

Route::get('/test', 'TestController@index')->name('test');

1 个答案:

答案 0 :(得分:0)

我刚想出来......问题在于TestCase&#39;要求/包括&#39; wp-load.php文件因为我在控制器中使用了一些wordpress函数。删除它,没关系。