When I am running the unit test case in yii2 advanced php framework from frontend\tests\unit\models\ContactFormTest.php I am getting some errors as below
This is my ContactFormTest.php
namespace frontend\tests\unit\models;
use Yii;
use frontend\models\ContactForm;
class ContactFormTest extends \Codeception\Test\Unit
{
public function testSendEmail()
{
$model = new ContactForm();
$model->attributes = [
'name' => 'vinayak',
'email' => '[email protected]',
'subject' => 'very important letter subject',
'body' => 'hi',
];
expect_that($model->sendEmail('[email protected]'));
// using Yii2 module actions to check email was sent
$this->tester->seeEmailIsSent();
$emailMessage = $this->tester->grabLastSentEmail();
expect('valid email is sent', $emailMessage)->isInstanceOf('yii\mail\MessageInterface');
expect($emailMessage->getTo())->hasKey('[email protected]');
expect($emailMessage->getFrom())->hasKey('[email protected]');
expect($emailMessage->getSubject())->equals('very important letter subject');
expect($emailMessage->toString())->contains('body of current message');
}
}
First Error
[yii\base\InvalidConfigException] The "id" configuration for the Application is required.
1 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\base\Application.php:220
2 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\base\Application.php:202
3 yii\base\Application->__construct
4 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\di\Container.php:383
5 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\di\Container.php:156
6 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\BaseYii.php:349
7 Codeception\Subscriber\Module->before
8 C:\xampp\htdocs\yii2_test\vendor\symfony\event-dispatcher\EventDispatcher.php:212
9 C:\xampp\htdocs\yii2_test\vendor\symfony\event-dispatcher\EventDispatcher.php:44
Second Error
[yii\base\InvalidConfigException] Unknown component ID: i18n
1 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\di\ServiceLocator.php:139
2 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\base\Module.php:742
3 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\base\Application.php:580
4 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\BaseYii.php:526
5 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\validators\RequiredValidator.php:60
6 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\base\BaseObject.php:109
7 yii\base\BaseObject->__construct
8 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\di\Container.php:383
9 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\di\Container.php:156
10 C:\xampp\htdocs\yii2_test\vendor\yiisoft\yii2\BaseYii.php:349
ERRORS! Tests: 1, Assertions: 0, Errors: 2.
Can any one please help me out on this thanks in advance