Ejemplo n.º 1
0
 public function setUp()
 {
     $this->objectManager = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->configEav = $this->getMockBuilder('Magento\\Eav\\Model\\Config')->disableOriginalConstructor()->setMethods(['getAttribute', 'getEntityAttributeCodes'])->getMock();
     $this->attrFormCollection = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Form\\Attribute\\Collection')->disableOriginalConstructor()->setMethods(['setStore', 'setEntityType', 'addFormCodeFilter', 'setSortOrder'])->getMock();
     $this->attrFormCollectionFactory = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Form\\Attribute\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->attrFormCollectionFactory->expects($this->any())->method('create')->will($this->returnValue($this->attrFormCollection));
     $this->storeManager = $this->getMockBuilder('Magento\\Store\\Model\\StoreManager')->disableOriginalConstructor()->setMethods(['getStore'])->getMock();
     $this->attributeMetadataProvider = $this->objectManager->getObject('Magento\\Customer\\Service\\V1\\Data\\Eav\\AttributeMetadataDataProvider', ['eavConfig' => $this->configEav, 'attrFormCollectionFactory' => $this->attrFormCollectionFactory, 'storeManager' => $this->storeManager]);
 }
 /**
  * Load collection with filters applied
  *
  * @param string $entityType
  * @param string $formCode
  * @return \Magento\Customer\Model\Resource\Form\Attribute\Collection
  */
 public function loadAttributesCollection($entityType, $formCode)
 {
     $attributesFormCollection = $this->attrFormCollectionFactory->create();
     $attributesFormCollection->setStore($this->storeManager->getStore())->setEntityType($entityType)->addFormCodeFilter($formCode)->setSortOrder();
     return $attributesFormCollection;
 }