Answer the question
In order to leave comments, you need to log in
How to test components in Yii2?
Good evening. Can you please tell me how to test components in Yii2? Indeed, when testing, the \Yii::$app property is not defined.
Are you using \Yii::$container->get() ?
Answer the question
In order to leave comments, you need to log in
Well, since no one answers..
See how it's done in https://github.com/yiisoft/yii2-codeception/blob/m...
Specifically, the mockApplication method. It allows you to create a new application instance with a given config (including components) before each test. It is strange that you did not use it, because it is included in the standard setup for tests in yii2-basic and yii2-advanced templates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question