使用PHPUnit进行Laravel登录测试
我对测试完全陌生。我正在尝试使用Laracasts/Integrated测试登录使用PHPUnit进行Laravel登录测试,phpunit,laravel-5,Phpunit,Laravel 5,我对测试完全陌生。我正在尝试使用Laracasts/Integrated测试登录 /** @test */ public function it_should_login_user() { $credentials = [ 'email' => 'jghenonig@gmail.com', 'password' => '12345' ]; $this->visit('/auth/login') -&g
/** @test */
public function it_should_login_user()
{
$credentials = [
'email' => 'jghenonig@gmail.com',
'password' => '12345'
];
$this->visit('/auth/login')
->submitForm('Login', $credentials)
->andSee('Dashboard')->onPage('/');
}
我有一个H1标题和图例“Dashboard”,但我得到了这个错误
1) ExampleTest::it\u应该\u登录\u用户
对“”的GET请求失败。改成了500码
第47行/Users/marionava/Code/ilencuentro/vendor/laravel/framework/src/illusted/Database/Connectors/Connector.php上的异常
你能帮我吗?我使用TestCase文件上的方法调用
be()
解决了这个问题。然后我用它创建了一个登录方法,仅此而已
然后我在需要的地方使用这个方法。我在TestCase文件上使用方法调用
be()
解决了这个问题。然后我用它创建了一个登录方法,仅此而已
然后,我在需要的地方使用此方法。看,我想您是在尝试测试登录功能。您没有测试登录功能,因此该问题具有误导性。请考虑更改它,您不会使用此测试登录功能。我想你是在测试登录功能。您没有测试登录功能,因此该问题具有误导性。请考虑更改它,您不会使用此测试登录功能。
//TestCase.php
use Ilencuentro\User;
use Laracasts\Integrated\Extensions\Laravel as IntegrationTest;
use Laracasts\Integrated\Services\Laravel\DatabaseTransactions;
class TestCase extends IntegrationTest {
use DatabaseTransactions;
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app;
}
public function login()
{
$user = User::first();
$this->be($user);
}
}