Answer the question
In order to leave comments, you need to log in
Yii2 and Codeception: why is Stub not working for Request component?
Hello.
I am writing a functional test in Codeception, I want to replace the getUserIP () method of the Request component, for this I create a Stub and register it in the application:
$requestStub = Stub::make(\yii\web\Request::class, ['getUserIP' => function () { return '192.168.0.10'; }]);
\Yii::$app->set('request', $requestStub);
[yii\base\ErrorException] Undefined index: SCRIPT_FILENAME
public function getScriptFile()
{
return isset($this->_scriptFile) ? $this->_scriptFile : $_SERVER['SCRIPT_FILENAME'];
}
Answer the question
In order to leave comments, you need to log in
Do other functional tests work? this looks like a bug with a functional test misconfiguration
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question