/** * Generates the necessary category settings. * * @param \SKYFILLERS\SfSimpleFaq\Domain\Model\Dto\FaqDemand $demand A demand * * @return void */ protected function generateCategories(\SKYFILLERS\SfSimpleFaq\Domain\Model\Dto\FaqDemand $demand) { $categories = $demand->getCategories(); if (strlen($categories) > 1) { $categories = explode(',', $categories); } $this->categoriesLength = count($categories); if ($this->categoriesLength != 0) { for ($i = 0; $i < $this->categoriesLength; $i++) { array_push($this->categoryConstraints, $this->query->contains('category', (string) $categories[$i])); } } $this->categoryConstraintsLength = count($this->categoryConstraints); if ($categories[0] == 0 && $this->categoryConstraintsLength < 2) { $this->categoryIsAll = TRUE; } }
/** * Test * * @test * @return void */ public function setCategoriesForEmptyStringSetsCategories() { $this->subject->setCategories(''); $this->assertSame('', $this->subject->getCategories()); }