Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SpecialAttributeTest.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
17 class SpecialAttributeTest 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  SpecialAttribute::class
35  );
36  }
37 
44  public function testGetFieldName($attributeCode, $expected)
45  {
46  $attributeMock = $this->getMockBuilder(AttributeAdapter::class)
47  ->disableOriginalConstructor()
48  ->setMethods(['getAttributeCode'])
49  ->getMock();
50  $attributeMock->expects($this->any())
51  ->method('getAttributeCode')
52  ->willReturn($attributeCode);
53 
54  $this->assertEquals(
55  $expected,
56  $this->resolver->getFieldName($attributeMock)
57  );
58  }
59 
63  public function getFieldNameProvider()
64  {
65  return [
66  ['id', 'id'],
67  ['sku', 'sku'],
68  ['store_id', 'store_id'],
69  ['visibility', 'visibility'],
70  ['price', ''],
71  ];
72  }
73 }
$objectManager
Definition: bootstrap.php:17
$attributeCode
Definition: extend.phtml:12