Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
EavSetupTest Class Reference
Inheritance diagram for EavSetupTest:

Public Member Functions

 testAddAttribute ($attributeCode)
 
 addAttributeDataProvider ()
 
 testAddAttributeThrowException ($attributeCode)
 
 addAttributeThrowExceptionDataProvider ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

Test class for Magento\Eav\Setup\EavSetup. @magentoDbIsolation enabled

Definition at line 13 of file EavSetupTest.php.

Member Function Documentation

◆ addAttributeDataProvider()

addAttributeDataProvider ( )

Data provider for testAddAttributeThrowException().

Returns
array

Definition at line 54 of file EavSetupTest.php.

55  {
56  return [
57  ['eav_setup_test'],
58  ['_59_characters_59_characters_59_characters_59_characters_59'],
59  ];
60  }

◆ addAttributeThrowExceptionDataProvider()

addAttributeThrowExceptionDataProvider ( )

Data provider for testAddAttributeThrowException().

Returns
array

Definition at line 83 of file EavSetupTest.php.

84  {
85  return [
86  [null],
87  [''],
88  [' '],
89  ['more_than_60_characters_more_than_more_than_60_characters_more'],
90  ];
91  }

◆ setUp()

setUp ( )
protected

{}

Definition at line 25 of file EavSetupTest.php.

26  {
28  $this->eavSetup = $objectManager->create(\Magento\Eav\Setup\EavSetup::class);
29  }
$objectManager
Definition: bootstrap.php:17

◆ testAddAttribute()

testAddAttribute (   $attributeCode)

Verify that add attribute work correct attribute_code.

Parameters
string$attributeCode@dataProvider addAttributeDataProvider

Definition at line 38 of file EavSetupTest.php.

39  {
40  $attributeData = $this->getAttributeData();
41 
42  $this->eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, $attributeData);
43 
44  $attribute = $this->eavSetup->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode);
45 
46  $this->assertEmpty(array_diff($attributeData, $attribute));
47  }
$attributeCode
Definition: extend.phtml:12

◆ testAddAttributeThrowException()

testAddAttributeThrowException (   $attributeCode)

Verify that add attribute throw exception if attribute_code is not valid.

Parameters
string | null$attributeCode@dataProvider addAttributeThrowExceptionDataProvider @expectedException \Magento\Framework\Exception\LocalizedException @expectedExceptionMessage An attribute code must not be less than 1 and more than 60 characters.

Definition at line 71 of file EavSetupTest.php.

72  {
73  $attributeData = $this->getAttributeData();
74 
75  $this->eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode, $attributeData);
76  }
$attributeCode
Definition: extend.phtml:12

The documentation for this class was generated from the following file: