本文整理匯總了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();
}
示例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');
}