public function _after(FunctionalTester $I) { User::deleteAll('email = :email', [':email' => Commons::TEST_EMAIL]); Utils::cleanDir($this->mailDir); // Delete all emails generated by the tests }
public function _after(FunctionalTester $I) { User::deleteAll('email = :email', [':email' => Commons::TEST_EMAIL]); }
$loginPage->openBy($I); //$I->assertTrue( // $I->seeExceptionThrown('yii\web\ForbiddenHttpException', function () use ($loginPage, $email) { // $loginPage->login($email, 'test123'); // }) //, "I see yii\\web\\ForbiddenHttpException when trying to login unconfirmed."); //The exception is handled therefore I cannot see the items below ! //$I->seeResponseCodeIs(403); //forbidden //$I->expectTo('see error that you cannot login without confirming your account.'); //$I->see('Unconfirmed account are not allowed to login'); //check database status $I->seeInDatabase('user', ['email' => $email, 'status' => 1, 'confirmed_on' => null]); $user_id = $I->grabFromDatabase('user', 'id', ['email' => $email]); $I->seeInDatabase('token', ['type' => 0, 'user_id' => $user_id]); $token_code = $I->grabFromDatabase('token', 'code', ['type' => 0, 'user_id' => $user_id]); //Confirmation tests //TODO: this fails on travis beacause of buggy phpunit, will enable when fixed //$I->assertTrue( // $I->seeExceptionThrown('yii\web\BadRequestHttpException', function () use ($I) { // ConfirmPage::openBy($I); // }) //, "I see yii\\web\\BadRequestHttpException when opening confirm URL without params."); $confirmPage = ConfirmPage::openBy($I, ['code' => $token_code]); //$I->assertTrue($confirmPage instanceof ConfirmPage); $I->expectTo('see successfully confirmed message!'); $I->see('Registration confirmed', 'h1'); $I->see('Your registration is confirmed succesfully!'); //token must be missing $I->dontSeeInDatabase('token', ['type' => 0, 'user_id' => $user_id]); User::deleteAll('email = :email', [':email' => $email]);
use nkostadinov\user\models\User; use nkostadinov\user\tests\_pages\LoginPage; use nkostadinov\user\tests\_pages\LogoutPage; $I = new FunctionalTester($scenario); $I->wantTo('see that login works.'); $loginPage = LoginPage::openBy($I); $I->see('Login', 'h3'); //empty username and password $loginPage->login('', ''); $I->expectTo('see validations errors'); $I->see('Username cannot be blank.'); $I->see('Password cannot be blank.'); //wrong username and password $loginPage->login('test', 'test'); $I->expectTo('see validations errors'); $I->see('Incorrect username or password'); //see the forgot password link $I->seeLink('Forgot password?', '/user/recovery/request'); // Test that the login works Commons::createUserWithUsername(); $loginPage->login(Commons::TEST_EMAIL, Commons::TEST_PASSWORD); $I->seeInCurrentUrl('/'); // Logout the user LogoutPage::openBy($I); // Log the user in again $loginPage = LoginPage::openBy($I); // Test that the login works with the username as well $loginPage->login(Commons::TEST_USERNAME, Commons::TEST_PASSWORD); $I->seeInCurrentUrl('/'); User::deleteAll('email = :email', [':email' => Commons::TEST_EMAIL]);
protected function tearDown() { User::deleteAll('email = :email', [':email' => Commons::TEST_EMAIL]); parent::tearDown(); }