本文整理汇总了PHP中Definition::getExpectations方法的典型用法代码示例。如果您正苦于以下问题:PHP Definition::getExpectations方法的具体用法?PHP Definition::getExpectations怎么用?PHP Definition::getExpectations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Definition
的用法示例。
在下文中一共展示了Definition::getExpectations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expects_an_expected_field_in_each_expectation
/**
* @test
*/
public function expects_an_expected_field_in_each_expectation()
{
$this->assertException(new \Exception('Missing expected field.'), function () {
$definitions = array('expectations' => array(array('uri' => 'http://www.example.com', 'type' => 'json')));
$d = new Definition($definitions);
$d->getExpectations();
});
}
示例2: test
public function test()
{
$loader = new ResourceLoader();
$definitions = new Definition($loader->load($this->source));
foreach ($definitions->getExpectations() as $definition) {
if (null !== $definition['type']) {
$actual = $loader->getType($definition['uri']);
if ($actual !== $definition['type']) {
throw new FailedExpectationException("Type mismatch for {$definition['uri']}. Got [{$actual}] but expected [{$definition['type']}]");
}
}
$expectation = new Expectation($definition['expected']);
if (!$expectation->assert($loader->load($definition['uri']))) {
throw new FailedExpectationException(implode("\n", $expectation->getMessages()));
}
}
return true;
}