用于验证错误的PHPunit测试 - Laravel 5.2

时间:2017-05-12 04:38:41

标签: php laravel-5.2 phpunit

我有一个包含姓名,电子邮件,消息字段的联系表格,我有一个控制器可以验证一些输入:

我有一个测试证明这种情况正在发生:

<?php 
    public function testContactFormValidationFields()
{
        $this->visit('/contact')
            ->type('', 'name')
            ->type('', 'email')
            ->type('', 'message')
            ->press('Send message')
            ->see('Sorry, there were some errors sending your message:')
            ->see('The name field is required.')
            ->see('The email field is required.')
            ->see('The message field is required.')
            ->seePageIs('/contact');     
}
?>

在终端中得到例外如下:

1) LoggedOutFormTest::testContactFormValidationFields
ErrorException: Declaration of Illuminate\Foundation\Testing\Constraints\PageCon
straint::fail() should be compatible with PHPUnit_Framework_Constraint::fail($ot
her, $description, PHPUnit_Framework_ComparisonFailure $comparisonFailure = NULL
)

D:\xampp\htdocs\phpunit-test\vendor\laravel\framework\src\Illuminate\Foundation\Tes
ting\Constraints\PageConstraint.php:114
D:\xampp\htdocs\phpunit-test\vendor\laravel\framework\src\Illuminate\Foundation\Tes
ting\Constraints\HasSource.php:6
D:\xampp\htdocs\phpunit-test\vendor\laravel\framework\src\Illuminate\Foundation\Tes
ting\Concerns\InteractsWithPages.php:263
D:\xampp\htdocs\phpunit-test\tests\myproject\LoggedOutFormTest.php:27
←[37;41m                                   ←[0m
←[37;41mFAILURES!                          ←[0m
←[37;41mTests: 1, Assertions: 3, Errors: 1.←[0m

0 个答案:

没有答案