D
D
Dmitry Baibukhtin2016-01-16 21:58:51
Yii
Dmitry Baibukhtin, 2016-01-16 21:58:51

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

1 answer(s)
M
matperez, 2016-01-17
@PiloTeZ

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 question

Ask a Question

731 491 924 answers to any question