Yii2 and Codeception: why doesn't the Stub component for the Request?

Hi all.

Write a functional test in Codeception want to do the substitution method getUserIP() the component's Request, to do this, create a Stub and register it in the application:

$requestStub = Stub::make(\yii\web\Request::class, ['getUserIP' => function () { return ''; }]);
\Yii::$app->set('request', $requestStub);

Run the test and get the error:
[yii\base\ErrorException] Undefined index: SCRIPT_FILENAME

Starting to look more in detail, the error appears in yii2\web\Request.php:
public function getScriptFile()
 return isset($this->_scriptFile) ? $this->_scriptFile : $_SERVER['SCRIPT_FILENAME'];

Write error_log inside this method and put in the log the contents of $_SERVER, start function test and see in the log that there is an index SCRIPT_FILENAME.

How can get this error if the index is?

Can anyone talivalza with this?
July 12th 19 at 17:17
1 answer
July 12th 19 at 17:19
and other functional tests are triggered? it seems to error when the wrong configuration, functional test

Find more questions by tags CodeceptionPHPYii