Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/config/main.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
Expand Down
1 change: 1 addition & 0 deletions backend/config/params.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'adminEmail' => 'admin@example.com',
];
1 change: 1 addition & 0 deletions backend/config/test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'id' => 'app-backend-tests',
'components' => [
Expand Down
1 change: 1 addition & 0 deletions backend/tests/_data/login_data.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
[
'username' => 'erau',
Expand Down
6 changes: 3 additions & 3 deletions backend/tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;
/**
* Define custom actions here
*/
/**
* Define custom actions here
*/
}
6 changes: 3 additions & 3 deletions backend/tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
/**
* Define custom actions here
*/
}
2 changes: 1 addition & 1 deletion backend/tests/functional/LoginCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function _fixtures()
]
];
}

/**
* @param FunctionalTester $I
*/
Expand Down
3 changes: 2 additions & 1 deletion backend/tests/functional/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cests.
Expand All @@ -13,4 +14,4 @@
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
*/
1 change: 1 addition & 0 deletions backend/tests/unit/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Tests.
Expand Down
12 changes: 7 additions & 5 deletions common/config/__autocomplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@
* }
* ```
*/
class Yii {
class Yii
{
/**
* @var \yii\web\Application|\yii\console\Application|__Application
*/
public static $app;
}

/**
* @property yii\rbac\DbManager $authManager
* @property yii\rbac\DbManager $authManager
* @property \yii\web\User|__WebUser $user
*
*/
class __Application {
class __Application
{
}

/**
* @property app\models\User $identity
*/
class __WebUser {
class __WebUser
{
}
1 change: 1 addition & 0 deletions common/config/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

Yii::setAlias('@common', dirname(__DIR__));
Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('@backend', dirname(dirname(__DIR__)) . '/backend');
Expand Down
1 change: 1 addition & 0 deletions common/config/main.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'aliases' => [
'@bower' => '@vendor/bower-asset',
Expand Down
1 change: 1 addition & 0 deletions common/config/params.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'adminEmail' => 'admin@example.com',
'supportEmail' => 'support@example.com',
Expand Down
1 change: 1 addition & 0 deletions common/config/test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'id' => 'app-common-tests',
'basePath' => dirname(__DIR__),
Expand Down
2 changes: 1 addition & 1 deletion common/models/LoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function login()
if ($this->validate()) {
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
}

return false;
}

Expand Down
17 changes: 9 additions & 8 deletions common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
/**
* User model
*
* @property integer $id
* @property int $id
* @property string $username
* @property string $password_hash
* @property string $password_reset_token
* @property string $verification_token
* @property string $email
* @property string $auth_key
* @property integer $status
* @property integer $created_at
* @property integer $updated_at
* @property int $status
* @property int $created_at
* @property int $updated_at
* @property string $password write-only password
*/
class User extends ActiveRecord implements IdentityInterface
{
const STATUS_DELETED = 0;
const STATUS_INACTIVE = 9;
const STATUS_ACTIVE = 10;
public const STATUS_DELETED = 0;
public const STATUS_INACTIVE = 9;
public const STATUS_ACTIVE = 10;


/**
Expand Down Expand Up @@ -110,7 +110,8 @@ public static function findByPasswordResetToken($token)
* @param string $token verify email token
* @return static|null
*/
public static function findByVerificationToken($token) {
public static function findByVerificationToken($token)
{
return static::findOne([
'verification_token' => $token,
'status' => self::STATUS_INACTIVE
Expand Down
6 changes: 3 additions & 3 deletions common/tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
/**
* Define custom actions here
*/
}
2 changes: 1 addition & 1 deletion common/tests/unit/models/LoginFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testLoginWrongPassword()
]);

verify($model->login())->false();
verify( $model->errors)->arrayHasKey('password');
verify($model->errors)->arrayHasKey('password');
verify(Yii::$app->user->isGuest)->true();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use \yii\db\Migration;
use yii\db\Migration;

class m190124_110200_add_verification_token_column_to_user_table extends Migration
{
Expand Down
1 change: 1 addition & 0 deletions environments/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The manifest of files that are local to specific environment.
* This file returns a list of environments that the application
Expand Down
1 change: 1 addition & 0 deletions frontend/config/main.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

$params = array_merge(
require __DIR__ . '/../../common/config/params.php',
require __DIR__ . '/../../common/config/params-local.php',
Expand Down
1 change: 1 addition & 0 deletions frontend/config/params.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'adminEmail' => 'admin@example.com',
];
1 change: 1 addition & 0 deletions frontend/config/test.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

return [
'id' => 'app-frontend-tests',
'components' => [
Expand Down
2 changes: 1 addition & 1 deletion frontend/models/PasswordResetRequestForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function sendEmail()
if (!$user) {
return false;
}

if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
if (!$user->save()) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/models/SignupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function signup()
if (!$this->validate()) {
return null;
}

$user = new User();
$user->username = $this->username;
$user->email = $this->email;
Expand Down
6 changes: 3 additions & 3 deletions frontend/tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;
/**
* Define custom actions here
*/
/**
* Define custom actions here
*/
}
3 changes: 2 additions & 1 deletion frontend/tests/acceptance/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cepts.
Expand All @@ -13,4 +14,4 @@
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
*/
2 changes: 1 addition & 1 deletion frontend/tests/functional/HomeCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public function checkOpen(FunctionalTester $I)
$I->click('About');
$I->see('This is the About page.');
}
}
}
12 changes: 6 additions & 6 deletions frontend/tests/functional/SignupCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ public function signupWithEmptyFields(FunctionalTester $I)
$I->seeValidationError('Username cannot be blank.');
$I->seeValidationError('Email cannot be blank.');
$I->seeValidationError('Password cannot be blank.');

}

public function signupWithWrongEmail(FunctionalTester $I)
{
$I->submitForm(
$this->formId, [
'SignupForm[username]' => 'tester',
'SignupForm[email]' => 'ttttt',
'SignupForm[password]' => 'tester_password',
]
$this->formId,
[
'SignupForm[username]' => 'tester',
'SignupForm[email]' => 'ttttt',
'SignupForm[password]' => 'tester_password',
]
);
$I->dontSee('Username cannot be blank.', '.invalid-feedback');
$I->dontSee('Password cannot be blank.', '.invalid-feedback');
Expand Down
3 changes: 2 additions & 1 deletion frontend/tests/functional/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Cests.
Expand All @@ -13,4 +14,4 @@
* ```php
* \Codeception\Util\Fixtures::get('user1');
* ```
*/
*/
1 change: 1 addition & 0 deletions frontend/tests/unit/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Here you can initialize variables via \Codeception\Util\Fixtures class
* to store data in global array and use it in Tests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testNotSendEmailsToInactiveUser()
public function testSendEmailSuccessfully()
{
$userFixture = $this->tester->grabFixture('user', 0);

$model = new PasswordResetRequestForm();
$model->email = $userFixture['email'];
$user = User::findOne(['password_reset_token' => $userFixture['password_reset_token']]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace frontend\tests\unit\models;


use Codeception\Test\Unit;
use common\fixtures\UserFixture;
use frontend\models\ResendVerificationEmailForm;
Expand Down
5 changes: 2 additions & 3 deletions frontend/tests/unit/models/ResetPasswordFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function _before()

public function testResetWrongToken()
{
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function () {
new ResetPasswordForm('');
});

$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function () {
new ResetPasswordForm('notexistingtoken_1391882543');
});
}
Expand All @@ -40,5 +40,4 @@ public function testResetCorrectToken()
$form = new ResetPasswordForm($user['password_reset_token']);
verify($form->resetPassword())->notEmpty();
}

}
6 changes: 3 additions & 3 deletions frontend/tests/unit/models/VerifyEmailFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public function _before()

public function testVerifyWrongToken()
{
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function () {
new VerifyEmailForm('');
});

$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function () {
new VerifyEmailForm('notexistingtoken_1391882543');
});
}

public function testAlreadyActivatedToken()
{
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function() {
$this->tester->expectThrowable('\yii\base\InvalidArgumentException', function () {
new VerifyEmailForm('already_used_token_1548675330');
});
}
Expand Down
1 change: 1 addition & 0 deletions requirements.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Application requirement checker script.
*
Expand Down