Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StatusTextTest.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
17  const STATUS_ID = 1;
18  const STATUS_TEXT = 'Enabled';
19 
23  protected $statusMock;
24 
25  protected function setUp()
26  {
27  parent::setUp();
28 
29  $this->statusMock = $this->getMockBuilder(Status::class)
30  ->setMethods(['getOptionText'])
31  ->disableOriginalConstructor()
32  ->getMock();
33  }
34 
38  protected function getModel()
39  {
40  return $this->objectManager->getObject(StatusText::class, [
41  'context' => $this->contextMock,
42  'uiComponentFactory' => $this->uiComponentFactoryMock,
43  'status' => $this->statusMock,
44  'components' => [],
45  'data' => [],
46  ]);
47  }
48 
49  public function testPrepareDataSource()
50  {
51  $dataSource = [
52  'data' => [
53  'items' => [
54  [
56  ]
57  ],
58  ],
59  ];
60  $expectedDataSource = [
61  'data' => [
62  'items' => [
63  [
65  '' => self::STATUS_TEXT,
66  ]
67  ],
68  ],
69  ];
70 
71  $this->statusMock->expects($this->once())
72  ->method('getOptionText')
73  ->with(self::STATUS_ID)
74  ->willReturn(self::STATUS_TEXT);
75 
76  $this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
77  }
78 }