本文整理匯總了PHP中Knp\Menu\FactoryInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP FactoryInterface::expects方法的具體用法?PHP FactoryInterface::expects怎麽用?PHP FactoryInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Knp\Menu\FactoryInterface
的用法示例。
在下文中一共展示了FactoryInterface::expects方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCreate
public function testCreate()
{
$this->builder->expects($this->once())->method('getName')->will($this->returnValue($name = 'name'));
$this->factory->expects($this->once())->method('createItem')->with($this->identicalTo($name))->will($this->returnValue($item = $this->createItemMock()));
$this->eventDispatcher->expects($this->once())->method('dispatch')->with($this->identicalTo(MenuBuilderEvents::BUILD), $this->callback(function (MenuBuilderEvent $event) use($item) {
return $event->getFactory() === $this->factory && $event->getItem() === $item;
}));
$this->assertSame($item, $this->builder->create());
}
示例2: testSorting
public function testSorting()
{
$menuName = 'test_menu';
$options = array();
$topMenu = $this->getMockBuilder('Knp\\Menu\\ItemInterface')->getMock();
$topMenu->expects($this->any())->method('hasChildren')->will($this->returnValue(true));
$topMenu->expects($this->any())->method('getDisplayChildren')->will($this->returnValue(true));
$menu = $this->getMockBuilder('Knp\\Menu\\ItemInterface')->getMock();
$menu->expects($this->any())->method('hasChildren')->will($this->returnValue(true));
$menu->expects($this->any())->method('getDisplayChildren')->will($this->returnValue(true));
$childOne = $this->getChildItem('child1', 5);
$childTwo = $this->getChildItem('child2', 10);
$childThree = $this->getChildItem('child3');
$childFour = $this->getChildItem('child4');
$menu->expects($this->any())->method('getChildren')->will($this->returnValue(array($childThree, $childFour, $childTwo, $childOne)));
$topMenu->expects($this->any())->method('getChildren')->will($this->returnValue(array($menu)));
$this->factory->expects($this->once())->method('createItem')->with($menuName)->will($this->returnValue($topMenu));
$menu->expects($this->once())->method('reorderChildren')->with(array('child1', 'child2', 'child3', 'child4'));
$newMenu = $this->provider->get($menuName, $options);
$this->assertInstanceOf('Knp\\Menu\\ItemInterface', $newMenu);
}