/** * @covers Navinator\Collection::addNodeIfNotExists */ public function testAddIfNotExists() { $nodeData = array('alpha/beta/gamma/delta', 'alpha/beta', 'alpha', 'alpha/beta/gamma'); $nodes = array(); $c = new Collection(); foreach ($nodeData as $path) { $n = new Node($path); $nodes[$path] = $n; $c->addNodeIfNotExists($n); } $n = new Node('alpha/beta'); $c->addNodeIfNotExists($n); foreach ($nodeData as $path) { $this->assertSame($c->getNode($path), $nodes[$path]); } }