當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。