@@ -33,4 +33,47 @@ public function tryToTest(AcceptanceTester $I)
3333 $ I ->didNotReceiveRequestsInRemoteService ();
3434 $ I ->seeRemoteServiceReceived (0 , A::getRequest ()->andUrl (Is::equalTo ('/some/url ' )));
3535 }
36+
37+ public function severalExceptatationsInOneTest (AcceptanceTester $ I )
38+ {
39+ $ I ->expectARequestToRemoteServiceWithAResponse (
40+ Phiremock::on (
41+ A::getRequest ()->andUrl (Is::equalTo ('/potato ' ))
42+ )->then (
43+ Respond::withStatusCode (203 )->andBody ('I am a potato ' )
44+ )
45+ );
46+ $ I ->expectARequestToRemoteServiceWithAResponse (
47+ Phiremock::on (
48+ A::getRequest ()->andUrl (Is::equalTo ('/tomato ' ))
49+ )->then (
50+ Respond::withStatusCode (203 )->andBody ('I am a tomato ' )
51+ )
52+ );
53+ $ I ->expectARequestToRemoteServiceWithAResponse (
54+ Phiremock::on (
55+ A::getRequest ()->andUrl (Is::equalTo ('/coconut ' ))
56+ )->then (
57+ Respond::withStatusCode (203 )->andBody ('I am a coconut ' )
58+ )
59+ );
60+ $ I ->expectARequestToRemoteServiceWithAResponse (
61+ Phiremock::on (
62+ A::getRequest ()->andUrl (Is::equalTo ('/banana ' ))
63+ )->then (
64+ Respond::withStatusCode (203 )->andBody ('I am a banana ' )
65+ )
66+ );
67+ foreach (['potato ' , 'tomato ' , 'banana ' , 'coconut ' ] as $ item ) {
68+ $ response = file_get_contents ('http://localhost:18080/ ' . $ item );
69+ $ I ->assertEquals ('I am a ' . $ item , $ response );
70+ }
71+ $ I ->seeRemoteServiceReceived (4 , A::getRequest ());
72+ $ I ->seeRemoteServiceReceived (1 , A::getRequest ()->andUrl (Is::equalTo ('/potato ' )));
73+ $ I ->seeRemoteServiceReceived (1 , A::getRequest ()->andUrl (Is::equalTo ('/tomato ' )));
74+ $ I ->seeRemoteServiceReceived (1 , A::getRequest ()->andUrl (Is::equalTo ('/banana ' )));
75+ $ I ->seeRemoteServiceReceived (1 , A::getRequest ()->andUrl (Is::equalTo ('/coconut ' )));
76+ $ I ->didNotReceiveRequestsInRemoteService ();
77+ $ I ->seeRemoteServiceReceived (0 , A::getRequest ());
78+ }
3679}
0 commit comments