Beispiel #1
0
 /**
  * @param Category $category
  * @param array $products
  * @param array $expectedNumbers
  * @param ConditionInterface[] $conditions
  * @param FacetInterface[] $facets
  * @param SortingInterface[] $sortings
  * @param null $context
  * @return ProductNumberSearchResult
  */
 protected function search($products, $expectedNumbers, $category = null, $conditions = array(), $facets = array(), $sortings = array(), $context = null)
 {
     if ($context === null) {
         $context = $this->getContext();
     }
     if ($category === null) {
         $category = $this->helper->createCategory();
     }
     $this->createProducts($products, $context, $category);
     $criteria = new Criteria();
     $this->addCategoryBaseCondition($criteria, $category, $conditions, $context);
     $this->addConditions($criteria, $conditions);
     $this->addFacets($criteria, $facets);
     $this->addSortings($criteria, $sortings);
     $criteria->offset(0)->limit(4000);
     $result = Shopware()->Container()->get('shopware_search.product_number_search')->search($criteria, $context);
     $this->assertSearchResult($result, $expectedNumbers);
     return $result;
 }
 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());
 }