当前位置: 首页>>代码示例>>PHP>>正文


PHP FactoryInterface::expects方法代码示例

本文整理汇总了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());
 }
开发者ID:blazarecki,项目名称:lug,代码行数:9,代码来源:MenuBuilderTest.php

示例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);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:21,代码来源:BuilderChainProviderTest.php


注:本文中的Knp\Menu\FactoryInterface::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。