使用 phpunit 的 assertDatabaseMissing () 报错
运行环境,laradock,php7.2.2。
在本章的CreateThreadsTest.php中,使用
$this->assertDatabaseMissing('threads',['id' => $thread->id]);
方法报错。报错提示为:
1) Tests\Feature\CreateThreadsTest::a_thread_can_be_deleted
Error: Class 'PHPUnit_Framework_Constraint_Not' not found
/var/www/forum/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php:38
/var/www/forum/tests/Feature/CreateThreadsTest.php:81
phpunit的版本为:6.5.14.从开始到这一张之前都没有出现这个问题。google搜索了一下,是在启动文件中添加:
class_alias(
\PHPUnit\Framework\Constraint\LogicalNot::class,
'PHPUnit_Framework_Constraint_Not'
);
但是我添加之后显示这个别名already used。
不知道咋解决?
尝试了切换phpunit的版本,7.0不行,8.0不行,然后切换到~5.*后面可以了。。。