<?php
namespace tests\codeception\engine;
use engine\components\BaseException;
use engine\components\BaseService;
use engine\modules\account\models\AccUser;
use engine\modules\account\models\AccUserActivity;
use yii\db\Connection;
class AccountServiceTest extends \Codeception\TestCase\Test
{
protected $tester;
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testisEmailAvailalable()
{
$email = 'alk@gmail.com';
$dsn = 'mysql:host=localhost;dbname=rewards';
$username = 'root';
$password = 'password';
$connection = new \yii\db\Connection([
'dsn' => $dsn,
'username' => $username,
'password' => $password,
]);
/*$connection->open();*/
$command = $connection->createCommand('SELECT email FROM acc_user');
$emailIds = $command->query();
$emailIdArray = array($emailIds);
$this->assertContains('alk@gmail.com',$emailIdArray);
}}
while running it shows the error that There was 1 failure:
1) Testis email availalable (AccountServiceTest::testisEmailAvailalable)
Failed asserting that an array contains 'alk@gmail.com'.
#1 /var/www/html/rewards/shopsup-rewards-web/htdocs/tests/codeception/engine/unit/AccountServiceTest.php:44
#2 tests\codeception\engine\AccountServiceTest->testisEmailAvailalable
#3 /usr/local/bin/codecept:7
what I do is..I check the 'alk@gmail.com' is present in the email field in the acc_user table.If there is error means put the correct code
Aucun commentaire:
Enregistrer un commentaire