@@ -92,14 +92,14 @@ public function shouldCreateAnExpectationWithBinaryResponseTest(AcceptanceTester
9292 $ responseBody = file_get_contents ('http://localhost:18080/show-me-the-video ' );
9393 $ I ->assertEquals ($ responseContents , $ responseBody );
9494 }
95-
95+
9696 public function testGrabRequestsMadeToRemoteService (AcceptanceTester $ I )
9797 {
9898 $ requestBuilder = A::postRequest ()->andUrl (Is::equalTo ('/some/url ' ));
9999 $ I ->expectARequestToRemoteServiceWithAResponse (
100100 Phiremock::on ($ requestBuilder )->then (Respond::withStatusCode (200 ))
101101 );
102-
102+
103103 $ options = array (
104104 'http ' => array (
105105 'header ' => 'Content-Type: application/x-www-form-urlencoded ' ,
@@ -108,16 +108,23 @@ public function testGrabRequestsMadeToRemoteService(AcceptanceTester $I)
108108 )
109109 );
110110 file_get_contents ('http://localhost:18080/some/url ' , false , stream_context_create ($ options ));
111-
111+
112112 $ requests = $ I ->grabRequestsMadeToRemoteService ($ requestBuilder );
113113 $ I ->assertCount (1 , $ requests );
114-
114+
115115 $ first = reset ($ requests );
116116 $ I ->assertEquals ('POST ' , $ first ->method );
117117 $ I ->assertEquals ('a=b ' , $ first ->body );
118- $ I ->assertArraySubset ([
118+
119+ $ headers = (array ) $ first ->headers ;
120+ $ expectedSubset = [
119121 'Host ' => ['localhost:18080 ' ],
120122 'Content-Type ' => ['application/x-www-form-urlencoded ' ]
121- ], (array ) $ first ->headers );
123+ ];
124+
125+ foreach ($ expectedSubset as $ key => $ value ) {
126+ $ I ->assertArrayHasKey ($ key , $ headers );
127+ $ I ->assertSame ($ value , $ headers [$ key ]);
128+ }
122129 }
123130}
0 commit comments