我想在PHP7中测试标量类型提示和严格类型的示例方法.当我没有传递参数时,该方法应该抛出一个TypeError.PHPSpec返回致命错误:
未捕获的TypeError:参数1传递给Example :: test
<?php
class Example
{
public function test(string $name)
{
$this->name = $name;
}
}
class ExampleSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Test\Example');
}
function it_check_test_method_when_not_pass_argument()
{
$this->shouldThrow('\TypeError')->during('test');
}
}
Run Code Online (Sandbox Code Playgroud)
一开始我宣布: declare(strict_types=1);
怎么了?我如何测试投掷TypeError?
我有使用JavaScript的验证表单,我想测试验证消息,因为消息是几种语言.然而,Behat引发了一个例外
无法打开连接:http POST引发的卷曲错误
http:// localhost:4444/wd/hub/session with params:{"desiredCapabilities":{"tags":["vagrant-ubuntu-trusty-32","PHP 7.0.1-2 + deb.sury.org ~relusty + 1"],"浏览器":"firefox","ignoreZoomSetting":false,"name":"Behat feature suite","browserName":"firefox"}}
无法连接到localhost端口4444:连接被拒绝(Behat\Mink\Exception\DriverException)
Feature: Validator form contact
In the contact form to see a validator message
@javascript
Scenario: Message validation in English lang
Given I am on "/"
When I fill in "name" with "behat"
And I fill in "email" with "example@example.com"
And I fill in "phone" with "111222333"
And I fill in "message" with "That test message, send via Behat."
When I press "Send Message"
Then …Run Code Online (Sandbox Code Playgroud)