Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
AttributeSetTextTest.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
17  const ATTRIBUTE_SET_ID = 4;
18  const ATTRIBUTE_SET_NAME = 'Default';
19 
24 
28  protected $attributeSetMock;
29 
30  protected function setUp()
31  {
32  parent::setUp();
33 
34  $this->attributeSetRepositoryMock = $this->getMockBuilder(AttributeSetRepositoryInterface::class)
35  ->setMethods(['get'])
36  ->getMockForAbstractClass();
37  $this->attributeSetMock = $this->getMockBuilder(AttributeSetInterface::class)
38  ->setMethods(['getAttributeSetName'])
39  ->getMockForAbstractClass();
40  }
41 
45  protected function getModel()
46  {
47  return $this->objectManager->getObject(AttributeSetText::class, [
48  'context' => $this->contextMock,
49  'uiComponentFactory' => $this->uiComponentFactoryMock,
50  'attributeSetRepository' => $this->attributeSetRepositoryMock,
51  'components' => [],
52  'data' => [],
53  ]);
54  }
55 
56  public function testPrepareDataSource()
57  {
58  $dataSource = [
59  'data' => [
60  'items' => [
61  [
63  ]
64  ],
65  ],
66  ];
67  $expectedDataSource = [
68  'data' => [
69  'items' => [
70  [
73  ]
74  ],
75  ],
76  ];
77 
78  $this->attributeSetMock->expects($this->once())
79  ->method('getAttributeSetName')
80  ->willReturn(self::ATTRIBUTE_SET_NAME);
81  $this->attributeSetRepositoryMock->expects($this->once())
82  ->method('get')
83  ->with(self::ATTRIBUTE_SET_ID)
84  ->willReturn($this->attributeSetMock);
85 
86  $this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
87  }
88 }