1111namespace Arachne \Codeception \Module ;
1212
1313use Arachne \Codeception \Connector \Nette as NetteConnector ;
14- use Arachne \Codeception \Module \Container as ContainerModule ;
1514use Codeception \Lib \Framework ;
1615use Codeception \TestInterface ;
17- use Nette \DI \ Container ;
18- use Nette \DI \ MissingServiceException ;
16+ use Nette \Http \ IRequest ;
17+ use Nette \Http \ IResponse ;
1918
2019/**
2120 * @author Jáchym Toušek <[email protected] > @@ -26,21 +25,6 @@ class Nette extends Framework
2625 'followRedirects ' => true ,
2726 ];
2827
29- /**
30- * @var array
31- */
32- private $ configFiles ;
33-
34- /**
35- * @var Container
36- */
37- private $ container ;
38-
39- /**
40- * @var callable
41- */
42- private $ containerAccessor ;
43-
4428 /**
4529 * @var string
4630 */
@@ -54,30 +38,15 @@ public function _beforeSuite($settings = [])
5438 public function _before (TestInterface $ test )
5539 {
5640 $ this ->configFiles = null ;
57- $ this ->container = null ;
58- $ this ->containerAccessor = function () {
59- if (!$ this ->container ) {
60- $ this ->container = $ this ->getModule (ContainerModule::class)->createContainer ();
61- }
62-
63- return $ this ->container ;
64- };
65-
6641 $ this ->client = new NetteConnector ();
67- $ this ->client ->setContainerAccessor ($ this ->containerAccessor );
42+ $ this ->client ->setContainerAccessor (function () {
43+ return $ this ->getModule (Container::class)->getContainer ();
44+ });
6845 $ this ->client ->followRedirects ($ this ->config ['followRedirects ' ]);
6946
7047 parent ::_before ($ test );
7148 }
7249
73- public function useConfigFiles (array $ configFiles )
74- {
75- if ($ this ->container ) {
76- $ this ->fail ('Can \'t set configFiles after the container is created. ' );
77- }
78- $ this ->configFiles = $ configFiles ;
79- }
80-
8150 public function _after (TestInterface $ test )
8251 {
8352 parent ::_after ($ test );
@@ -94,9 +63,8 @@ public function seeRedirectTo($url)
9463 if ($ this ->config ['followRedirects ' ]) {
9564 $ this ->fail ('Method seeRedirectTo only works when followRedirects option is disabled ' );
9665 }
97- $ container = call_user_func ($ this ->containerAccessor );
98- $ request = $ container ->getByType ('Nette\Http\IRequest ' );
99- $ response = $ container ->getByType ('Nette\Http\IResponse ' );
66+ $ request = $ this ->getModule (Container::class)->grabService (IRequest::class);
67+ $ response = $ this ->getModule (Container::class)->grabService (IResponse::class);
10068 if ($ response ->getHeader ('Location ' ) !== $ request ->getUrl ()->getHostUrl ().$ url && $ response ->getHeader ('Location ' ) !== $ url ) {
10169 $ this ->fail ('Couldn \'t confirm redirect target to be " ' .$ url .'", Location header contains " ' .$ response ->getHeader ('Location ' ).'". ' );
10270 }
0 commit comments