Skip to content

Commit 1f758ec

Browse files
committed
Added comments, refactoring
1 parent 7a0a79b commit 1f758ec

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Arachne/Codeception/Util/Connector/Nette.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ public function doRequest($request)
4141

4242
// Container initialization can't be called earlier because Nette\Http\IRequest service might be initialized too soon and amOnPage method would not work anymore.
4343
$this->container->initialize();
44+
45+
// Compatibility
4446
Environment::setContext($this->container);
4547

48+
// The HTTP code from previous test sometimes survives in http_response_code() so it's necessary to reset it manually.
49+
$httpResponse = $this->container->getByType('Nette\Http\IResponse');
50+
$httpResponse->setCode(IResponse::S200_OK);
51+
4652
ob_start();
4753
try {
48-
// The HTTP code from previous test sometimes survives in http_response_code() so it's necessary to reset it manually.
49-
// @link https://github.com/nette/nette/pull/1263
50-
$this->container->getByType('Nette\Http\IResponse')->setCode(IResponse::S200_OK);
5154
$this->container->getByType('Nette\Application\Application')->run();
5255
} catch (\Exception $e) {
5356
ob_end_clean();
@@ -56,12 +59,10 @@ public function doRequest($request)
5659
}
5760
$content = ob_get_clean();
5861

59-
$httpResponse = $this->container->getByType('Nette\Http\IResponse');
6062
$code = $httpResponse->getCode();
6163
$headers = $httpResponse->getHeaders();
6264

63-
$repsonse = new Response($content, $code, $headers);
64-
return $repsonse;
65+
return new Response($content, $code, $headers);
6566
}
6667

6768
}

src/Codeception/Module/Nette.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public function _beforeSuite($settings = array())
8282
public function _before(TestCase $test)
8383
{
8484
$class = $this->getContainerClass();
85+
// Cannot use $this->configurator->createContainer() directly beacuse it would call $container->initialize().
86+
// Container initialization is called laiter by NetteConnector.
8587
$this->container = new $class;
8688
$this->client = new NetteConnector();
8789
$this->client->setContainer($this->container);

0 commit comments

Comments
 (0)