public function test_removing_recipe_from_storage() { $recipe = new Recipe(new Name("Screwdriver")); $this->storage->save($recipe); $this->storage->remove($recipe); $fileName = DIRECTORY_SEPARATOR . 'screwdriver'; $this->assertFileNotExists(MY_DRINKS_VAR_DIR . '/tmp/' . $fileName, $this->serializer->serialize($recipe)); }
/** * @param string $slug * @return Recipe * @throws RecipeNotFoundException */ public function fetchBySlug($slug) { if (!$this->filesystem->has($this->generateFileNameFromSlug($slug))) { throw new RecipeNotFoundException(sprintf("Recipe with slug \"%s\" does not exists", $slug)); } $json = $this->filesystem->read($this->generateFileNameFromSlug($slug)); return $this->serializer->deserialize($json, Recipe::class); }