我正在尝试测试我的laravel应用程序,运行phpunit,但是得到了一个错误:
Error: Call to undefined method Illuminate\Hashing\BcryptHasher::driver()Laravel5.5,PHPUnit 7.0
我的UserTest:
namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
class UserTest extends TestCase
{
use RefreshDatabase;
/** @test */
function name_should_not_be_too_long()
{
$response = $this->post('/users', [
'name' => str_repeat('a', 51),
'email' => $this->user->email,
'password' => 'secret',
]);
$response->assertStatus(302);
$response->assertSessionHasErrors([
'name' => 'The name may not be greater than 50 characters.'
]);
}}
发布于 2018-03-13 12:49:51
在您的CreatesApplication类中,更改这一行:
Hash::driver('bcrypt')->setRounds(4); 对此:
Hash::setRounds(4); 之后,做一个composer dumpautoload
如果仍然没有运气,降级到phpunit 6.0。
https://stackoverflow.com/questions/49126397
复制相似问题