包含$ this-> expectedEvents()的测试始终通过

时间:2016-02-19 11:08:49

标签: laravel phpunit laravel-5.1 laravel-5.2 mockery

以下测试始终通过从5.1升级的Laravel 5.2应用程序:

<?php

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

class EventTest extends TestCase
{
    public function tearDown()
    {
        Mockery::close();
    }

    public function testExample()
    {
        $this->expectsEvents(App\Events\Foo::class);
    }
}

尽管App \ Events \ Foo类甚至不存在。我在新的5.2安装中测试了相同的测试,但是它按预期失败了。我查看了升级指南和所有相关的非核心代码,看看我是否已经错过了5.1和5.2之间的变化,但我无法理解出来。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您需要执行父tearDown方法:

public function tearDown()
{
    Mockery::close();
    parent::tearDown();
}