public function testRebuild() { $this->assertTrue(Category::isValidNestedSet()); $root = Category::root(); Category::query()->update(array('lft' => null, 'rgt' => null)); $this->assertFalse(Category::isValidNestedSet()); Category::rebuild(); $this->assertTrue(Category::isValidNestedSet()); $this->assertEquals($root, Category::root()); }
public function testRootStatic() { $this->assertEquals(Category::root(), $this->categories('Root 1')); }
public function testNodeIsSoftDeleted() { $root = Category::root(); $samsung = $this->findCategory('samsung'); $samsung->delete(); $this->assertTreeNotBroken(); $this->assertNull($this->findCategory('galaxy')); sleep(1); $node = $this->findCategory('mobile'); $node->delete(); $nodes = Category::whereIn('id', array(5, 6, 7, 8, 9))->count(); $this->assertEquals(0, $nodes); $originalRgt = $root->getRgt(); $root->refreshNode(); $this->assertEquals($originalRgt, $root->getRgt()); $node = $this->findCategory('mobile', true); $node->restore(); $this->assertNull($this->findCategory('samsung')); $this->assertNotNull($this->findCategory('nokia')); }