Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NotEavAttributeTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
17 class NotEavAttributeTest extends \PHPUnit\Framework\TestCase
18 {
22  private $resolver;
23 
29  protected function setUp()
30  {
31  $objectManager = new ObjectManagerHelper($this);
32 
33  $this->resolver = $objectManager->getObject(
34  NotEavAttribute::class
35  );
36  }
37 
46  public function testGetFieldName($attributeCode, $isEavAttribute, $context, $expected)
47  {
48  $attributeMock = $this->getMockBuilder(AttributeAdapter::class)
49  ->disableOriginalConstructor()
50  ->setMethods(['isEavAttribute', 'getAttributeCode'])
51  ->getMock();
52  $attributeMock->expects($this->any())
53  ->method('isEavAttribute')
54  ->willReturn($isEavAttribute);
55  $attributeMock->expects($this->any())
56  ->method('getAttributeCode')
57  ->willReturn($attributeCode);
58 
59  $this->assertEquals(
60  $expected,
61  $this->resolver->getFieldName($attributeMock, $context)
62  );
63  }
64 
68  public function getFieldNameProvider()
69  {
70  return [
71  ['code', true, [], ''],
72  ['code', false, [], 'code'],
73  ];
74  }
75 }
$objectManager
Definition: bootstrap.php:17
$attributeCode
Definition: extend.phtml:12