当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObjectProcessor::expects方法代码示例

本文整理汇总了PHP中Magento\Framework\Reflection\DataObjectProcessor::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectProcessor::expects方法的具体用法?PHP DataObjectProcessor::expects怎么用?PHP DataObjectProcessor::expects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Reflection\DataObjectProcessor的用法示例。


在下文中一共展示了DataObjectProcessor::expects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testToNestedArrayCustom

 /**
  * Test toNestedArray() method with custom attributes and with skipped custom attribute.
  */
 public function testToNestedArrayCustom()
 {
     $dataArray = ['attribute_key' => 'attribute_value', AbstractExtensibleObject::CUSTOM_ATTRIBUTES_KEY => [[AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code', AttributeValue::VALUE => 'custom_attribute_value'], [AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code_multi', AttributeValue::VALUE => ['custom_attribute_value_multi_1', 'custom_attribute_value_multi_2']], [AttributeValue::ATTRIBUTE_CODE => 'custom_attribute_code_skip', AttributeValue::VALUE => 'custom_attribute_value_skip']]];
     $resultArray = ['attribute_key' => 'attribute_value', 'custom_attribute_code' => 'custom_attribute_value', 'custom_attribute_code_multi' => ['custom_attribute_value_multi_1', 'custom_attribute_value_multi_2']];
     $this->processor->expects($this->any())->method('buildOutputDataArray')->with($this->dataObject)->willReturn($dataArray);
     $this->assertEquals($resultArray, $this->converter->toNestedArray($this->dataObject, ['custom_attribute_code_skip']));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:10,代码来源:ExtensibleDataObjectConverterTest.php

示例2: testNewAccount

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testNewAccount()
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerEmail = 'email@email.com';
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false);
     $customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getEmail')->willReturn($customerEmail);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId);
     $this->storeManagerMock->expects($this->once())->method('getStore')->with($customerStoreId)->willReturn($this->storeMock);
     $this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecureMock);
     $this->dataProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)->willReturn($customerData);
     $this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $this->customerSecureMock->expects($this->once())->method('addData')->with($customerData)->willReturnSelf();
     $this->customerSecureMock->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf();
     $this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier);
     $this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender);
     $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false);
     $this->transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['customer' => $this->customerSecureMock, 'back_url' => '', 'store' => $this->storeMock])->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('getTransport')->willReturn($transport);
     $transport->expects($this->once())->method('sendMessage');
     $this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:EmailNotificationTest.php

示例3: testSave

 public function testSave()
 {
     $groupId = 0;
     $taxClass = $this->getMockForAbstractClass('Magento\\Tax\\Api\\Data\\TaxClassInterface', [], '', false);
     $this->group->expects($this->once())->method('getCode')->willReturn('Code');
     $this->group->expects($this->atLeastOnce())->method('getId')->willReturn($groupId);
     $this->group->expects($this->once())->method('getTaxClassId')->willReturn(17);
     $this->groupModel->expects($this->atLeastOnce())->method('getId')->willReturn($groupId);
     $this->groupModel->expects($this->atLeastOnce())->method('getCode')->willReturn('Code');
     $this->groupModel->expects($this->atLeastOnce())->method('getTaxClassId')->willReturn(234);
     $this->groupModel->expects($this->atLeastOnce())->method('getTaxClassName')->willReturn('Tax class name');
     $this->group->expects($this->once())->method('setId')->with($groupId)->willReturnSelf();
     $this->group->expects($this->once())->method('setCode')->with('Code')->willReturnSelf();
     $this->group->expects($this->once())->method('setTaxClassId')->with(234)->willReturnSelf();
     $this->group->expects($this->once())->method('setTaxClassName')->with('Tax class name')->willReturnSelf();
     $this->taxClassRepository->expects($this->once())->method('get')->with(17)->willReturn($taxClass);
     $taxClass->expects($this->once())->method('getClassType')->willReturn('CUSTOMER');
     $this->groupRegistry->expects($this->once())->method('retrieve')->with($groupId)->willReturn($this->groupModel);
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->with($this->group, '\\Magento\\Customer\\Api\\Data\\GroupInterface')->willReturn(['attributeCode' => 'attributeData']);
     $this->groupModel->expects($this->once())->method('setDataUsingMethod')->with('attributeCode', 'attributeData');
     $this->groupResourceModel->expects($this->once())->method('save')->with($this->groupModel);
     $this->groupRegistry->expects($this->once())->method('remove')->with($groupId);
     $this->groupDataFactory->expects($this->once())->method('create')->willReturn($this->group);
     $this->assertSame($this->group, $this->model->save($this->group));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:GroupRepositoryTest.php

示例4: prepareInitiatePasswordReset

 /**
  * @param string $email
  * @param string $templateIdentifier
  * @param string $sender
  * @param int $storeId
  * @param int $customerId
  * @param string $hash
  */
 protected function prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash)
 {
     $websiteId = 1;
     $dateTime = date(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
     $this->store->expects($this->any())->method('getId')->willReturn($storeId);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->any())->method('getEmail')->willReturn($email);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getStoreId')->willReturn($storeId);
     $this->customerRepository->expects($this->once())->method('get')->with($email, $websiteId)->willReturn($customer);
     $this->customerRepository->expects($this->once())->method('save')->with($customer)->willReturnSelf();
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($hash);
     $this->customerViewHelper->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $this->customerSecure->expects($this->any())->method('setRpToken')->with($hash)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setRpTokenCreatedAt')->with($dateTime)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('addData')->with($customerData)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setData')->with('name', $customerName)->willReturnSelf();
     $this->customerRegistry->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
     $this->dataObjectProcessor->expects($this->any())->method('buildOutputDataArray')->with($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName);
 }
开发者ID:nja78,项目名称:magento2,代码行数:33,代码来源:AccountManagementTest.php

示例5: testToModel

 public function testToModel()
 {
     /**
      * @var \Magento\SalesRule\Model\Data\Rule $dataModel
      */
     $dataModel = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Data\\Rule')->disableOriginalConstructor()->setMethods(['create', 'load', 'getData', 'getRuleId', 'getCondition', 'getActionCondition', 'getStoreLabels'])->getMock();
     $dataModel->expects($this->atLeastOnce())->method('getRuleId')->willReturn(1);
     $dataModel->expects($this->atLeastOnce())->method('getCondition')->willReturn(false);
     $dataModel->expects($this->atLeastOnce())->method('getActionCondition')->willReturn(false);
     $dataModel->expects($this->atLeastOnce())->method('getStoreLabels')->willReturn([]);
     $ruleModel = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Rule')->disableOriginalConstructor()->setMethods(['create', 'load', 'getId', 'getData'])->getMock();
     $ruleModel->expects($this->atLeastOnce())->method('load')->willReturn($ruleModel);
     $ruleModel->expects($this->atLeastOnce())->method('getId')->willReturn(1);
     $ruleModel->expects($this->atLeastOnce())->method('getData')->willReturn(['data_1' => 1]);
     $this->dataObjectProcessor->expects($this->any())->method('buildOutputDataArray')->willReturn(['data_2' => 2]);
     $this->ruleFactory->expects($this->any())->method('create')->willReturn($ruleModel);
     $result = $this->model->toModel($dataModel);
     $this->assertEquals($ruleModel, $result);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:ToModelTest.php

示例6: testFormattingDate

 /**
  * @dataProvider expectedDatesProvider
  */
 public function testFormattingDate($data)
 {
     /**
      * @var \Magento\SalesRule\Model\Data\Rule|\PHPUnit_Framework_MockObject_MockObject $dataModel
      */
     $dataModel = $this->getMockBuilder(\Magento\SalesRule\Model\Data\Rule::class)->disableOriginalConstructor()->setMethods(['create', 'load', 'getData', 'getRuleId', 'getCondition', 'getActionCondition', 'getStoreLabels', 'getFromDate', 'setFromDate', 'getToDate', 'setToDate'])->getMock();
     $dataModel->expects($this->atLeastOnce())->method('getRuleId')->willReturn(null);
     $dataModel->expects($this->atLeastOnce())->method('getCondition')->willReturn(false);
     $dataModel->expects($this->atLeastOnce())->method('getActionCondition')->willReturn(false);
     $dataModel->expects($this->atLeastOnce())->method('getStoreLabels')->willReturn([]);
     $ruleModel = $this->getMockBuilder('\\Magento\\SalesRule\\Model\\Rule')->disableOriginalConstructor()->setMethods(['create', 'load', 'getId', 'getData'])->getMock();
     $ruleModel->expects($this->atLeastOnce())->method('getData')->willReturn(['data_1' => 1]);
     $this->dataObjectProcessor->expects($this->any())->method('buildOutputDataArray')->willReturn(['data_2' => 2]);
     $this->ruleFactory->expects($this->any())->method('create')->willReturn($ruleModel);
     $dataModel->expects($this->atLeastOnce())->method('getFromDate')->willReturn($data['from_date']);
     $dataModel->expects($this->atLeastOnce())->method('getToDate')->willReturn($data['to_date']);
     $dataModel->expects($this->atLeastOnce())->method('setFromDate')->with($data['expected_from_date']);
     $dataModel->expects($this->atLeastOnce())->method('setToDate')->with($data['expected_to_date']);
     $this->model->toModel($dataModel);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:23,代码来源:ToModelTest.php

示例7: testCall

 public function testCall()
 {
     $requestedServices = ['requestedServices'];
     $this->_requestMock->expects($this->once())->method('getRequestedServices')->will($this->returnValue($requestedServices));
     $this->_dataObjectConverter->expects($this->once())->method('convertStdObjectToArray')->will($this->returnValue(['field' => 1]));
     $operationName = 'soapOperation';
     $className = 'Magento\\Framework\\Object';
     $methodName = 'testMethod';
     $isSecure = false;
     $aclResources = [['Magento_TestModule::resourceA']];
     $this->_apiConfigMock->expects($this->once())->method('getServiceMethodInfo')->with($operationName, $requestedServices)->will($this->returnValue([SoapConfig::KEY_CLASS => $className, SoapConfig::KEY_METHOD => $methodName, SoapConfig::KEY_IS_SECURE => $isSecure, SoapConfig::KEY_ACL_RESOURCES => $aclResources]));
     $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $serviceMock = $this->getMockBuilder($className)->disableOriginalConstructor()->setMethods([$methodName])->getMock();
     $serviceResponse = ['foo' => 'bar'];
     $serviceMock->expects($this->once())->method($methodName)->will($this->returnValue($serviceResponse));
     $this->_objectManagerMock->expects($this->once())->method('get')->with($className)->will($this->returnValue($serviceMock));
     $this->_serviceInputProcessorMock->expects($this->once())->method('process')->will($this->returnArgument(2));
     $this->_dataObjectProcessorMock->expects($this->any())->method('getMethodReturnType')->with($className, $methodName)->will($this->returnValue('string'));
     /** Execute SUT. */
     $this->assertEquals(['result' => $serviceResponse], $this->_handler->__call($operationName, [(object) ['field' => 1]]));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:21,代码来源:HandlerTest.php

示例8: testSendNotificationEmailsIfRequired

 /**
  * @param int $testNumber
  * @param string $oldEmail
  * @param string $newEmail
  * @param bool $isPasswordChanged
  *
  * @dataProvider sendNotificationEmailsDataProvider
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendNotificationEmailsIfRequired($testNumber, $oldEmail, $newEmail, $isPasswordChanged)
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerWebsiteId = 1;
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     switch ($testNumber) {
         case 1:
             $xmlPathTemplate = EmailNotification::XML_PATH_RESET_PASSWORD_TEMPLATE;
             $expects = $this->once();
             break;
         case 2:
             $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE;
             $expects = $this->exactly(2);
             break;
         case 3:
             $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_AND_PASSWORD_TEMPLATE;
             $expects = $this->exactly(2);
             break;
     }
     $origCustomer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $origCustomer->expects($this->any())->method('getStoreId')->willReturn(0);
     $origCustomer->expects($this->any())->method('getId')->willReturn($customerId);
     $origCustomer->expects($this->any())->method('getWebsiteId')->willReturn($customerWebsiteId);
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId);
     $this->storeManagerMock->expects(clone $expects)->method('getStore')->willReturn($storeMock);
     $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->setMethods(['getStoreIds'])->getMock();
     $websiteMock->expects($this->any())->method('getStoreIds')->willReturn([$customerStoreId]);
     $this->storeManagerMock->expects(clone $expects)->method('getWebsite')->with($customerWebsiteId)->willReturn($websiteMock);
     $customerSecureMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->disableOriginalConstructor()->getMock();
     $this->customerRegistryMock->expects(clone $expects)->method('retrieveSecureData')->with($customerId)->willReturn($customerSecureMock);
     $this->dataProcessorMock->expects(clone $expects)->method('buildOutputDataArray')->with($origCustomer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($origCustomer)->willReturn($customerName);
     $customerSecureMock->expects(clone $expects)->method('addData')->with($customerData)->willReturnSelf();
     $customerSecureMock->expects(clone $expects)->method('setData')->with('name', $customerName)->willReturnSelf();
     $savedCustomer = clone $origCustomer;
     $origCustomer->expects($this->any())->method('getEmail')->willReturn($oldEmail);
     $savedCustomer->expects($this->any())->method('getEmail')->willReturn($newEmail);
     $this->scopeConfigMock->expects($this->any())->method('getValue')->withConsecutive([$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [\Magento\Customer\Helper\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [\Magento\Customer\Helper\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId])->willReturnOnConsecutiveCalls($templateIdentifier, $sender, $templateIdentifier, $sender);
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateOptions')->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateVars')->with(['customer' => $customerSecureMock, 'store' => $storeMock])->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('addTo')->withConsecutive([$oldEmail, $customerName], [$newEmail, $customerName])->willReturnSelf();
     $transport = $this->getMockBuilder('Magento\\Framework\\Mail\\TransportInterface')->getMock();
     $this->transportBuilderMock->expects(clone $expects)->method('getTransport')->willReturn($transport);
     $transport->expects(clone $expects)->method('sendMessage');
     $this->assertEquals($this->helper, $this->helper->sendNotificationEmailsIfRequired($origCustomer, $savedCustomer, $isPasswordChanged));
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:62,代码来源:EmailNotificationTest.php

示例9: testMergeDataObjects

 /**
  * @param array $data1
  * @param array $data2
  * @dataProvider dataProviderForTestMergeDataObjects
  */
 public function testMergeDataObjects($data1, $data2)
 {
     /** @var \Magento\Customer\Model\Data\Address $addressDataObject */
     $firstAddressDataObject = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address', ['dataObjectHelper' => $this->dataObjectHelper]);
     /** @var \Magento\Customer\Model\Data\Region $regionDataObject */
     $firstRegionDataObject = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Region', ['dataObjectHelper' => $this->dataObjectHelper]);
     $firstRegionDataObject->setRegionId($data1['region']['region_id']);
     $firstRegionDataObject->setRegion($data1['region']['region']);
     if (isset($data1['id'])) {
         $firstAddressDataObject->setId($data1['id']);
     }
     if (isset($data1['country_id'])) {
         $firstAddressDataObject->setCountryId($data1['country_id']);
     }
     $firstAddressDataObject->setStreet($data1['street']);
     $firstAddressDataObject->setIsDefaultShipping($data1['default_shipping']);
     $firstAddressDataObject->setRegion($firstRegionDataObject);
     $secondAddressDataObject = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Address', ['dataObjectHelper' => $this->dataObjectHelper]);
     /** @var \Magento\Customer\Model\Data\Region $regionDataObject */
     $secondRegionDataObject = $this->objectManager->getObject('Magento\\Customer\\Model\\Data\\Region', ['dataObjectHelper' => $this->dataObjectHelper]);
     $secondRegionDataObject->setRegionId($data2['region']['region_id']);
     $secondRegionDataObject->setRegion($data2['region']['region']);
     if (isset($data2['id'])) {
         $secondAddressDataObject->setId($data2['id']);
     }
     if (isset($data2['country_id'])) {
         $secondAddressDataObject->setCountryId($data2['country_id']);
     }
     $secondAddressDataObject->setStreet($data2['street']);
     $secondAddressDataObject->setIsDefaultShipping($data2['default_shipping']);
     $secondAddressDataObject->setRegion($secondRegionDataObject);
     $this->objectProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($secondAddressDataObject, get_class($firstAddressDataObject))->willReturn($data2);
     $this->methodsMapProcessor->expects($this->at(0))->method('getMethodReturnType')->with('Magento\\Customer\\Model\\Data\\Address', 'getStreet')->willReturn('string[]');
     $this->methodsMapProcessor->expects($this->at(1))->method('getMethodReturnType')->with('Magento\\Customer\\Model\\Data\\Address', 'getRegion')->willReturn('\\Magento\\Customer\\Api\\Data\\RegionInterface');
     $this->objectFactoryMock->expects($this->once())->method('create')->with('\\Magento\\Customer\\Api\\Data\\RegionInterface', [])->willReturn($secondRegionDataObject);
     $this->dataObjectHelper->mergeDataObjects(get_class($firstAddressDataObject), $firstAddressDataObject, $secondAddressDataObject);
     $this->assertSame($firstAddressDataObject->getId(), $secondAddressDataObject->getId());
     $this->assertSame($firstAddressDataObject->getCountryId(), $secondAddressDataObject->getCountryId());
     $this->assertSame($firstAddressDataObject->getStreet(), $secondAddressDataObject->getStreet());
     $this->assertSame($firstAddressDataObject->isDefaultShipping(), $secondAddressDataObject->isDefaultShipping());
     $this->assertSame($firstAddressDataObject->getRegion(), $secondAddressDataObject->getRegion());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:47,代码来源:DataObjectHelperTest.php

示例10: testGetList

 /**
  * @test
  */
 public function testGetList()
 {
     $field = 'name';
     $value = 'magento';
     $condition = 'eq';
     $total = 10;
     $currentPage = 3;
     $pageSize = 2;
     $sortField = 'id';
     $criteria = $this->getMockBuilder('Magento\\Framework\\Api\\SearchCriteriaInterface')->getMock();
     $filterGroup = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->getMock();
     $filter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->getMock();
     $storeFilter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->getMock();
     $sortOrder = $this->getMockBuilder('Magento\\Framework\\Api\\SortOrder')->getMock();
     $criteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
     $criteria->expects($this->once())->method('getSortOrders')->willReturn([$sortOrder]);
     $criteria->expects($this->once())->method('getCurrentPage')->willReturn($currentPage);
     $criteria->expects($this->once())->method('getPageSize')->willReturn($pageSize);
     $filterGroup->expects($this->once())->method('getFilters')->willReturn([$storeFilter, $filter]);
     $filter->expects($this->once())->method('getConditionType')->willReturn($condition);
     $filter->expects($this->any())->method('getField')->willReturn($field);
     $filter->expects($this->once())->method('getValue')->willReturn($value);
     $storeFilter->expects($this->any())->method('getField')->willReturn('store_id');
     $storeFilter->expects($this->once())->method('getValue')->willReturn(1);
     $sortOrder->expects($this->once())->method('getField')->willReturn($sortField);
     $sortOrder->expects($this->once())->method('getDirection')->willReturn(SortOrder::SORT_DESC);
     /** @var \Magento\Framework\Api\SearchCriteriaInterface $criteria */
     $this->collection->addItem($this->block);
     $this->blockSearchResult->expects($this->once())->method('setSearchCriteria')->with($criteria)->willReturnSelf();
     $this->collection->expects($this->once())->method('addFieldToFilter')->with($field, [$condition => $value])->willReturnSelf();
     $this->blockSearchResult->expects($this->once())->method('setTotalCount')->with($total)->willReturnSelf();
     $this->collection->expects($this->once())->method('getSize')->willReturn($total);
     $this->collection->expects($this->once())->method('setCurPage')->with($currentPage)->willReturnSelf();
     $this->collection->expects($this->once())->method('setPageSize')->with($pageSize)->willReturnSelf();
     $this->collection->expects($this->once())->method('addOrder')->with($sortField, 'DESC')->willReturnSelf();
     $this->block->expects($this->once())->method('getData')->willReturn(['data']);
     $this->blockSearchResult->expects($this->once())->method('setItems')->with(['someData'])->willReturnSelf();
     $this->dataHelper->expects($this->once())->method('populateWithArray')->with($this->blockData, ['data'], 'Magento\\Cms\\Api\\Data\\BlockInterface');
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->with($this->blockData, 'Magento\\Cms\\Api\\Data\\BlockInterface')->willReturn('someData');
     $this->assertEquals($this->blockSearchResult, $this->repository->getList($criteria));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:44,代码来源:BlockRepositoryTest.php

示例11: testExecuteWithTaxClassAndException

 public function testExecuteWithTaxClassAndException()
 {
     $taxClass = '3';
     $groupId = 0;
     $code = 'NOT LOGGED IN';
     $this->request->expects($this->exactly(3))->method('getParam')->withConsecutive(['tax_class'], ['id'], ['code'])->willReturnOnConsecutiveCalls($taxClass, $groupId, null);
     $this->resultRedirectFactory->expects($this->once())->method('create')->willReturn($this->resultRedirect);
     $this->groupRepositoryMock->expects($this->once())->method('getById')->with($groupId)->willReturn($this->group);
     $this->group->expects($this->once())->method('getCode')->willReturn($code);
     $this->group->expects($this->once())->method('setCode')->with($code);
     $this->group->expects($this->once())->method('setTaxClassId')->with($taxClass);
     $this->groupRepositoryMock->expects($this->once())->method('save')->with($this->group);
     $this->messageManager->expects($this->once())->method('addSuccess')->with(__('You saved the customer group.'));
     $exception = new \Exception('Exception');
     $this->resultRedirect->expects($this->at(0))->method('setPath')->with('customer/group')->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addError')->with('Exception');
     $this->dataObjectProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($this->group, '\\Magento\\Customer\\Api\\Data\\GroupInterface')->willReturn(['code' => $code]);
     $this->session->expects($this->once())->method('setCustomerGroupData')->with(['customer_group_code' => $code]);
     $this->resultRedirect->expects($this->at(1))->method('setPath')->with('customer/group/edit', ['id' => $groupId]);
     $this->assertSame($this->resultRedirect, $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:21,代码来源:SaveTest.php

示例12: testSendPasswordReminderEmail

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendPasswordReminderEmail()
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerEmail = 'email@email.com';
     $passwordToken = 'token';
     $isFrontendSecure = true;
     $resetUrl = 'reset url';
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getEmail')->willReturn($customerEmail);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getStore')->with($customerStoreId)->willReturn($store);
     $store->expects($this->any())->method('isFrontUrlSecure')->willReturn($isFrontendSecure);
     $this->url->expects($this->once())->method('getUrl')->with('customer/account/createPassword', ['_query' => ['id' => $customerId, 'token' => $passwordToken], '_store' => $customerStoreId, '_secure' => $isFrontendSecure])->willReturn($resetUrl);
     $customerSecure = $this->getMockBuilder('\\Magento\\Customer\\Model\\Data\\CustomerSecure')->disableOriginalConstructor()->setMethods(['addData', 'setData', 'setResetPasswordUrl'])->getMock();
     $this->customerRegistry->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($customerSecure);
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->with($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->customerViewHelper->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $customerSecure->expects($this->once())->method('addData')->with($customerData)->willReturnSelf();
     $customerSecure->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf();
     $customerSecure->expects($this->once())->method('setResetPasswordUrl')->with($resetUrl);
     $this->scopeConfig->expects($this->at(0))->method('getValue')->with(AccountManagement::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier);
     $this->scopeConfig->expects($this->at(1))->method('getValue')->with(AccountManagement::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender);
     $transport = $this->getMockBuilder('Magento\\Framework\\Mail\\TransportInterface')->getMock();
     $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateVars')->with(['customer' => $customerSecure, 'store' => $store])->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport);
     $transport->expects($this->once())->method('sendMessage');
     $this->assertEquals($this->accountManagement, $this->accountManagement->sendPasswordReminderEmail($customer, $passwordToken));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:42,代码来源:AccountManagementTest.php


注:本文中的Magento\Framework\Reflection\DataObjectProcessor::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。