/**
  * @covers sCategories::sGetCategoryPath
  */
 public function testsGetCategoryPath()
 {
     // Default arguments should work
     $this->assertEquals($this->module->sGetCategoryPath(21), $this->module->sGetCategoryPath(21, Shopware()->Shop()->get('parentID')));
     // Looking for elements in root gives full path
     $this->assertCount(2, $this->module->sGetCategoryPath(21, 3));
     // Looking for elements in wrong paths returns empty array
     $this->assertCount(0, $this->module->sGetCategoryPath(21, 39));
 }
 public function testPositionSorting()
 {
     $first = $this->helper->createCategory(array('name' => 'first', 'parent' => 3));
     $second = $this->helper->createCategory(array('name' => 'second', 'parent' => $first->getId(), 'position' => 1));
     $third = $this->helper->createCategory(array('name' => 'third', 'parent' => $first->getId(), 'position' => 2));
     $fourth = $this->helper->createCategory(array('name' => 'fourth', 'parent' => $first->getId(), 'position' => 2));
     $result = $this->module->sGetCategories($second->getId());
     $this->assertArrayHasKey($first->getId(), $result);
     $level1 = $this->assertAndGetSubCategories($result[$first->getId()], array($second->getId(), $third->getId(), $fourth->getId()));
     $level1 = array_values($level1);
     $this->assertEquals($level1[0]['id'], $second->getId());
     $this->assertEquals($level1[1]['id'], $third->getId());
     $this->assertEquals($level1[2]['id'], $fourth->getId());
 }
Example #3
0
 /**
  * Test the sGetWholeCategoryTree method.
  * This should now only return children when all parents are active
  * @ticket SW-5098
  */
 public function testGetWholeCategoryTree()
 {
     //set Category "Tees und Zubehör" to inactive so the childs should not be displayed
     $sql = "UPDATE `s_categories` SET `active` = '0' WHERE `id` =11";
     Shopware()->Db()->exec($sql);
     $allCategories = $this->module->sGetWholeCategoryTree(3, 3);
     //get "Genusswelten" this category should not have the inactive category "Tees and Zubehör" as subcategory
     $category = $this->getCategoryById($allCategories, 5);
     //search for Tees und Zubehör
     $result = $this->getCategoryById($category["sub"], 11);
     $this->assertEmpty($result);
     //if the parent category is inactive the child's should not be displayed
     //category = "Genusswelten" the active child "Tees" and "Tees und Zubehör" should not be return because the father ist inactive
     $result = $this->getCategoryById($category["sub"], 12);
     $this->assertEmpty($result);
     $result = $this->getCategoryById($category["sub"], 13);
     $this->assertEmpty($result);
     //set Category "Tees und Zubehör" to inactive so the childs should not be displayed
     $sql = "UPDATE `s_categories` SET `active` = '1' WHERE `id` = 11";
     Shopware()->Db()->exec($sql);
 }
Example #4
0
 /**
  * Returns a category path by category id.
  *
  * @param int $category
  * @param int $end
  * @return array
  */
 public function getCategoryPath($category, $end)
 {
     return $this->module->sGetCategoryPath($category, $end);
 }