Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ModularSwitchTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\View\Design\Fallback\Rule\ModularSwitch;
9 
10 class ModularSwitchTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $object;
16 
20  protected $ruleNonModular;
21 
25  protected $ruleModular;
26 
27  protected function setUp()
28  {
29  $this->ruleNonModular = $this->getMockForAbstractClass(
30  \Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class
31  );
32  $this->ruleModular = $this->getMockForAbstractClass(
33  \Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class
34  );
35  $this->object = new ModularSwitch($this->ruleNonModular, $this->ruleModular);
36  }
37 
38  protected function tearDown()
39  {
40  $this->object = null;
41  $this->ruleNonModular = null;
42  $this->ruleModular = null;
43  }
44 
45  public function testGetPatternDirsNonModular()
46  {
47  $inputParams = ['param_one' => 'value_one', 'param_two' => 'value_two'];
48  $expectedResult = new \stdClass();
49  $this->ruleNonModular->expects(
50  $this->once()
51  )->method(
52  'getPatternDirs'
53  )->with(
54  $inputParams
55  )->will(
56  $this->returnValue($expectedResult)
57  );
58 
59  $this->ruleModular->expects($this->never())->method('getPatternDirs');
60 
61  $this->assertSame($expectedResult, $this->object->getPatternDirs($inputParams));
62  }
63 
64  public function testGetPatternDirsModular()
65  {
66  $inputParams = ['param' => 'value', 'module_name' => 'Magento_Core'];
67  $expectedResult = new \stdClass();
68  $this->ruleNonModular->expects($this->never())->method('getPatternDirs');
69 
70  $this->ruleModular->expects(
71  $this->once()
72  )->method(
73  'getPatternDirs'
74  )->with(
75  $inputParams
76  )->will(
77  $this->returnValue($expectedResult)
78  );
79 
80  $this->assertSame($expectedResult, $this->object->getPatternDirs($inputParams));
81  }
82 }