@@ -311,7 +311,7 @@ public function testSeeResponseJsonMatchesXPathWorksWithAmpersand()
311311 $ this ->module ->seeResponseJsonMatchesXpath ('//comment ' );
312312 }
313313
314-
314+
315315 public function testSeeResponseJsonMatchesJsonPathFails ()
316316 {
317317 $ this ->shouldFail ();
@@ -322,8 +322,8 @@ public function testSeeResponseJsonMatchesJsonPathFails()
322322 $ this ->module ->seeResponseIsJson ();
323323 $ this ->module ->seeResponseJsonMatchesJsonPath ('$[*].profile ' );
324324 }
325-
326-
325+
326+
327327 public function testStructuredJsonPathAndXPath ()
328328 {
329329 $ this ->setStubResponse (
@@ -442,6 +442,63 @@ public function testAmDigestAuthenticatedThrowsExceptionWithFunctionalModules()
442442 $ this ->module ->amDigestAuthenticated ('username ' , 'password ' );
443443 }
444444
445+ /**
446+ * @param $configUrl
447+ * @param $requestUrl
448+ * @param $expectedFullUrl
449+ *
450+ * @dataProvider configAndRequestUrls
451+ */
452+ public function testRestExecute ($ configUrl , $ requestUrl , $ expectedFullUrl )
453+ {
454+ $ connectionModule = $ this ->createMock (
455+ \Codeception \Module \UniversalFramework::class
456+ );
457+ $ connectionModule
458+ ->expects ($ this ->once ())
459+ ->method ('_request ' )
460+ ->will (
461+ $ this ->returnCallback (function ($ method ,
462+ $ uri ,
463+ $ parameters ,
464+ $ files ,
465+ $ server ,
466+ $ content
467+ ) use ($ expectedFullUrl ) {
468+ \PHPUnit \Framework \Assert::assertEquals ($ expectedFullUrl , $ uri );
469+ })
470+ );
471+
472+ $ config = ['url ' => $ configUrl ];
473+
474+ /** @var \Codeception\Module\REST */
475+ $ module = Stub::make ('\Codeception\Module\REST ' );
476+ $ module ->_setConfig ($ config );
477+ $ module ->_inject ($ connectionModule );
478+ $ module ->_initialize ();
479+ $ module ->_before (Stub::makeEmpty ('\Codeception\Test\Test ' ));
480+
481+ $ module ->sendGET ($ requestUrl );
482+ }
483+
484+ public static function configAndRequestUrls ()
485+ {
486+ return [
487+ //$configUrl, $requestUrl, $expectedFullUrl
488+ ['v1/ ' , 'healthCheck ' , 'v1/healthCheck ' ],
489+ ['/v1 ' , '/healthCheck ' , '/v1/healthCheck ' ],
490+ ['v1 ' , 'healthCheck ' , 'v1/healthCheck ' ],
491+ ['http://v1/ ' , '/healthCheck ' , 'http://v1/healthCheck ' ],
492+ ['http://v1 ' , 'healthCheck ' , 'http://v1/healthCheck ' ],
493+ ['http://v1 ' , 'http://v2/healthCheck ' , 'http://v2/healthCheck ' ],
494+ ['http://v1 ' , '' , 'http://v1 ' ],
495+ ['http://v1 ' , '/ ' , 'http://v1/ ' ],
496+ ['' , 'http://v1 ' , 'http://v1 ' ],
497+ ['' , 'healthCheck ' , 'healthCheck ' ],
498+ ['/ ' , 'healthCheck ' , '/healthCheck ' ],
499+ ];
500+ }
501+
445502 protected function shouldFail ()
446503 {
447504 $ this ->expectException ('PHPUnit\Framework\AssertionFailedError ' );
0 commit comments