public function testReloadResetsChangesOnFreshNodes()
 {
     $new = new Category();
     $new->name = 'Some new category';
     $new->reload();
     $this->assertNull($new->name);
 }
Example #2
0
 public function testActiveProductCountWhenChangingCategoryAvailability()
 {
     $this->root->reload();
     $rootActiveProductCount = $this->root->activeProductCount->get();
     $rootAotalProductCount = $this->root->totalProductCount->get();
     $rootAvailableProductCount = $this->root->availableProductCount->get();
     $subCategory = Category::getNewInstance($this->root);
     $subCategory->setValueByLang("name", 'en', "New Category 1");
     $subCategory->isEnabled->set(false);
     $subCategory->activeProductCount->set(1);
     $subCategory->totalProductCount->set(1);
     $subCategory->availableProductCount->set(1);
     $subCategory->save();
     $this->root->reload();
     $this->assertEqual($rootActiveProductCount, $this->root->activeProductCount->get());
     $subCategory->isEnabled->set(true);
     $subCategory->save();
     $this->root->reload();
     $this->assertEqual($rootActiveProductCount + 1, $this->root->activeProductCount->get());
 }
 public function testNullifyParentColumnOnNewNodes()
 {
     $node = new Category(['name' => 'Root 3']);
     $node->parent_id = null;
     $node->save();
     $node->reload();
     $this->assertNull($node->parent()->first());
     $this->assertEquals(0, $node->getLevel());
     $this->assertEquals(13, $node->getLeft());
     $this->assertEquals(14, $node->getRight());
     $this->assertTrue(Category::isValidNestedSet());
 }