public function provideGetAncestorData() { $root = new Item(); $level1 = new Item(); $level1->setParent($root); $level2 = new Item(); $level2->setParent($level1); return array(array($root, 0, $root), array($root, 1, null), array($root, -1, null), array($level1, 0, $root), array($level1, -1, $root), array($level1, '-1', $root), array($level1, '-9', null), array($level1, 9, null), array($level2, 1, $level1), array($level2, '2', $level2), array($level2, '0', $root), array($level2, 'foo', null)); }
public function testIterator() { $root = new Item(); $level1 = new Item(); $level1->setParent($root); $iterator = new BreadcrumbIterator($level1); $this->assertSame(0, $iterator->key()); $this->assertNull($iterator->rewind()); $this->assertTrue($iterator->valid()); $this->assertSame($level1, $iterator->current()); $this->assertSame(0, $iterator->key()); $this->assertNull($iterator->next()); $this->assertTrue($iterator->valid()); $this->assertSame($root, $iterator->current()); $this->assertSame(1, $iterator->key()); $iterator->next(); $this->assertFalse($iterator->valid()); $this->assertNull($iterator->current()); $this->assertNull($iterator->key()); }