/** * @param CreateNewRecipeCommand $command * @throws RecipeAlreadyExistsException */ public function handle(CreateNewRecipeCommand $command) { $recipe = $this->recipeFactory->createRecipe($command->name); if ($this->recipes->hasRecipeWithName($recipe->getName())) { throw new RecipeAlreadyExistsException(); } $this->recipes->add($recipe); }
function let(Recipes $recipes, Factory $recipeFactory) { $recipeFactory->createRecipe("Screwdriver")->willReturn(new Recipe(new Name("Screwdriver"))); $this->beConstructedWith($recipes, $recipeFactory); }