Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RelativePathConverterTest.php
Go to the documentation of this file.
1 <?php
7 
8 class RelativePathConverterTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_sut;
14 
15  protected function setUp()
16  {
17  $this->_sut = new \Magento\Config\Model\Config\Structure\Mapper\Helper\RelativePathConverter();
18  }
19 
21  {
22  $nodePath = 'node/path';
23  $relativePath = '*/*/*/relativePath';
24 
25  $exceptionMessage = sprintf('Invalid relative path %s in %s node', $relativePath, $nodePath);
26 
27  $this->expectException('InvalidArgumentException');
28  $this->expectExceptionMessage($exceptionMessage);
29  $this->_sut->convert($nodePath, $relativePath);
30  }
31 
37  public function testConvertWithInvalidArguments($nodePath, $relativePath)
38  {
39  $this->expectException('InvalidArgumentException');
40  $this->expectExceptionMessage('Invalid arguments');
41  $this->_sut->convert($nodePath, $relativePath);
42  }
43 
50  public function testConvert($nodePath, $relativePath, $result)
51  {
52  $this->assertEquals($result, $this->_sut->convert($nodePath, $relativePath));
53  }
54 
59  {
60  return [['', ''], ['some/node', ''], ['', 'some/node']];
61  }
62 
66  public function convertDataProvider()
67  {
68  return [
69  ['currentNode', 'relativeNode', 'relativeNode'],
70  ['current/node/path', 'relative/node/path', 'relative/node/path'],
71  ['current/node', 'siblingRelativeNode', 'current/siblingRelativeNode'],
72  ['current/node', '*/siblingNode', 'current/siblingNode'],
73  ['very/deep/node/hierarchy', '*/*/sourceNode', 'very/deep/sourceNode']
74  ];
75  }
76 }
$relativePath
Definition: get.php:35