本文整理汇总了PHP中Magento\Framework\Object::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::expects方法的具体用法?PHP Object::expects怎么用?PHP Object::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Object
的用法示例。
在下文中一共展示了Object::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
$this->orderMock = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
$this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
$this->orderSenderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender\\OrderSender', [], [], '', false);
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getQuote', 'getOrder'])->getMock();
$this->observerMock = $this->getMock('Magento\\Framework\\Object', ['getEvent'], [], '', false);
$this->observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
$eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
$this->quoteMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
$this->model = new \Magento\Quote\Model\Observer\Webapi\Submit($this->loggerMock, $this->orderSenderMock);
}
示例2: testBeforeSave
public function testBeforeSave()
{
$regionId = '23';
$countryId = '67';
$this->object->expects($this->once())->method('getData')->with('region')->willReturn($regionId);
$this->object->expects($this->once())->method('getCountryId')->willReturn($countryId);
$this->regionFactory->expects($this->once())->method('create')->willReturn($this->region);
$this->region->expects($this->once())->method('load')->with($regionId)->willReturnSelf();
$this->region->expects($this->atLeastOnce())->method('getId')->willReturn($regionId);
$this->region->expects($this->once())->method('getCountryId')->willReturn($countryId);
$this->object->expects($this->once())->method('setRegionId')->with($regionId)->willReturnSelf();
$this->region->expects($this->once())->method('getName')->willReturn('Region name');
$this->object->expects($this->once())->method('setRegion')->with('Region name');
$this->model->beforeSave($this->object);
}
示例3: testAddFieldsToResponseSuccess
/**
* Test for addFieldsToResponse method
*
* @return void
*/
public function testAddFieldsToResponseSuccess()
{
$testData = $this->getAddFieldsToResponseSuccessTestData();
$observerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
$orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
$orderPaymentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Payment')->disableOriginalConstructor()->getMock();
$instanceMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost')->disableOriginalConstructor()->getMock();
$requestToAuthorizenetMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Request')->disableOriginalConstructor()->setMethods(['setControllerActionName', 'setIsSecure', 'getData'])->getMock();
$requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getControllerName'])->getMockForAbstractClass();
$storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
$this->coreRegistryMock->expects($this->once())->method('registry')->with('directpost_order')->willReturn($orderMock);
$orderMock->expects($this->once())->method('getId')->willReturn($testData['order.getId']);
$orderMock->expects($this->once())->method('getPayment')->willReturn($orderPaymentMock);
$orderPaymentMock->expects($this->once())->method('getMethod')->willReturn($testData['orderPayment.getMethod']);
$this->paymentMock->expects($this->exactly(2))->method('getCode')->willReturn($testData['payment.getCode']);
$observerMock->expects($this->atLeastOnce())->method('getData')->willReturnMap($testData['observer.getData']);
$this->resultMock->expects($this->once())->method('getData')->willReturn($testData['result.getData']);
$orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($testData['order.getIncrementId']);
$this->sessionMock->expects($this->once())->method('addCheckoutOrderIncrementId')->with($testData['session.addCheckoutOrderIncrementId']);
$this->sessionMock->expects($this->once())->method('setLastOrderIncrementId')->with($testData['session.setLastOrderIncrementId']);
$orderPaymentMock->expects($this->once())->method('getMethodInstance')->willReturn($instanceMock);
$instanceMock->expects($this->once())->method('generateRequestFromOrder')->with($orderMock)->willReturn($requestToAuthorizenetMock);
$this->actionMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
$requestMock->expects($this->once())->method('getControllerName')->willReturn($testData['request.getControllerName']);
$requestToAuthorizenetMock->expects($this->once())->method('setControllerActionName')->with($testData['requestToAuthorizenet.setControllerActionName']);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
$storeMock->expects($this->once())->method('isCurrentlySecure')->willReturn($testData['store.isCurrentlySecure']);
$requestToAuthorizenetMock->expects($this->once())->method('setIsSecure')->with($testData['requestToAuthorizenet.setIsSecure']);
$requestToAuthorizenetMock->expects($this->once())->method('getData')->willReturn($testData['requestToAuthorizenet.getData']);
$this->resultMock->expects($this->once())->method('setData')->with($testData['result.setData']);
$this->observer->addFieldsToResponse($observerMock);
}
示例4: testAuthorize
/**
* Test method
* with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
*/
public function testAuthorize()
{
$this->initializationAuthorizeMock();
$this->buildRequestData();
$this->responseMock->expects($this->any())->method('getResultCode')->willReturn(Payflowpro::RESPONSE_CODE_APPROVED);
$this->responseMock->expects($this->any())->method('getOrigresult')->willReturn(0);
$this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
$this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
$this->responseMock->expects($this->once())->method('getPnref')->willReturn('test-pnref');
$this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
$this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
$this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
}
示例5: testDisplayPriceAttribute
/**
* @param string $expected
* @param bool $dataObjectIsOrder
* @param bool $isCurrencyDifferent
* @param bool $magentoDataObjectHasOrder
* @param bool $strong
* @param string $separator
* @dataProvider displayPricesDataProvider
*/
public function testDisplayPriceAttribute($expected, $dataObjectIsOrder, $isCurrencyDifferent = true, $magentoDataObjectHasOrder = true, $strong = false, $separator = '<br/>')
{
$this->orderMock->expects($this->any())->method('isCurrencyDifferent')->will($this->returnValue($isCurrencyDifferent));
$storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
$this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock));
$this->priceCurrency->expects($this->any())->method('format')->will($this->returnValue('storeFormattedPrice'));
$dataObject = $this->orderMock;
if (!$dataObjectIsOrder) {
$returnRes = false;
if ($magentoDataObjectHasOrder) {
$returnRes = $this->orderMock;
}
$this->magentoObjectMock->expects($this->once())->method('getOrder')->will($this->returnValue($returnRes));
$this->magentoObjectMock->expects($this->any())->method('getData')->will($this->returnValue('data'));
$dataObject = $this->magentoObjectMock;
}
$this->assertEquals($expected, $this->adminHelper->displayPriceAttribute($dataObject, 'code', $strong, $separator));
}
示例6: setUp
protected function setUp()
{
$this->object = $this->getMock('Magento\\Framework\\Object');
$this->object->expects($this->any())->method('getId')->will($this->returnValue(1));
$this->objectRegistry = (new ObjectManager($this))->getObject('Magento\\CatalogUrlRewrite\\Model\\ObjectRegistry', ['entities' => [$this->object]]);
}
示例7: testGetTranslatedString
/**
* Test protected `getTranslatedString` method via public `getElementHtml` method
*/
public function testGetTranslatedString()
{
$this->configMock->expects($this->any())->method('getData')->withConsecutive(['enabled'])->willReturn(true);
$html = $this->model->getElementHtml();
$this->assertRegExp('/.*"Insert Image...":"Insert Image...".*/i', $html);
}