This repository was archived by the owner on Jul 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +364
-23
lines changed
Expand file tree Collapse file tree 5 files changed +364
-23
lines changed Original file line number Diff line number Diff line change 77 " mock" ,
88 " mock external services"
99 ],
10- "authors" : [{
11- "name" : " Mariano Custiel" ,
12- "email" : " jmcustiel@gmail.com" ,
13- "homepage" : " https://github.com/mcustiel" ,
14- "role" : " Developer"
15- }
16- ],
10+ "authors" : [{
11+ "name" : " Mariano Custiel" ,
12+ "email" : " jmcustiel@gmail.com" ,
13+ "homepage" : " https://github.com/mcustiel" ,
14+ "role" : " Developer"
15+ }
16+ ],
1717 "autoload" : {
1818 "psr-4" : {
1919 "Codeception\\ " : " src"
2626 "require" : {
2727 "php" : " >=5.4" ,
2828 "codeception/codeception" : " ~2.1.0" ,
29- "wiremock-php/wiremock-php" : " >=1.43"
29+ "wiremock-php/wiremock-php" : " >=1.43" ,
30+ "mcustiel/php-simple-di" : " >=1.2.0"
3031 },
3132 "require-dev" : {
3233 "phing/phing" : " >=2.12.0" ,
Original file line number Diff line number Diff line change 1919
2020use Codeception \Platform \Extension as CodeceptionExtension ;
2121use WireMock \Client \WireMock as WireMockClient ;
22+ use Mcustiel \DependencyInjection \DependencyContainer ;
2223
2324/**
2425 * Codeception Extension for WireMock
@@ -78,7 +79,12 @@ public function __construct(
7879 $ host = 'localhost ' ;
7980 sleep ($ this ->config ['start-delay ' ]);
8081 }
81- WireMockConnection::setConnection (WireMockClient::create ($ host , $ this ->config ['port ' ]));
82+ DependencyContainer::getInstance ()->add (
83+ 'wiremockConnection ' ,
84+ function () use ($ host ) {
85+ return WireMockClient::create ($ host , $ this ->config ['port ' ]);
86+ }
87+ );
8288 }
8389
8490 private function initWireMockProcess ($ process )
@@ -113,8 +119,9 @@ private function initWireMockArgumentsManager($argumentsManager)
113119 */
114120 public function __destruct ()
115121 {
116- if (WireMockConnection::get ()->isAlive ()) {
117- WireMockConnection::get ()->shutdownServer ();
122+ $ connection = DependencyContainer::getInstance ()->get ('wiremockConnection ' );
123+ if ($ connection ->isAlive ()) {
124+ $ connection ->shutdownServer ();
118125 }
119126 $ this ->process ->stop ();
120127 }
Original file line number Diff line number Diff line change 2222use Codeception \Extension \WireMockConnection ;
2323use WireMock \Client \MappingBuilder ;
2424use WireMock \Client \RequestPatternBuilder ;
25+ use Mcustiel \DependencyInjection \DependencyContainer ;
2526
2627class WireMock extends CodeceptionModule
2728{
@@ -37,7 +38,7 @@ class WireMock extends CodeceptionModule
3738 public function _before (TestCase $ testCase )
3839 {
3940 parent ::_before ($ testCase );
40- $ this ->wireMock = WireMockConnection:: get ();
41+ $ this ->wireMock = DependencyContainer:: getInstance ()-> get (' wiremockConnection ' );
4142 }
4243
4344 public function cleanAllPreviousRequestsToWireMock ()
You can’t perform that action at this time.
0 commit comments