@@ -31,10 +31,17 @@ protected function validateConfig()
31
31
Validators::assertField ($ this ->config , 'robotLoader ' , 'array ' );
32
32
}
33
33
34
- public function _initialize ( )
34
+ public function _beforeSuite ( $ settings = array () )
35
35
{
36
+ parent ::_beforeSuite ($ settings );
37
+
36
38
self ::purge ($ this ->config ['tempDir ' ]);
37
39
$ configurator = new \Nette \Config \Configurator ();
40
+ $ configurator ->addParameters (array (
41
+ 'container ' => array (
42
+ 'class ' => ucfirst ($ this ->detectSuiteName ($ settings )) . 'SuiteContainer ' ,
43
+ ),
44
+ ));
38
45
$ configurator ->setTempDirectory ($ this ->config ['tempDir ' ]);
39
46
foreach ($ this ->config ['configFiles ' ] as $ file ) {
40
47
$ configurator ->addConfig ($ file );
@@ -60,6 +67,19 @@ public function grabService($service)
60
67
}
61
68
}
62
69
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
+
63
83
/**
64
84
* Purges directory.
65
85
* @param string $dir
0 commit comments