/** * @param $number * @param ProductContext $context * @param Category $category * @return array */ protected function getProduct($number, ProductContext $context, Category $category = null) { $product = $this->helper->getSimpleProduct($number, array_shift($context->getTaxRules()), $context->getCurrentCustomerGroup()); if ($category) { $product['categories'] = array(array('id' => $category->getId())); } return $product; }
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()); }