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

Public Member Functions

 testGetEntityAttributeCodes ()
 
 testGetAttributes ()
 
 testGetAttribute ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

@magentoAppIsolation enabled @magentoDbIsolation enabled @magentoDataFixture Magento/Eav/_files/attribute_for_search.php

Definition at line 17 of file ConfigTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 24 of file ConfigTest.php.

25  {
27  $this->config = $objectManager->get(Config::class);
28  }
$objectManager
Definition: bootstrap.php:17

◆ testGetAttribute()

testGetAttribute ( )

Definition at line 99 of file ConfigTest.php.

100  {
101  $entityType = 'test';
103  $attribute1 = $this->config->getAttribute($entityType, 'attribute_for_search_1');
104  $this->assertEquals('attribute_for_search_1', $attribute1->getAttributeCode());
105  $this->assertEquals('varchar', $attribute1->getBackendType());
106  $this->assertEquals(1, $attribute1->getIsRequired());
107  $this->assertEquals(1, $attribute1->getIsUserDefined());
108  $this->assertEquals(0, $attribute1->getIsUnique());
109  $attribute2 = $this->config->getAttribute($entityType, 'attribute_for_search_1');
110  $this->assertEquals($attribute1, $attribute2);
111  }

◆ testGetAttributes()

testGetAttributes ( )

Definition at line 77 of file ConfigTest.php.

78  {
79  $entityType = 'test';
81  $attributes1 = $this->config->getAttributes($entityType);
82  $expectedAttributeCodes = [
83  'attribute_for_search_1',
84  'attribute_for_search_2',
85  'attribute_for_search_3',
86  'attribute_for_search_4',
87  'attribute_for_search_5',
88  ];
89  $this->assertEquals(count($expectedAttributeCodes), count($attributes1));
90  $attributeCodes = [];
91  foreach ($attributes1 as $attribute) {
92  $attributeCodes[] = $attribute->getAttributeCode();
93  }
94  $this->assertEquals($expectedAttributeCodes, $attributeCodes);
95  $attributes2 = $this->config->getAttributes($entityType);
96  $this->assertEquals($attributes1, $attributes2);
97  }

◆ testGetEntityAttributeCodes()

testGetEntityAttributeCodes ( )

Definition at line 30 of file ConfigTest.php.

31  {
32  $entityType = 'test';
34  $entityAttributeCodes1 = $this->config->getEntityAttributeCodes($entityType);
35  $this->assertEquals(
36  [
37  'attribute_for_search_1',
38  'attribute_for_search_2',
39  'attribute_for_search_3',
40  'attribute_for_search_4',
41  'attribute_for_search_5',
42  ],
43  $entityAttributeCodes1
44  );
45 
46  $entityAttributeCodes2 = $this->config->getEntityAttributeCodes($entityType);
47  $this->assertEquals($entityAttributeCodes1, $entityAttributeCodes2);
48  }

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