2
2
3
3
namespace Arachne \Codeception \DI ;
4
4
5
- use Nette \Bridges \Framework \NetteExtension ;
6
5
use Nette \DI \CompilerExtension ;
7
6
use Nette \Http \IResponse ;
8
7
@@ -16,18 +15,21 @@ public function beforeCompile()
16
15
{
17
16
$ builder = $ this ->getContainerBuilder ();
18
17
19
- if ($ builder ->hasDefinition ('httpResponse ' )) {
20
- $ builder ->getDefinition ('httpResponse ' )
21
- ->setClass ('Arachne\Codeception\Http\Response ' )
22
- // The HTTP code from previous test sometimes survives in http_response_code() so it's necessary to reset it manually.
23
- ->addSetup ('setCode ' , [ IResponse::S200_OK ]);
24
- }
25
-
26
- if ($ builder ->hasDefinition ('httpRequest ' )) {
27
- $ builder ->getDefinition ('httpRequest ' )
18
+ $ request = $ builder ->getByType ('Nette\Http\IRequest ' ) ?: 'httpRequest ' ;
19
+ if ($ builder ->hasDefinition ($ request )) {
20
+ $ builder ->getDefinition ($ request )
28
21
// RequestFactory leaves port NULL in CLI mode but the urls created by amOnPage have port 80 which breaks canonicalization.
29
22
->addSetup ('$url = ?->getUrl(); if (!$url->getPort()) { $url->setPort(80); } ' , [ '@self ' ]);
30
23
}
24
+
25
+ $ response = $ builder ->getByType ('Nette\Http\IResponse ' ) ?: 'httpResponse ' ;
26
+ if ($ builder ->hasDefinition ($ response )) {
27
+ $ builder ->getDefinition ($ response )
28
+ ->setClass ('Nette\Http\IResponse ' )
29
+ ->setFactory ('Arachne\Codeception\Http\Response ' )
30
+ // The HTTP code from previous test sometimes survives in http_response_code() so it's necessary to reset it manually.
31
+ ->addSetup ('setCode ' , [ IResponse::S200_OK ]);
32
+ }
31
33
}
32
34
33
35
}
0 commit comments