コード例 #1
0
 protected function setUp()
 {
     $this->_objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     /** @var CustomerMetadataService $customerMetadataService */
     $this->_customerMetadataService = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\CustomerMetadataService')->setMethods(array('getCustomAddressAttributeMetadata'))->disableOriginalConstructor()->getMock();
     $this->_customerMetadataService->expects($this->any())->method('getCustomAddressAttributeMetadata')->will($this->returnValue(array(new \Magento\Framework\Object(array('attribute_code' => 'warehouse_zip')), new \Magento\Framework\Object(array('attribute_code' => 'warehouse_alternate')))));
 }
コード例 #2
0
 protected function setUp()
 {
     $this->objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $regionBuilder = $this->objectManagerHelper->getObject('Magento\\Customer\\Service\\V1\\Data\\RegionBuilder');
     /** @var \Magento\Customer\Service\V1\CustomerMetadataService $customerMetadataService */
     $this->_customerMetadataService = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\AddressMetadataService')->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->_valueBuilder = $this->objectManagerHelper->getObject('Magento\\Framework\\Service\\Data\\AttributeValueBuilder');
     $this->_addressBuilder = $this->objectManagerHelper->getObject('Magento\\Customer\\Service\\V1\\Data\\AddressBuilder', ['valueBuilder' => $this->_valueBuilder, 'regionBuilder' => $regionBuilder, 'metadataService' => $this->_customerMetadataService]);
 }
コード例 #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);
     }
 }
コード例 #4
0
 public function testGetAllAttributeSetMetadataWithoutAttributeMetadata()
 {
     $this->_eavConfigMock->expects($this->any())->method('getAttribute')->will($this->returnValue(false));
     $this->_eavConfigMock->expects($this->any())->method('getEntityAttributeCodes')->will($this->returnValue(array('bogus')));
     $attributeColFactoryMock = $this->getMockBuilder('\\Magento\\Customer\\Model\\Resource\\Form\\Attribute\\CollectionFactory')->disableOriginalConstructor()->getMock();
     $storeManagerMock = $this->getMockBuilder('\\Magento\\Store\\Model\\StoreManager')->disableOriginalConstructor()->getMock();
     $optionBuilder = $this->objectManager->getObject('\\Magento\\Customer\\Service\\V1\\Data\\Eav\\OptionBuilder');
     $validationRuleBuilder = $this->objectManager->getObject('\\Magento\\Customer\\Service\\V1\\Data\\Eav\\ValidationRuleBuilder');
     $attributeMetadataBuilder = $this->objectManager->getObject('\\Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadataBuilder', ['optionBuilder' => $optionBuilder, 'validationRuleBuilder' => $validationRuleBuilder]);
     $service = new CustomerMetadataService($this->_eavConfigMock, $attributeColFactoryMock, $storeManagerMock, $optionBuilder, $validationRuleBuilder, $attributeMetadataBuilder);
     $this->assertEquals(array(), $service->getAllAttributeSetMetadata('entityType', 0, 1));
 }