本文整理汇总了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);
}