/** * @dataProvider incorrectXPathsProvider * @expectedException \Siso\Bundle\ContentLoaderBundle\Tree\Exceptions\XPathMatcherException * @param string $xpath */ public function testIncorrectXPaths($xpath) { $data = ['a' => ['b' => 'b-value']]; $tree = new Tree($data); $node = $tree->getRoot()->getChildByName('a')->getChildByName('b'); $matcher = new XPathMatcher(); $this->assertTrue($matcher->matches($node, $xpath)); }
public function testTree() { $data = ['first' => 'firstValue', 'second' => ['second0' => ['second0-1' => 'secondO-1-value', 'second0-2' => 'secondO-2-value']], 'third' => 'thirdValue']; $tree = new Tree($data); $node = $tree->getRoot()->getChildByName('second')->getChildByName('second0'); $this->assertTrue($node->isPathMatched('/*/second0')); $this->assertTrue($node->isPathMatched('/second/*')); $this->assertTrue($node->isPathMatched('/*/*')); $this->assertFalse($node->isPathMatched('/first/*')); }
/** * @inheritdoc */ public function load($data, $parameters = []) { $tree = new Tree($data); $this->visitNodes($tree->getRoot()); }