Example #1
0
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     /** @var \Magento\Customer\Service\V1\CustomerMetadataService $customerMetadataService */
     $this->_customerMetadataService = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\CustomerMetadataService')->setMethods(array('getCustomAttributesMetadata'))->disableOriginalConstructor()->getMock();
     $this->_customerMetadataService->expects($this->any())->method('getCustomAttributesMetadata')->will($this->returnValue(array(new \Magento\Framework\Object(array('attribute_code' => 'warehouse_zip')), new \Magento\Framework\Object(array('attribute_code' => 'warehouse_alternate')))));
     $this->_addressMetadataService = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\AddressMetadataService')->setMethods(array('getCustomAttributesMetadata'))->disableOriginalConstructor()->getMock();
     $this->_addressMetadataService->expects($this->any())->method('getCustomAttributesMetadata')->will($this->returnValue(array(new \Magento\Framework\Object(array('attribute_code' => 'warehouse_zip')), new \Magento\Framework\Object(array('attribute_code' => 'warehouse_alternate')))));
     $this->_valueBuilder = $this->_objectManager->getObject('Magento\\Framework\\Service\\Data\\AttributeValueBuilder');
     $this->_customerBuilder = $this->_objectManager->getObject('Magento\\Customer\\Service\\V1\\Data\\CustomerBuilder', ['valueBuilder' => $this->_valueBuilder, 'metadataService' => $this->_customerMetadataService]);
     parent::setUp();
 }
Example #2
0
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->addressMetadataService = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\AddressMetadataService')->setMethods(array('getAttributeMetadata', 'getCustomAttributesMetadata'))->disableOriginalConstructor()->getMock();
     $customAttributeMetadata1 = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata')->disableOriginalConstructor()->getMock();
     $customAttributeMetadata1->expects($this->any())->method('getAttributeCode')->will($this->returnValue('warehouse_zip'));
     $customAttributeMetadata2 = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata')->disableOriginalConstructor()->getMock();
     $customAttributeMetadata2->expects($this->any())->method('getAttributeCode')->will($this->returnValue('warehouse_alternate'));
     $attributesMetadata = array($customAttributeMetadata1, $customAttributeMetadata2);
     $this->addressMetadataService->expects($this->any())->method('getAttributeMetadata')->will($this->returnValue($attributesMetadata));
     $this->addressMetadataService->expects($this->any())->method('getCustomAttributesMetadata')->will($this->returnValue($attributesMetadata));
 }
Example #3
0
 public function testGetCustomAttributesMetadata()
 {
     $value = 'v';
     $this->customerMetadataServiceMock->expects($this->once())->method('getCustomAttributesMetadata')->will($this->returnValue($value));
     for ($c = 0; $c < 10; $c++) {
         $actualValue = $this->cachedMetadataService->getCustomAttributesMetadata();
         $this->assertEquals($value, $actualValue);
     }
 }