function testIsRootSection() { $menu = new OA_Admin_Menu(); $sections = $this->generateSections(10, 0); $someOtherSections = $this->generateSections(2, 10); for ($i = 0; $i < count($sections); $i++) { $menu->add($sections[$i]); } //check null $nullSection = null; $this->assertFalse($menu->isRootSection($nullSection)); //check the id instead of the section itself $rootSection = $sections[0]->getId(); $this->assertFalse($menu->isRootSection($rootSection)); //check the root section for ($i = 0; $i < count($sections); $i++) { $this->assertTrue($menu->isRootSection($sections[$i])); } //check the non added root section for ($i = 0; $i < count($someOtherSections); $i++) { $this->assertFalse($menu->isRootSection($someOtherSections[$i])); } //ok, add other sections to menu as second level sections and check again for ($i = 0; $i < count($someOtherSections); $i++) { $menu->addTo($sections[$i]->getId(), $someOtherSections[$i]); } for ($i = 0; $i < count($someOtherSections); $i++) { $this->assertFalse($menu->isRootSection($someOtherSections[$i])); } }