Esempio n. 1
0
 /**
  * @param int $numLines
  * @param int $expectedNumLines
  * @dataProvider providerGetStreetLines
  */
 public function testGetStreetLines($numLines, $expectedNumLines)
 {
     $attributeMock = $this->getMockBuilder('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadata')->disableOriginalConstructor()->getMock();
     $attributeMock->expects($this->any())->method('getMultilineCount')->will($this->returnValue($numLines));
     $this->addressMetadataService->expects($this->any())->method('getAttributeMetadata')->will($this->returnValue($attributeMock));
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
     $this->assertEquals($expectedNumLines, $this->helper->getStreetLines());
 }
Esempio n. 2
0
 /**
  * Retrieve field configuration for street address attribute
  *
  * @param string $attributeCode
  * @param array $attributeConfig
  * @param string $providerName name of the storage container used by UI component
  * @param string $dataScopePrefix
  * @return array
  */
 protected function getStreetFieldConfig($attributeCode, array $attributeConfig, $providerName, $dataScopePrefix)
 {
     $streetLines = [];
     for ($lineIndex = 0; $lineIndex < $this->addressHelper->getStreetLines(); $lineIndex++) {
         $isFirstLine = $lineIndex === 0;
         $streetLines[] = ['component' => 'Magento_Ui/js/form/element/abstract', 'config' => ['customScope' => $dataScopePrefix, 'template' => 'ui/form/field', 'elementTmpl' => 'ui/form/element/input'], 'dataScope' => $lineIndex, 'provider' => $providerName, 'validation' => $isFirstLine ? ['required-entry' => true] : [], 'additionalClasses' => $isFirstLine ?: 'additional'];
     }
     return ['component' => 'Magento_Ui/js/form/components/group', 'label' => __('Address'), 'required' => true, 'dataScope' => $dataScopePrefix . '.' . $attributeCode, 'provider' => $providerName, 'sortOrder' => $attributeConfig['sortOrder'], 'type' => 'group', 'config' => ['template' => 'ui/group/group', 'additionalClasses' => 'street'], 'children' => $streetLines];
 }