Skip to content

Commit 49fa139

Browse files
committed
Fixed support for multiple suites
1 parent e33ee84 commit 49fa139

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/Codeception/Module/Nette.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ protected function validateConfig()
3131
Validators::assertField($this->config, 'robotLoader', 'array');
3232
}
3333

34-
public function _initialize()
34+
public function _beforeSuite($settings = array())
3535
{
36+
parent::_beforeSuite($settings);
37+
3638
self::purge($this->config['tempDir']);
3739
$configurator = new \Nette\Config\Configurator();
40+
$configurator->addParameters(array(
41+
'container' => array(
42+
'class' => ucfirst($this->detectSuiteName($settings)) . 'SuiteContainer',
43+
),
44+
));
3845
$configurator->setTempDirectory($this->config['tempDir']);
3946
foreach ($this->config['configFiles'] as $file) {
4047
$configurator->addConfig($file);
@@ -60,6 +67,19 @@ public function grabService($service)
6067
}
6168
}
6269

70+
private function detectSuiteName($settings)
71+
{
72+
if (!isset($settings['path'])) {
73+
throw new \Nette\InvalidStateException('Could not detect suite name, path is not set.');
74+
}
75+
$directory = rtrim($settings['path'], DIRECTORY_SEPARATOR);
76+
$position = strrpos($directory, DIRECTORY_SEPARATOR);
77+
if ($position === FALSE) {
78+
throw new \Nette\InvalidStateException('Could not detect suite name, path is invalid.');
79+
}
80+
return substr($directory, $position + 1);
81+
}
82+
6383
/**
6484
* Purges directory.
6585
* @param string $dir

0 commit comments

Comments
 (0)