Skip to content

Commit 638a959

Browse files
committed
Defered container initialization to fix the amOnPage method
1 parent d38cab9 commit 638a959

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Codeception/Module/Nette.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Nette\DI\Container;
1010
use Nette\DI\MissingServiceException;
1111
use Nette\Diagnostics\Debugger;
12-
use Nette\Environment;
1312
use Nette\InvalidStateException;
1413
use Nette\Loaders\RobotLoader;
1514
use Nette\Utils\Validators;
@@ -85,6 +84,10 @@ public function _beforeSuite($settings = array())
8584
$this->robotLoader->addDirectory($dir);
8685
}
8786
$this->robotLoader->register();
87+
88+
// Generates and loads the container class.
89+
// The actual container is created later.
90+
$this->configurator->createContainer();
8891
}
8992

9093
public function _afterSuite()
@@ -95,13 +98,7 @@ public function _afterSuite()
9598
public function _before(TestCase $test)
9699
{
97100
$class = $this->getContainerClass();
98-
if (!class_exists($class, FALSE)) {
99-
$this->container = $this->configurator->createContainer();
100-
} else {
101-
$this->container = new $class;
102-
$this->container->initialize();
103-
Environment::setContext($this->container);
104-
}
101+
$this->container = new $class;
105102
$this->client = new NetteConnector();
106103
$this->client->setContainer($this->container);
107104
parent::_before($test);

src/Codeception/Util/Connector/Nette.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Nette\DI\Container;
66
use Nette\Diagnostics\Debugger;
7+
use Nette\Environment;
78
use Symfony\Component\BrowserKit\Client;
89
use Symfony\Component\BrowserKit\Request;
910
use Symfony\Component\BrowserKit\Response;
@@ -37,6 +38,9 @@ public function doRequest($request)
3738
$_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod());
3839
$_SERVER['REQUEST_URI'] = $uri;
3940

41+
$this->container->initialize();
42+
Environment::setContext($this->container);
43+
4044
ob_start();
4145
try {
4246
$this->container->getByType('Nette\Application\Application')->run();

0 commit comments

Comments
 (0)