@@ -20,14 +20,30 @@ public function __construct(InputDefinition $definition = NULL)
20
20
$ parameters = array ($ _SERVER ['argv ' ][0 ], 'run ' );
21
21
22
22
if (isset ($ _SERVER ['argv ' ][1 ])) {
23
- $ filename = str_replace ('\\' , '/ ' , $ _SERVER ['argv ' ][1 ]);
24
- $ cwd = str_replace ('\\' , '/ ' , getcwd ()) . '/ ' ;
25
- if (strpos ($ filename , $ cwd ) === 0 ) {
26
- $ parameters [] = substr ($ filename , strlen ($ cwd ));
23
+ $ filename = $ this ->normalizePath ($ _SERVER ['argv ' ][1 ]);
24
+ $ cwd = $ this ->normalizePath (getcwd ()) . '/ ' ;
25
+
26
+ // IDE always provides absolute path but Codeception only accepts relative path without leading "./".
27
+ // If path is not absolute, make it that way and call realpath to remove "./".
28
+ if (strpos ($ filename , $ cwd ) !== 0 && file_exists ($ cwd . $ filename )) {
29
+ $ filename = $ this ->normalizePath (realpath ($ cwd . $ filename ));
27
30
}
31
+
32
+ if (!file_exists ($ filename )) {
33
+ echo 'File " ' . $ filename . '" could not be found. ' ;
34
+ exit ;
35
+ }
36
+
37
+ // Cut of the absolute part for Codeception.
38
+ $ parameters [] = substr ($ filename , strlen ($ cwd ));
28
39
}
29
40
30
41
parent ::__construct ($ parameters , $ definition );
31
42
}
32
43
44
+ private function normalizePath ($ path )
45
+ {
46
+ return str_replace ('\\' , '/ ' , $ path );
47
+ }
48
+
33
49
}
0 commit comments