99use Behat \Gherkin \Node \TableNode ;
1010use Example \Domain \Administration \Application \AdministrationService ;
1111use Example \Domain \Administration \Application \HireCandidateCommand ;
12+ use Example \Domain \Administration \Application \MenuService ;
13+ use Example \Domain \Administration \Application \RegisterNewMeal ;
14+ use Example \Domain \Administration \Application \ReleaseMeal ;
1215use Example \Domain \Common \DomainModel \FullName ;
1316use Example \Domain \Administration \DomainModel \Identity \OwnerId ;
1417use Example \Domain \Administration \DomainModel \Owner ;
1518use Example \Domain \Common \DomainModel \JobTitle ;
19+ use Example \Domain \Common \DomainModel \MealName ;
20+ use Example \Domain \Common \DomainModel \Money ;
1621use Example \Domain \Sale \Application \CashierService ;
22+ use Example \Domain \Sale \Application \OrderMeal ;
23+ use Example \Domain \Sale \Application \OrderService ;
1724use Example \Domain \Sale \Application \WaitressService ;
25+ use Example \Domain \Sale \DomainModel \CustomerName ;
26+ use Example \Domain \Sale \DomainModel \CustomerType ;
27+ use Example \Domain \Sale \DomainModel \Identity \EmployeeId ;
28+ use Example \Domain \Sale \DomainModel \Waitress ;
1829use Example \Domain \Shipping \Application \CreateDeliveryBoyHandler ;
1930use Example \Infrastructure \InMemory \EmployeeCollection ;
2031use Example \Infrastructure \InMemory \OwnerCollection ;
32+ use Example \Infrastructure \InMemory \Sale \MealCollection ;
2133use Example \Infrastructure \Symfony \SymfonyPublisher ;
2234use Example \Domain \Sale \Application \CookService ;
2335use PHPUnit_Framework_Assert as Assert ;
@@ -37,11 +49,33 @@ class ApplicationContext implements Context, SnippetAcceptingContext
3749 */
3850 private $ owners ;
3951
52+ /**
53+ * @var MealCollection
54+ */
55+ private $ meals ;
56+
4057 /**
4158 * @var AdministrationService
4259 */
4360 private $ administrationService ;
4461
62+ /**
63+ * @var MenuService
64+ */
65+ private $ menuService ;
66+
67+ /**
68+ * @var OrderService
69+ */
70+ private $ orderService ;
71+
72+ /**
73+ * The current waitress on post
74+ *
75+ * @var Waitress|null
76+ */
77+ private $ waitress ;
78+
4579 /**
4680 * Initializes context.
4781 *
@@ -52,16 +86,19 @@ class ApplicationContext implements Context, SnippetAcceptingContext
5286 public function __construct ()
5387 {
5488 $ publisher = new SymfonyPublisher ();
89+ $ this ->meals = new MealCollection ();
5590
5691 // Administration context
5792 $ this ->owners = new OwnerCollection ();
5893 $ this ->administrationService = new AdministrationService ($ this ->owners , $ publisher );
94+ $ this ->menuService = new MenuService ();
5995
6096 // Sale context
6197 $ this ->employees = new EmployeeCollection ();
6298 new CookService ($ this ->employees , $ publisher );
6399 new CashierService ($ this ->employees , $ publisher );
64100 new WaitressService ($ this ->employees , $ publisher );
101+ $ this ->orderService = new OrderService ();
65102
66103 // Shipping context
67104 new CreateDeliveryBoyHandler ($ this ->employees , $ publisher );
@@ -86,13 +123,81 @@ public function alreadyEmploysAs($ownerName, $employeeName, $role)
86123 ->hire (FullName::fromSingleString ($ employeeName ), JobTitle::fromString ($ role ));
87124 }
88125
126+ /**
127+ * @Given :owner has created the meal :mealName with price of :mealPrice each
128+ */
129+ public function hasCreatedTheMealWithPriceOfEach ($ owner , $ mealName , $ mealPrice )
130+ {
131+ $ this ->menuService ->registerMeal (
132+ new RegisterNewMeal (
133+ new OwnerId (FullName::fromSingleString ($ owner )),
134+ MealName::fromString ($ mealName ),
135+ Money::fromString ($ mealPrice )
136+ )
137+ );
138+ }
139+
140+ /**
141+ * @Given :owner has released the meal :mealName
142+ */
143+ public function hasReleasedTheMeal ($ owner , $ mealName )
144+ {
145+ $ this ->menuService ->releaseMeal (
146+ new ReleaseMeal (
147+ new OwnerId (FullName::fromSingleString ($ owner )),
148+ MealName::fromString ($ mealName )
149+ )
150+ );
151+ }
152+
89153 /**
90154 * @Given :applicantName postulate on a job offering
91155 */
92156 public function postulateOnAJobOffering ($ applicantName )
93157 {
94158 }
95159
160+ /**
161+ * @Given :waitressName is taking phone call orders
162+ */
163+ public function isTakingPhoneCallOrders ($ waitressName )
164+ {
165+ $ this ->waitress = $ this ->employees ->employeeWithIdentity (new EmployeeId ($ waitressName ));
166+ }
167+
168+ /**
169+ * @Given :customerName calls the shop to order the meal :mealName
170+ */
171+ public function callsTheShopToOrderTheMeal ($ customerName , $ mealName )
172+ {
173+ $ meal = $ this ->meals ->mealWithName (MealName::fromString ($ mealName ));
174+
175+ $ this ->orderService ->orderMeal (
176+ new OrderMeal (
177+ $ this ->waitress ->getIdentity (),
178+ CustomerType::PhoneCustomer (),
179+ $ meal ->getIdentity (),
180+ CustomerName::fromString ($ customerName )
181+ )
182+ );
183+ }
184+
185+ /**
186+ * @Given :customerName phone number is :phoneNumber
187+ */
188+ public function phoneNumberIs ($ customerName , $ phoneNumber )
189+ {
190+ throw new PendingException ();
191+ }
192+
193+ /**
194+ * @Given :customerName home address is :address
195+ */
196+ public function homeAddressIs ($ customerName , $ address )
197+ {
198+ throw new PendingException ();
199+ }
200+
96201 /**
97202 * @When :ownerName hires :applicantName as the new :role
98203 */
@@ -107,6 +212,38 @@ public function hiresAsTheNew($ownerName, $applicantName, $role)
107212 );
108213 }
109214
215+ /**
216+ * @When :waitressName confirms the order with id :orderId at :time
217+ */
218+ public function confirmsTheOrderWithIdAt ($ waitressName , $ orderId , $ time )
219+ {
220+ throw new PendingException ();
221+ }
222+
223+ /**
224+ * @When :cookName finishes to cook the order :orderId at :time
225+ */
226+ public function finishesToCookTheOrderAt ($ cookName , $ orderId , $ time )
227+ {
228+ throw new PendingException ();
229+ }
230+
231+ /**
232+ * @When :deliveryBoyName delivers the order :orderId at :time
233+ */
234+ public function deliversTheOrderAt ($ deliveryBoyName , $ orderId , $ time )
235+ {
236+ throw new PendingException ();
237+ }
238+
239+ /**
240+ * @When :customerName pays :price to :deliveryBoyName
241+ */
242+ public function paysTo ($ customerName , $ price , $ deliveryBoyName )
243+ {
244+ throw new PendingException ();
245+ }
246+
110247 /**
111248 * @Then :ownerName should have :employeeCount employees
112249 */
@@ -126,4 +263,36 @@ public function thereShouldBeEmployeesWithTitle($employeeCount, $role)
126263 (int ) $ employeeCount , $ this ->employees ->employeesWithTitle (JobTitle::fromString ($ role ))
127264 );
128265 }
266+
267+ /**
268+ * @Then Order :orderId should be closed at :time
269+ */
270+ public function orderShouldBeClosedAt ($ orderId , $ time )
271+ {
272+ throw new PendingException ();
273+ }
274+
275+ /**
276+ * @Then The order :orderId should have an income of :money
277+ */
278+ public function theOrderShouldHaveAnIncomeOf ($ orderId , $ money )
279+ {
280+ throw new PendingException ();
281+ }
282+
283+ /**
284+ * @Then The order :orderId should registers a tip of :money
285+ */
286+ public function theOrderShouldRegistersATipOf ($ orderId , $ money )
287+ {
288+ throw new PendingException ();
289+ }
290+
291+ /**
292+ * @Then The order :orderId should have taken :time to complete
293+ */
294+ public function theOrderShouldHaveTakenToComplete ($ orderId , $ time )
295+ {
296+ throw new PendingException ();
297+ }
129298}
0 commit comments