我正在尝试为我的laravel 5.2
项目创建一个测试,该测试将测试休息资源控制器中的注册页面。当我使用测试的确切输入手动测试它时,一切正常,但是当我使用它进行测试时,phpunit
我被重定向到一个错误页面,使我的页面断言失败。然而,该错误显示了断言失败的错误,而不是错误页面上的内容,因此没有显示测试失败的原因。我怎么能看到这个?
测试用例:
class registerTest extends TestCase
{
use WithoutMiddleware;
public function testRegisterCompanyCorrectly()
{
$this->actAsAdmin();
$this->visit('/Companies/create')
->type('testCompany', 'CName')
->type('www.testCompany.com', 'CUrl')
->type('testManager@gmail.com', 'Mail')
->type('John Doe', 'Name')
->type('Keith Richards', 'Password')
->type('Keith Richards', 'CPassword')
->press('Registreren')
->seePageIs('/Companies/3')
;
}
private function actAsAdmin()
{
$user = User::find(1);
$this->actingAs($user);
}
}'
phpunit错误:
There was 1 failure:
1) registerTest::testRegisterCompanyCorrectly
Did not land on expected page [http://localhost/Companies/3].
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/Companies/3'
+'http://localhost/Companies'
C:\Users\Stefan\Documents\producten\Applicatie\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:170
C:\Users\Stefan\Documents\producten\Applicatie\tests\registerTest.php:34
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:176
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:129
FAILURES!
Tests: 5, Assertions: 14, Failures: 1.