Your $app is not being initialized in your testing environment.
You can view an example about how initialize it in yii2-app-advanced > tests > codeception > frontend > unit > SignupForTest (<< see this). There you will see that each unit test is prepared to ‘bootstrap’ the $app through yii2-codeception > Testcase (<< and see this too).