Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TabAbstractTest.php
Go to the documentation of this file.
1 <?php
7 
8 class TabAbstractTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_model;
14 
15  protected function setUp()
16  {
17  $this->_model = $this->getMockForAbstractClass(
18  \Magento\Theme\Block\Adminhtml\System\Design\Theme\Edit\AbstractTab::class,
19  [
20  $this->createMock(\Magento\Backend\Block\Template\Context::class),
21  $this->createMock(\Magento\Framework\Registry::class),
22  $this->createMock(\Magento\Framework\Data\FormFactory::class),
23  $this->createMock(\Magento\Framework\ObjectManagerInterface::class),
24  ],
25  '',
26  true,
27  false,
28  true,
29  ['_getCurrentTheme', 'getTabLabel']
30  );
31  }
32 
33  protected function tearDown()
34  {
35  unset($this->_model);
36  }
37 
38  public function testGetTabTitle()
39  {
40  $label = 'test label';
41  $this->_model->expects($this->once())->method('getTabLabel')->will($this->returnValue($label));
42  $this->assertEquals($label, $this->_model->getTabTitle());
43  }
44 
51  public function testCanShowTab($isVirtual, $themeId, $result)
52  {
53  $themeMock = $this->createPartialMock(\Magento\Theme\Model\Theme::class, ['isVirtual', 'getId', '__wakeup']);
54  $themeMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual));
55 
56  $themeMock->expects($this->any())->method('getId')->will($this->returnValue($themeId));
57 
58  $this->_model->expects($this->any())->method('_getCurrentTheme')->will($this->returnValue($themeMock));
59 
60  if ($result === true) {
61  $this->assertTrue($this->_model->canShowTab());
62  } else {
63  $this->assertFalse($this->_model->canShowTab());
64  }
65  }
66 
70  public function canShowTabDataProvider()
71  {
72  return [[true, 1, true], [true, 0, false], [false, 1, false]];
73  }
74 
75  public function testIsHidden()
76  {
77  $this->assertFalse($this->_model->isHidden());
78  }
79 }
$label
Definition: details.phtml:21