-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fad326
commit 64e1cd3
Showing
52 changed files
with
2,930 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace: backend\tests | ||
actor: Tester | ||
paths: | ||
tests: tests | ||
log: tests/_output | ||
data: tests/_data | ||
helpers: tests/_support | ||
settings: | ||
bootstrap: _bootstrap.php | ||
colors: true | ||
memory_limit: 1024M | ||
modules: | ||
config: | ||
Yii2: | ||
configFile: 'config/test-local.php' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
return [ | ||
'id' => 'app-backend-tests', | ||
'components' => [ | ||
'assetManager' => [ | ||
'basePath' => __DIR__ . '/../web/assets', | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
defined('YII_DEBUG') or define('YII_DEBUG', true); | ||
defined('YII_ENV') or define('YII_ENV', 'test'); | ||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../'); | ||
|
||
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php'); | ||
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php'); | ||
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php'); | ||
require_once(__DIR__ . '/../config/bootstrap.php'); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
return [ | ||
[ | ||
'username' => 'erau', | ||
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI', | ||
// password_0 | ||
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne', | ||
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490', | ||
'created_at' => '1392559490', | ||
'updated_at' => '1392559490', | ||
'email' => '[email protected]', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace backend\tests; | ||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class FunctionalTester extends \Codeception\Actor | ||
{ | ||
use _generated\FunctionalTesterActions; | ||
/** | ||
* Define custom actions here | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace backend\tests; | ||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class UnitTester extends \Codeception\Actor | ||
{ | ||
use _generated\UnitTesterActions; | ||
/** | ||
* Define custom actions here | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class_name: FunctionalTester | ||
modules: | ||
enabled: | ||
- Yii2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace backend\tests\functional; | ||
|
||
use \backend\tests\FunctionalTester; | ||
use common\fixtures\User as UserFixture; | ||
|
||
/** | ||
* Class LoginCest | ||
*/ | ||
class LoginCest | ||
{ | ||
public function _before(FunctionalTester $I) | ||
{ | ||
$I->haveFixtures([ | ||
'user' => [ | ||
'class' => UserFixture::className(), | ||
'dataFile' => codecept_data_dir() . 'login_data.php' | ||
] | ||
]); | ||
} | ||
/** | ||
* @param FunctionalTester $I | ||
*/ | ||
public function loginUser(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/site/login'); | ||
$I->fillField('Username', 'erau'); | ||
$I->fillField('Password', 'password_0'); | ||
$I->click('login-button'); | ||
|
||
$I->see('Logout (erau)', 'form button[type=submit]'); | ||
$I->dontSeeLink('Login'); | ||
$I->dontSeeLink('Signup'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Here you can initialize variables via \Codeception\Util\Fixtures class | ||
* to store data in global array and use it in Cests. | ||
* | ||
* ```php | ||
* // Here _bootstrap.php | ||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']); | ||
* ``` | ||
* | ||
* In Cests | ||
* | ||
* ```php | ||
* \Codeception\Util\Fixtures::get('user1'); | ||
* ``` | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class_name: UnitTester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
/** | ||
* Here you can initialize variables via \Codeception\Util\Fixtures class | ||
* to store data in global array and use it in Tests. | ||
* | ||
* ```php | ||
* // Here _bootstrap.php | ||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']); | ||
* ``` | ||
* | ||
* In Tests | ||
* | ||
* ```php | ||
* \Codeception\Util\Fixtures::get('user1'); | ||
* ``` | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# global codeception file to run tests from all apps | ||
include: | ||
- common | ||
- frontend | ||
- backend | ||
paths: | ||
log: console/runtime/logs | ||
settings: | ||
colors: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace: common\tests | ||
actor: Tester | ||
paths: | ||
tests: tests | ||
log: tests/_output | ||
data: tests/_data | ||
helpers: tests/_support | ||
settings: | ||
bootstrap: _bootstrap.php | ||
colors: true | ||
memory_limit: 1024M | ||
modules: | ||
config: | ||
Yii2: | ||
configFile: 'config/test-local.php' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
return [ | ||
'id' => 'app-common-tests', | ||
'basePath' => dirname(__DIR__), | ||
'components' => [ | ||
'user' => [ | ||
'class' => 'yii\web\User', | ||
'identityClass' => 'common\models\User', | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace common\fixtures; | ||
|
||
use yii\test\ActiveFixture; | ||
|
||
class User extends ActiveFixture | ||
{ | ||
public $modelClass = 'common\models\User'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
defined('YII_DEBUG') or define('YII_DEBUG', true); | ||
defined('YII_ENV') or define('YII_ENV', 'test'); | ||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../'); | ||
|
||
require_once(__DIR__ . '/../../vendor/autoload.php'); | ||
require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); | ||
require(__DIR__ . '/../config/bootstrap.php'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
return [ | ||
[ | ||
'username' => 'bayer.hudson', | ||
'auth_key' => 'HP187Mvq7Mmm3CTU80dLkGmni_FUH_lR', | ||
//password_0 | ||
'password_hash' => '$2y$13$EjaPFBnZOQsHdGuHI.xvhuDp1fHpo8hKRSk6yshqa9c5EG8s3C3lO', | ||
'password_reset_token' => 'ExzkCOaYc1L8IOBs4wdTGGbgNiG3Wz1I_1402312317', | ||
'created_at' => '1402312317', | ||
'updated_at' => '1402312317', | ||
'email' => '[email protected]', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
namespace common\tests; | ||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class UnitTester extends \Codeception\Actor | ||
{ | ||
use _generated\UnitTesterActions; | ||
/** | ||
* Define custom actions here | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class_name: UnitTester | ||
bootstrap: false | ||
modules: | ||
enabled: | ||
- Yii2: | ||
part: fixtures |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace common\tests\unit\models; | ||
|
||
use Yii; | ||
use common\models\LoginForm; | ||
use common\fixtures\User as UserFixture; | ||
|
||
/** | ||
* Login form test | ||
*/ | ||
class LoginFormTest extends \Codeception\Test\Unit | ||
{ | ||
/** | ||
* @var \frontend\tests\UnitTester | ||
*/ | ||
protected $tester; | ||
|
||
|
||
public function _before() | ||
{ | ||
$this->tester->haveFixtures([ | ||
'user' => [ | ||
'class' => UserFixture::className(), | ||
'dataFile' => codecept_data_dir() . 'user.php' | ||
] | ||
]); | ||
} | ||
|
||
public function testLoginNoUser() | ||
{ | ||
$model = new LoginForm([ | ||
'username' => 'not_existing_username', | ||
'password' => 'not_existing_password', | ||
]); | ||
|
||
expect('model should not login user', $model->login())->false(); | ||
expect('user should not be logged in', Yii::$app->user->isGuest)->true(); | ||
} | ||
|
||
public function testLoginWrongPassword() | ||
{ | ||
$model = new LoginForm([ | ||
'username' => 'bayer.hudson', | ||
'password' => 'wrong_password', | ||
]); | ||
|
||
expect('model should not login user', $model->login())->false(); | ||
expect('error message should be set', $model->errors)->hasKey('password'); | ||
expect('user should not be logged in', Yii::$app->user->isGuest)->true(); | ||
} | ||
|
||
public function testLoginCorrect() | ||
{ | ||
$model = new LoginForm([ | ||
'username' => 'bayer.hudson', | ||
'password' => 'password_0', | ||
]); | ||
|
||
expect('model should login user', $model->login())->true(); | ||
expect('error message should not be set', $model->errors)->hasntKey('password'); | ||
expect('user should be logged in', Yii::$app->user->isGuest)->false(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.