Laravel 5 具有代码覆盖率的Laravel5和PHPUnit:身份验证后的分段错误

Laravel 5 具有代码覆盖率的Laravel5和PHPUnit:身份验证后的分段错误,laravel-5,phpunit,code-coverage,Laravel 5,Phpunit,Code Coverage,我在MAC OS X 10.9.5上的Laravel 5项目中使用PHPUnit,代码覆盖率为。我为客户机配置文件页面编写了一个测试类,如下所示 <?php use Illuminate\Foundation\Testing\DatabaseMigrations; class MinimalViewTest extends TestCase { use DatabaseMigrations; public function testWithSegFault()

我在MAC OS X 10.9.5上的Laravel 5项目中使用PHPUnit,代码覆盖率为。我为客户机配置文件页面编写了一个测试类,如下所示

<?php

use Illuminate\Foundation\Testing\DatabaseMigrations;

class MinimalViewTest extends TestCase
{
    use DatabaseMigrations;

    public function testWithSegFault()
    {
        ...

        $this->actingAs($userAuthorized)
             ->visit('/clients/profile/x11')
             ->visit('/clients/profile/' . $randomUser->id);
    }
}
<?php

namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth as Auth;

class UserGroupMiddleware
{
    public function handle($request, Closure $next)
    {
        return $next($request);
    }
}
如果在没有代码覆盖的情况下调用PHPUnit,测试就会成功

$ vendor/bin/phpunit -v tests/MinimalViewTest.php --no-coverage
PHPUnit 5.0.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.0.0 with Xdebug 2.4.0
Configuration: /.../phpunit.xml

.                                                                   1 / 1 (100%)

Time: 1.71 seconds, Memory: 16.00Mb

OK (1 test, 3 assertions)
除了Laravel5提供的身份验证之外,我还使用自己的中间件来确定用户组

Route::group(['middleware' => ['web', 'auth', 'usergroup'], 'groups' => ['admin', 'orgateam']], function ()
{
    Route::get('/clients/profile/{clientsId}', ['as' => 'clientsProfileByClientId', 'uses' => 'ClientsController@profileByClientId']);
});
我使用的中间件如下所示

<?php

use Illuminate\Foundation\Testing\DatabaseMigrations;

class MinimalViewTest extends TestCase
{
    use DatabaseMigrations;

    public function testWithSegFault()
    {
        ...

        $this->actingAs($userAuthorized)
             ->visit('/clients/profile/x11')
             ->visit('/clients/profile/' . $randomUser->id);
    }
}
<?php

namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth as Auth;

class UserGroupMiddleware
{
    public function handle($request, Closure $next)
    {
        return $next($request);
    }
}

这里到底发生了什么?Laravel 5和PHPUnit代码覆盖范围的认证是否真的存在问题?我真的希望将代码覆盖率与PHPUnit一起使用。

您找到关于此错误的解决方案了吗?不幸的是,我还没有找到解决方案。我找到了解决方案。我已经安装了phpunit4.x。我在docker PHP7图像上运行测试。当我将phpunit从4.x升级到5.5.x时,一切都很完美。PHP5.6.x上的phpunit4.x上没有显示该错误。只有在PHP7上,您才找到此错误的解决方案?不幸的是,我还没有找到解决方案。我找到了解决方案。我已经安装了phpunit4.x。我在docker PHP7图像上运行测试。当我将phpunit从4.x升级到5.5.x时,一切都很完美。PHP5.6.x上的phpunit4.x上没有显示该错误。仅在php7上