作者:米饭2502912051 | 来源:互联网 | 2022-12-25 15:09
我正在尝试测试我的laravel应用程序,运行phpunit,但得到一个错误:
Error: Call to undefined method Illuminate\Hashing\BcryptHasher::driver()
laravel 5.5,PHPUnit 7.0
我的用户测试:
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.'
]);
}
}
1> Gazben..:
在CreatesApplication类中更改以下行:
Hash::driver('bcrypt')->setRounds(4);
对此:
Hash::setRounds(4);
在那之后,做一个 composer dumpautoload
如果仍然没有运气,降级到phpunit 6.0.