public function tearDown() { if (self::$endOfClass) { $this->closeWindow(); self::$endOfClass = false; } }
function test_move() { /** * Add blog and about and contact nodes and test move(). * * Structure: * * index * - about * - blog * - contact */ self::$about_node = (object) array('data' => 'About', 'attr' => (object) array('id' => 'about', 'sort' => 0)); self::$contact_node = (object) array('data' => 'Contact', 'attr' => (object) array('id' => 'contact', 'sort' => 0)); self::$blog_node = (object) array('data' => 'Blog', 'attr' => (object) array('id' => 'blog', 'sort' => 0)); self::$n->add(self::$about_node, 'index'); self::$n->add(self::$contact_node, 'index'); self::$n->add(self::$blog_node, 'about'); $this->assertEquals(self::$n->get_all_ids(), array('index', 'about', 'blog', 'contact')); /** * Move contact under about. New structure: * * index * - about * - blog * - contact */ self::$n->move('contact', 'about'); $this->assertEquals(self::$n->parent('contact')->attr->id, 'about'); /** * Move contact under blog. New structure: * * index * - about * - blog * - contact */ self::$n->move('contact', 'blog'); $this->assertEquals(self::$n->parent('contact')->attr->id, 'blog'); $this->assertEquals(self::$n->parent('blog')->attr->id, 'about'); $this->assertEquals(self::$n->parent('about')->attr->id, 'index'); /** * Move blog to top. New structure: * * index * - about * blog * - contact */ self::$n->move('blog', false); $this->assertEquals(self::$n->parent('contact')->attr->id, 'blog'); $this->assertEquals(self::$n->parent('blog'), null); /** * Move blog to after about under index. New structure: * * index * - about * - blog * - contact */ self::$n->move('blog', 'about', 'after'); $this->assertEquals(self::$n->parent('blog')->attr->id, 'index'); $this->assertEquals(self::$n->parent('contact')->attr->id, 'blog'); $this->assertEquals(self::$n->node('about')->attr->sort, 0); $this->assertEquals(self::$n->node('blog')->attr->sort, 1); /** * Move blog to after about under index. New structure: * * index * - about * - contact * - blog */ self::$n->move('contact', 'blog', 'before'); $this->assertEquals(self::$n->parent('contact')->attr->id, 'index'); $this->assertEquals(self::$n->node('about')->attr->sort, 0); $this->assertEquals(self::$n->node('contact')->attr->sort, 1); $this->assertEquals(self::$n->node('blog')->attr->sort, 2); /** * Move blog to before index. New structure: * * blog * index * - about * - contact */ self::$n->move('blog', 'index', 'before'); $this->assertEquals(self::$n->parent('blog'), null); $this->assertEquals(self::$n->node('blog')->attr->sort, 0); $this->assertEquals(self::$n->node('index')->attr->sort, 1); /** * Move blog to after index. New structure: * * index * - about * - contact * blog */ self::$n->move('blog', 'index', 'after'); $this->assertEquals(self::$n->parent('blog'), null); $this->assertEquals(self::$n->node('index')->attr->sort, 0); $this->assertEquals(self::$n->node('blog')->attr->sort, 1); /** * Move index to after blog. New structure: * * blog * index * - about * - contact */ self::$n->move('index', 'blog', 'after'); $this->assertEquals(self::$n->parent('blog'), null); $this->assertEquals(self::$n->node('blog')->attr->sort, 0); $this->assertEquals(self::$n->node('index')->attr->sort, 1); $this->assertEquals(count(self::$n->node('index')->children), 2); /** * Move index to before blog. New structure: * * index * - about * - contact * blog */ self::$n->move('index', 'blog', 'before'); $this->assertEquals(self::$n->parent('blog'), null); $this->assertEquals(self::$n->node('index')->attr->sort, 0); $this->assertEquals(self::$n->node('blog')->attr->sort, 1); $this->assertEquals(count(self::$n->node('index')->children), 2); }
public function setUp() { parent::setUp(); self::$_menus = Navigation::items(); }