Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ReservedAttributeListTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ReservedAttributeListTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $model;
16 
17  protected function setUp()
18  {
19  $this->model = new ReservedAttributeList(
20  \Magento\Catalog\Model\Product::class,
21  ['some_value'],
22  ['some_attribute']
23  );
24  }
25 
30  public function testIsReservedAttribute($isUserDefined, $attributeCode, $expected)
31  {
32  $attribute = $this->createPartialMock(
33  \Magento\Catalog\Model\Entity\Attribute::class,
34  ['getIsUserDefined', 'getAttributeCode', '__sleep', '__wakeup']
35  );
36 
37  $attribute->expects($this->once())->method('getIsUserDefined')->will($this->returnValue($isUserDefined));
38  $attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode));
39 
40  $this->assertEquals($expected, $this->model->isReservedAttribute($attribute));
41  }
42 
46  public function dataProvider()
47  {
48  return [
49  [false, 'some_code', false],
50  [true, 'some_value', true],
51  [true, 'name', true],
52  [true, 'price', true],
53  [true, 'category_id', true],
54  [true, 'some_code', false],
55  ];
56  }
57 }
$attributeCode
Definition: extend.phtml:12