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


PHP Object::expects方法代碼示例

本文整理匯總了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);
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:15,代碼來源:SubmitTest.php

示例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);
 }
開發者ID:Coplex,項目名稱:magento2,代碼行數:15,代碼來源:RegionTest.php

示例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);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:37,代碼來源:ObserverTest.php

示例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));
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:17,代碼來源:TransparentTest.php

示例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));
 }
開發者ID:zhangjiachao,項目名稱:magento2,代碼行數:27,代碼來源:AdminTest.php

示例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]]);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:6,代碼來源:ObjectRegistryTest.php

示例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);
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:9,代碼來源:EditorTest.php


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