1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Config\Test\Unit\Dom;
use \Magento\Framework\Config\Dom\NodePathMatcher;
class NodePathMatcherTest extends \PHPUnit\Framework\TestCase
{
/**
* @var NodePathMatcher
*/
protected $_model;
protected function setUp()
{
$this->_model = new NodePathMatcher();
}
/**
* @param string $pathPattern
* @param string $xpathSubject
* @param boolean $expectedResult
*
* @dataProvider getNodeInfoDataProvider
*/
public function testMatch($pathPattern, $xpathSubject, $expectedResult)
{
$actualResult = $this->_model->match($pathPattern, $xpathSubject);
$this->assertSame($expectedResult, $actualResult);
}
/**
* @return array
*/
public function getNodeInfoDataProvider()
{
return [
'no match' => ['/root/node', '/root', false],
'partial match' => ['/root/node', '/wrapper/root/node', false],
'exact match' => ['/root/node', '/root/node', true],
'regexp match' => ['/root/node/(sub-)+node', '/root/node/sub-node', true],
'match with namespace' => ['/root/node', '/mage:root/node', true],
'match with predicate' => ['/root/node', '/root/node[@name="test"]', true]
];
}
}