/**
  * @return Recipe
  */
 private function createRecipe()
 {
     $recipe = new Recipe(new Name("Screwdriver"));
     $recipe->prepareTheGlass(new Name("Highball"), new Capacity(350));
     $recipe->pourIntoGlass(new Name("Vodka"), new Capacity(150));
     return $recipe;
 }
 /**
  * @param Recipe $recipe
  */
 private function prepareGlassShakerAndLiquidForShaker(Recipe $recipe)
 {
     $recipe->prepareTheGlass(new Name("Highball"), new Recipe\Supply\Capacity(250));
     $recipe->prepareTheShaker(new Recipe\Supply\Capacity(250));
     $recipe->pourIntoShaker(new Name("Vodka"), new Recipe\Supply\Capacity(100));
     $recipe->shakeShakerContent();
     $recipe->strainIntoGlassFromShaker();
 }
Beispiel #3
0
 /**
  * @param DomainRecipe $recipe
  * @param array $data
  * @throws RuntimeException
  * @throws \MyDrinks\Domain\Exception\Recipe\GlassCapacityOverflowException
  * @throws \MyDrinks\Domain\Exception\Recipe\MissingGlassException
  */
 private function deserializeSteps(DomainRecipe $recipe, array $data)
 {
     foreach ($data['steps'] as $step) {
         switch ($step['type']) {
             case Actions::PREPARE_GLASS:
                 $recipe->prepareTheGlass(new Name($step['name']), new Capacity($step['capacity']), new Amount($step['amount']));
                 break;
             case Actions::POUR_INTO_GLASS:
                 $recipe->pourIntoGlass(new Name($step['name']), new Capacity($step['capacity']));
                 break;
             case Actions::STRAIN_INTO_GLASS_FROM_SHAKER:
                 $recipe->strainIntoGlassFromShaker();
                 break;
             case Actions::ADD_INGREDIENT_INTO_GLASS:
                 $recipe->addIngredientIntoGlass(new Name($step['name']), new Amount($step['amount']));
                 break;
             case Actions::STIR_GLASS_CONTENT:
                 $recipe->stirGlassContent();
                 break;
             case Actions::FILL_GLASS:
                 $recipe->fillGlassWith(new Name($step['name']));
                 break;
             case Actions::IGNITE_GLASS_CONTENT:
                 $recipe->igniteGlassContent();
                 break;
             case Actions::GARNISH_GLASS:
                 $recipe->garnishGlass(new Name($step['name']));
                 break;
             case Actions::EMPTY_GLASS_CONTENT:
                 $recipe->emptyTheGlass();
                 break;
             case Actions::MUDDLE_GLASS_CONTENT:
                 $recipe->muddleContent();
                 break;
             case Actions::TOP_UP_GLASS:
                 $recipe->topUpGlass(new Name($step['name']));
                 break;
             case Actions::PREPARE_SHAKER:
                 $recipe->prepareTheShaker(new Capacity($step['capacity']));
                 break;
             case Actions::POUR_INTO_SHAKER:
                 $recipe->pourIntoShaker(new Name($step['name']), new Capacity($step['capacity']));
                 break;
             case Actions::SHAKE_SHAKER_CONTENT:
                 $recipe->shakeShakerContent();
                 break;
             case Actions::FILL_SHAKER:
                 $recipe->fillShakerWith(new Name($step['name']));
                 break;
             case Actions::ADD_INGREDIENT_INTO_SHAKER:
                 $recipe->addIngredientIntoShaker(new Name($step['name']), new Amount($step['amount']));
                 break;
             default:
                 throw new RuntimeException(sprintf("Unknown step type \"%s\"", $step['type']));
         }
     }
 }
 function it_add_prepare_the_glass_step_to_recipe(Recipe $recipe)
 {
     $command = new AddRecipeStepCommand();
     $command->slug = 'screwdriver';
     $command->type = Actions::PREPARE_GLASS;
     $command->name = 'Highball';
     $command->capacity = 150;
     $command->amount = 1;
     $recipe->prepareTheGlass(Argument::type(Name::class), Argument::type(Capacity::class), Argument::type(Amount::class))->shouldBeCalled();
     $this->handle($command);
 }
 private function createRecipe($name)
 {
     $faker = Factory::create();
     $recipe = new Recipe(new Name($name));
     $description = new Description();
     $description->markAsIBAOfficial();
     $description->setText($faker->text(1000));
     $recipe->updateDescription($description);
     $recipe->prepareTheGlass(new Name("Highball"), new Recipe\Supply\Capacity(250));
     $recipe->addIngredientIntoGlass(new Name("Ice Cubes"), new Recipe\Supply\Amount(5));
     $recipe->pourIntoGlass(new Name("Vodka"), new Recipe\Supply\Capacity(50));
     $recipe->pourIntoGlass(new Name("Orange Juice"), new Recipe\Supply\Capacity(100));
     $recipe->garnishGlass(new Name("Orange Slice"), new Recipe\Supply\Amount(1));
     return $recipe;
 }
Beispiel #6
0
 public function test_recipe_with_top_up_step()
 {
     $serializer = new JsonSerializer();
     $recipe = new Recipe(new Name("Screwdriver"));
     $recipe->prepareTheGlass(new Name("Highball"), new Capacity(350));
     $recipe->topUpGlass(new Name("Vodka"));
     $json = json_encode(["name" => "Screwdriver", "publicationDate" => null, "steps" => [["type" => Actions::PREPARE_GLASS, "name" => "Highball", "capacity" => 350, "amount" => 1], ["type" => Actions::TOP_UP_GLASS, "name" => "Vodka"]], "glass" => "Highball", "description" => ["text" => null, "IBAOfficial" => false, "alcoholContent" => null, "taste" => []]]);
     $this->assertJsonStringEqualsJsonString($json, $serializer->serialize($recipe));
     $this->assertEquals($recipe, $serializer->deserialize($json, Recipe::class));
 }