/** * @covers sCategories::sGetCategories */ public function testGetCategoriesWithSubcategory() { $categoryTree = $this->module->sGetCategories(13); foreach ($categoryTree as $key => $category) { $this->assertArrayHasKey('id', $category); $this->assertEquals($key, $category['id']); $this->validateCategory($category, 'subcategories'); } }
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()); }
/** * @covers sCategories::sGetMainCategories */ public function testsGetMainCategories() { $this->assertEquals($this->module->sGetMainCategories(), $this->module->sGetCategories(Shopware()->Shop()->get('parentID'))); $this->assertNotEquals($this->module->sGetMainCategories(), $this->module->sGetCategories(5)); }