當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::expects方法代碼示例

本文整理匯總了PHP中Magento\Framework\TestFramework\Unit\Helper\ObjectManager::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::expects方法的具體用法?PHP ObjectManager::expects怎麽用?PHP ObjectManager::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Framework\TestFramework\Unit\Helper\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::expects方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testExecute

 /**
  * @param array $indexerIds
  * @param \Exception $exception
  * @param array $expectsExceptionValues
  * @dataProvider executeDataProvider
  */
 public function testExecute($indexerIds, $exception, $expectsExceptionValues)
 {
     $this->model = new \Magento\Indexer\Controller\Adminhtml\Indexer\MassChangelog($this->contextMock);
     $this->request->expects($this->any())->method('getParam')->with('indexer_ids')->will($this->returnValue($indexerIds));
     if (!is_array($indexerIds)) {
         $this->messageManager->expects($this->once())->method('addError')->with(__('Please select indexers.'))->will($this->returnValue(1));
     } else {
         $this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Indexer\\IndexerRegistry')->will($this->returnValue($this->indexReg));
         $indexerInterface = $this->getMockForAbstractClass('Magento\\Framework\\Indexer\\IndexerInterface', ['setScheduled'], '', false);
         $this->indexReg->expects($this->any())->method('get')->with(1)->will($this->returnValue($indexerInterface));
         if ($exception !== null) {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->throwException($exception));
         } else {
             $indexerInterface->expects($this->any())->method('setScheduled')->with(true)->will($this->returnValue(1));
         }
         $this->messageManager->expects($this->any())->method('addSuccess')->will($this->returnValue(1));
         if ($exception !== null) {
             $this->messageManager->expects($this->exactly($expectsExceptionValues[2]))->method('addError')->with($exception->getMessage());
             $this->messageManager->expects($this->exactly($expectsExceptionValues[1]))->method('addException')->with($exception, "We couldn't change indexer(s)' mode because of an error.");
         }
     }
     $this->helper->expects($this->any())->method("getUrl")->willReturn("magento.com");
     $this->response->expects($this->any())->method("setRedirect")->willReturn(1);
     $this->model->executeInternal();
 }
開發者ID:nblair,項目名稱:magescotch,代碼行數:31,代碼來源:MassChangelogTest.php

示例2: testCreateRouteNegative

 /**
  * @test
  * @expectedException \LogicException
  * @return void
  */
 public function testCreateRouteNegative()
 {
     $this->objectManager->expects($this->once())->method('create')->will($this->returnValue(new \StdClass()));
     $object = new Factory($this->objectManager);
     $object->createRoute('routerClass', 'router');
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:11,代碼來源:FactoryTest.php


注:本文中的Magento\Framework\TestFramework\Unit\Helper\ObjectManager::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。