/** * @param int $from * @param int $size * @return SearchResultSlice */ public function getDrinks($from = 0, $size = 20) { $criteria = new SearchEngine\Criteria($from); $criteria->changeSize($size); $criteria->updateRequiredTaste((new TasteBuilder())->sweet()->buildTaste()); return $this->searchEngine->search($criteria); }
/** * @param RemoveCommand $command */ public function handle(RemoveCommand $command) { $recipe = $command->getEntity(); if (!$recipe instanceof Recipe) { throw new \RuntimeException(sprintf("Entity \"%s\" can't be handled by Recipe\\NewCommandHandler", get_class($recipe))); } $this->storage->remove($recipe); $this->engine->removeRecipeFromIndex($recipe); }
function it_save_and_index_updated_recipes(Storage $storage, SearchEngine $searchEngine) { $recipe = new Recipe(new Name("Screwdriver")); $recipe->publish(); $command = new EditCommand($recipe, new ChangeSet()); $searchEngine->indexRecipe(Argument::any())->shouldBeCalled(); $storage->save(Argument::type(Recipe::class))->shouldBeCalled(); $this->handle($command); }