本文整理汇总了PHP中Magento\Framework\ObjectManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::expects方法的具体用法?PHP ObjectManager::expects怎么用?PHP ObjectManager::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::expects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreate
public function testCreate()
{
$type = '1';
$data = ['data2', 'data3'];
$this->objectManagerMock->expects($this->once())->method('create')->with($type, $data);
$this->conditionFactory->create($type, $data);
}
示例2: testCreate
public function testCreate()
{
$rawResponse = ['documents' => [['title' => 'oneTitle', 'description' => 'oneDescription'], ['title' => 'twoTitle', 'description' => 'twoDescription']], 'aggregations' => []];
$exceptedResponse = ['documents' => [[['name' => 'title', 'value' => 'oneTitle'], ['name' => 'description', 'value' => 'oneDescription']], [['name' => 'title', 'value' => 'twoTitle'], ['name' => 'description', 'value' => 'twoDescription']]], 'aggregations' => []];
$this->documentFactory->expects($this->at(0))->method('create')->with($this->equalTo($exceptedResponse['documents'][0]))->will($this->returnValue('document1'));
$this->documentFactory->expects($this->at(1))->method('create')->with($exceptedResponse['documents'][1])->will($this->returnValue('document2'));
$this->objectManager->expects($this->once())->method('create')->with($this->equalTo('\\Magento\\Framework\\Search\\QueryResponse'), $this->equalTo(['documents' => ['document1', 'document2'], 'aggregations' => null]))->will($this->returnValue('QueryResponseObject'));
$result = $this->factory->create($rawResponse);
$this->assertEquals('QueryResponseObject', $result);
}
示例3: exceptionResponse
/**
* Processing section runtime errors
*
* @return void
*/
protected function exceptionResponse()
{
$dataMock = $this->getMock('Magento\\Core\\Helper\\Data', ['jsonEncode'], [], '', false);
$this->objectManagerMock->expects($this->once())->method('get')->will($this->returnValue($dataMock));
$dataMock->expects($this->once())->method('jsonEncode')->will($this->returnValue('{json-data}'));
$this->responseMock->expects($this->once())->method('representJson')->with('{json-data}');
}