/** * Method to test setLocation(). * * @return void * * @covers Windwalker\Record\NestedRecord::setLocation */ public function testSetLocationAndStore() { $data = array('title' => 'Flower', 'alias' => 'flower'); $this->instance->bind($data)->setLocation(1, NestedRecord::POSITION_FIRST_CHILD)->store(); $data = array('title' => 'Sakura', 'alias' => 'sakura'); $this->instance->reset(true)->bind($data)->setLocation(2, NestedRecord::POSITION_FIRST_CHILD)->store(); // First child $data = array('title' => 'Olive', 'alias' => 'olive'); $this->instance->reset(true)->bind($data)->setLocation(2, NestedRecord::POSITION_FIRST_CHILD)->store(); $this->assertEquals(array(2, 3), array($this->instance->lft, $this->instance->rgt)); // Last child $data = array('title' => 'Sunflower', 'alias' => 'sunflower'); $this->instance->reset(true)->bind($data)->setLocation(2, NestedRecord::POSITION_LAST_CHILD)->store(); $this->assertEquals(array(6, 7), array($this->instance->lft, $this->instance->rgt)); // Before $data = array('title' => 'Rose', 'alias' => 'rose'); $this->instance->reset(true)->bind($data)->setLocation(2, NestedRecord::POSITION_BEFORE)->store(); $this->assertEquals(array(1, 2), array($this->instance->lft, $this->instance->rgt)); // After $data = array('title' => 'Rose', 'alias' => 'rose'); $this->instance->reset(true)->bind($data)->setLocation(2, NestedRecord::POSITION_AFTER)->store(); $this->assertEquals(array(11, 12), array($this->instance->lft, $this->instance->rgt)); }