Exemple #1
0
 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = [['email', '*****@*****.**'], ['group_id', 1]];
     $attributeMocks = [];
     foreach ($attributes as $attribute) {
         $attributeMock = $this->getMock('Magento\\Customer\\Api\\Data\\AttributeMetadataInterface', [], [], '', false);
         $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0]));
         $attributeMocks[] = $attributeMock;
     }
     $customerGroupMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\GroupInterface', [], '', false, true, true, ['getTaxClassId']);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId));
     $customerFormMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks));
     $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue([]));
     $customerFormMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->getMock('Magento\\Framework\\App\\RequestInterface')));
     $customerMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerMapper->expects($this->atLeastOnce())->method('toFlatArray')->willReturn(['email' => '*****@*****.**', 'group_id' => 1, 'gender' => 1]);
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $quoteMock->expects($this->once())->method('addData')->with(['customer_email' => $attributes[0][1], 'customer_group_id' => $attributes[1][1], 'customer_tax_class_id' => $taxClassId]);
     $this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with($customerMock, ['email' => '*****@*****.**', 'group_id' => 1, 'gender' => 1], '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
     $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->customerFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
     $this->groupRepositoryMock->expects($this->once())->method('getById')->will($this->returnValue($customerGroupMock));
     $this->adminOrderCreate->setAccountData([]);
 }
Exemple #2
0
 public function testSetAccountData()
 {
     $taxClassId = 1;
     $attributes = array(array('email', '*****@*****.**'), array('group_id', 1));
     $attributeMocks = array();
     foreach ($attributes as $attribute) {
         $attributeMock = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata', array(), array(), '', false);
         $attributeMock->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attribute[0]));
         $attributeMocks[] = $attributeMock;
     }
     $customerGroupMock = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\CustomerGroup', array(), array(), '', false);
     $customerGroupMock->expects($this->once())->method('getTaxClassId')->will($this->returnValue($taxClassId));
     $customerFormMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', array(), array(), '', false);
     $customerFormMock->expects($this->any())->method('getAttributes')->will($this->returnValue($attributeMocks));
     $customerFormMock->expects($this->any())->method('extractData')->will($this->returnValue(array()));
     $customerFormMock->expects($this->any())->method('restoreData')->will($this->returnValue(array()));
     $customerFormMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->getMock('Magento\\Framework\\App\\RequestInterface')));
     $customerMock = $this->getMock('Magento\\Customer\\Service\\V1\\Data\\Customer', array(), array(), '', false);
     $customerMock->expects($this->any())->method('__toArray')->will($this->returnValue(array('email' => '*****@*****.**', 'group_id' => 1)));
     $quoteMock = $this->getMock('Magento\\Sales\\Model\\Quote', array(), array(), '', false);
     $quoteMock->expects($this->any())->method('getCustomerData')->will($this->returnValue($customerMock));
     $quoteMock->expects($this->once())->method('addData')->with(array('customer_email' => $attributes[0][1], 'customer_group_id' => $attributes[1][1], 'customer_tax_class_id' => $taxClassId));
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerFormMock));
     $this->sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->customerBuilderMock->expects($this->any())->method('populateWithArray')->will($this->returnSelf());
     $this->customerBuilderMock->expects($this->any())->method('create')->will($this->returnValue($customerMock));
     $this->customerBuilderMock->expects($this->any())->method('mergeDataObjectWithArray')->will($this->returnArgument(0));
     $this->customerGroupServiceMock->expects($this->once())->method('getGroup')->will($this->returnValue($customerGroupMock));
     $this->adminOrderCreate->setAccountData(array());
 }