本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Test\WebTestCase::assertCount方法的典型用法代码示例。如果您正苦于以下问题:PHP WebTestCase::assertCount方法的具体用法?PHP WebTestCase::assertCount怎么用?PHP WebTestCase::assertCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Test\WebTestCase
的用法示例。
在下文中一共展示了WebTestCase::assertCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: iSelectFromADateDaysFromNow
/**
*
* @Given /^I select from "([^"]*)" a date "([^"]*)"$/
*/
public function iSelectFromADateDaysFromNow($cssQuery, $diff)
{
$items = $this->getPage()->findAll('css', $cssQuery);
$fields = array();
foreach ($items as $item) {
$id = $item->getAttribute('id');
if (substr($id, strlen($id) - strlen('year'), strlen($id)) == 'year') {
$fields['year'] = $item;
continue;
}
if (substr($id, strlen($id) - strlen('month'), strlen($id)) == 'month') {
$fields['month'] = $item;
continue;
}
if (substr($id, strlen($id) - strlen('day'), strlen($id)) == 'day') {
$fields['day'] = $item;
continue;
}
}
WebTestCase::assertCount(3, $fields, 'Date fields could not be found!');
WebTestCase::assertArrayHasKey('year', $fields, 'The year field could not be found!');
WebTestCase::assertArrayHasKey('month', $fields, 'The month field could not be found!');
WebTestCase::assertArrayHasKey('day', $fields, 'The day field could not be found!');
$date = new \Datetime($diff);
$filterFunc = function ($options, $has) {
foreach ($options as $option) {
if ($option->getText() == $has) {
return true;
}
}
return false;
};
WebTestCase::assertTrue(call_user_func_array($filterFunc, array($fields['year']->findAll('css', 'option'), $date->format('Y'))));
WebTestCase::assertTrue(call_user_func_array($filterFunc, array($fields['month']->findAll('css', 'option'), $date->format('M'))));
WebTestCase::assertTrue(call_user_func_array($filterFunc, array($fields['day']->findAll('css', 'option'), $date->format('j'))));
$fields['year']->selectOption($date->format('Y'));
$fields['month']->selectOption($date->format('M'));
$fields['day']->selectOption($date->format('j'));
}