/** * @param RemoveRecipeCommand $command * @throws RecipeNotFoundException */ public function handle(RemoveRecipeCommand $command) { $recipe = $this->recipes->findBySlug($command->slug); if (is_null($recipe)) { throw new RecipeNotFoundException(sprintf("Recipe with slug \"%s\" does not exists.", $command->slug)); } $this->recipes->remove($recipe); }
public function it_remove_step_from_recipe(Recipes $recipes) { $recipe = $this->createRecipe(); $recipes->findBySlug("screwdriver")->willReturn($recipe); $recipes->remove($recipe)->shouldBeCalled(); $command = new RemoveRecipeCommand(); $command->slug = 'screwdriver'; $this->handle($command); }