Skip to content

Commit 4443518

Browse files
SilverFireDavertMik
authored andcommitted
Respect absolute paths in Yii2 module (#4961)
* Respect absoulte paths in Yii2 module * Added codecept_absolute_path function * Added CHANGELOG * Use codecept_absolute_path() in ParamsLoader
1 parent 2f8d801 commit 4443518

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Codeception/Module/Yii2.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* modules:
5454
* enabled:
5555
* - Yii2:
56-
* configFile: '/path/to/config.php'
56+
* configFile: 'path/to/config.php'
5757
* ```
5858
*
5959
* ### Parts
@@ -238,10 +238,12 @@ private function initServerGlobal()
238238
protected function validateConfig()
239239
{
240240
parent::validateConfig();
241-
if (!is_file(Configuration::projectDir() . $this->config['configFile'])) {
241+
242+
$pathToConfig = codecept_absolute_path($this->config['configFile']);
243+
if (!is_file($pathToConfig)) {
242244
throw new ModuleConfigException(
243245
__CLASS__,
244-
"The application config file does not exist: " . Configuration::projectDir() . $this->config['configFile']
246+
"The application config file does not exist: " . $pathToConfig
245247
);
246248
}
247249

@@ -262,7 +264,7 @@ protected function validateConfig()
262264

263265
protected function configureClient(array $settings)
264266
{
265-
$settings['configFile'] = Configuration::projectDir() . $settings['configFile'];
267+
$settings['configFile'] = codecept_absolute_path($settings['configFile']);
266268

267269
foreach ($settings as $key => $value) {
268270
if (property_exists($this->client, $key)) {

0 commit comments

Comments
 (0)