2016-01-21 02:44:29 +05:30
|
|
|
<?php
|
2016-03-20 05:03:49 +05:30
|
|
|
namespace tests\codeception\api\models\base;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-03-20 05:03:49 +05:30
|
|
|
use api\models\base\KeyConfirmationForm;
|
2016-01-21 02:44:29 +05:30
|
|
|
use Codeception\Specify;
|
2016-05-12 03:38:40 +05:30
|
|
|
use common\models\EmailActivation;
|
2016-01-21 02:44:29 +05:30
|
|
|
use tests\codeception\api\unit\DbTestCase;
|
|
|
|
use tests\codeception\common\fixtures\EmailActivationFixture;
|
|
|
|
use Yii;
|
|
|
|
|
|
|
|
/**
|
2016-05-12 03:38:40 +05:30
|
|
|
* @property EmailActivationFixture $emailActivations
|
2016-01-21 02:44:29 +05:30
|
|
|
*/
|
2016-03-20 05:03:49 +05:30
|
|
|
class KeyConfirmationFormTest extends DbTestCase {
|
2016-01-21 02:44:29 +05:30
|
|
|
use Specify;
|
|
|
|
|
|
|
|
public function fixtures() {
|
|
|
|
return [
|
2016-05-15 04:03:21 +05:30
|
|
|
'emailActivations' => EmailActivationFixture::class,
|
2016-01-21 02:44:29 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-05-12 03:38:40 +05:30
|
|
|
public function testGetActivationCodeModel() {
|
|
|
|
$this->specify('should return model, based on passed key', function() {
|
|
|
|
$model = new KeyConfirmationForm();
|
|
|
|
$model->key = array_values($this->emailActivations->data)[0]['key'];
|
|
|
|
expect($model->getActivationCodeModel())->isInstanceOf(EmailActivation::class);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->specify('should return null, if passed key is invalid', function() {
|
|
|
|
$model = new KeyConfirmationForm();
|
|
|
|
$model->key = 'this-is-invalid-key';
|
|
|
|
expect($model->getActivationCodeModel())->null();
|
2016-01-21 02:44:29 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|