function testActiveStatusPropagatedToParent() { $parent = new T_Url_Collection('diff', 'https', 'example.com'); $parent->addChild($this->url); $this->url->setActive(); $this->assertTrue($parent->isActive()); }
function testVisitUrlCompositeWithNestedChild() { $parent = new T_Url_Collection('parent', 'test', 'p.com'); $child1 = new T_Url_Collection('child1', 'test', 'c1.com'); $child2 = new T_Url_Leaf('child2', 'test', 'c2.com'); $parent->addChild($child1); $child1->addChild($child2); ob_start(); // execute visitor $parent->accept($this->visitor); $xhtml = ob_get_contents(); ob_end_clean(); $expected = EOL . '<a class="parent" href="test://p.com">parent</a>' . EOL . '<ul>' . EOL . $this->indent . '<li class="parent"><a class="parent" href="test://c1.com">child1</a>' . EOL . $this->indent . '<ul>' . EOL . str_repeat($this->indent, 2) . '<li><a href="test://c2.com">child2</a></li>' . EOL . $this->indent . '</ul>' . EOL . $this->indent . '</li>' . EOL . '</ul>'; $this->assertSame($xhtml, $expected); }
function testMultiActiveAtSingleLevelException() { $parent = new T_Url_Collection('parent', 'test', 'p.com'); $child1 = new T_Url_Leaf('child1', 'test', 'c1.com'); $child2 = new T_Url_Collection('child2', 'test', 'c2.com'); $child2->setActive(); $child1->setActive(); $parent->addChild($child1); $parent->addChild($child2); ob_start(); try { $parent->accept($this->visitor); $this->fail(); } catch (OutOfRangeException $e) { } ob_end_clean(); }
function testXmlRenderedToBuffer() { $sitemap = new T_Xhtml_UrlSitemap(); $url = new T_Url_Collection('root', 'test', 'p.com'); $url->setChangeFreq('always'); $url->accept($sitemap); ob_start(); $test = $sitemap->toBuffer(); $this->assertSame($sitemap, $test, 'fluent interface'); $content = ob_get_clean(); $this->assertSame($content, $sitemap->asXml()); }