mirror of
https://github.com/elyby/accounts.git
synced 2025-01-11 14:32:12 +05:30
Upgrade Codeception to 3 version. Remove codeception/verify.
This commit is contained in:
parent
5dacd66fb7
commit
75fdd5d1ba
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace api\tests\unit;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use Mockery;
|
||||
|
||||
class TestCase extends \Codeception\Test\Unit {
|
||||
class TestCase extends Unit {
|
||||
|
||||
/**
|
||||
* @var \api\tests\UnitTester
|
||||
@ -22,7 +25,7 @@ class TestCase extends \Codeception\Test\Unit {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class ComponentTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
/**
|
||||
* @var Component|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var Component|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $component;
|
||||
|
||||
@ -30,7 +30,7 @@ class ComponentTest extends TestCase {
|
||||
$this->component = new Component($this->getComponentConfig());
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'sessions' => AccountSessionFixture::class,
|
||||
@ -115,7 +115,7 @@ class ComponentTest extends TestCase {
|
||||
$result = $this->component->createJwtAuthenticationToken($account, true);
|
||||
$this->component->logout();
|
||||
|
||||
/** @var Component|\PHPUnit_Framework_MockObject_MockObject $component */
|
||||
/** @var Component|\PHPUnit\Framework\MockObject\MockObject $component */
|
||||
$component = $this->getMockBuilder(Component::class)
|
||||
->setMethods(['getIsGuest'])
|
||||
->setConstructorArgs([$this->getComponentConfig()])
|
||||
|
@ -20,7 +20,7 @@ class NginxCacheTest extends TestCase {
|
||||
}
|
||||
|
||||
private function testAfterActionInternal($ruleConfig, $expected) {
|
||||
/** @var HeaderCollection|\PHPUnit_Framework_MockObject_MockObject $headers */
|
||||
/** @var HeaderCollection|\PHPUnit\Framework\MockObject\MockObject $headers */
|
||||
$headers = $this->getMockBuilder(HeaderCollection::class)
|
||||
->setMethods(['set'])
|
||||
->getMock();
|
||||
@ -29,7 +29,7 @@ class NginxCacheTest extends TestCase {
|
||||
->method('set')
|
||||
->with('X-Accel-Expires', $expected);
|
||||
|
||||
/** @var Request|\PHPUnit_Framework_MockObject_MockObject $request */
|
||||
/** @var Request|\PHPUnit\Framework\MockObject\MockObject $request */
|
||||
$request = $this->getMockBuilder(Request::class)
|
||||
->setMethods(['getHeaders'])
|
||||
->getMock();
|
||||
@ -40,7 +40,7 @@ class NginxCacheTest extends TestCase {
|
||||
|
||||
Yii::$app->set('response', $request);
|
||||
|
||||
/** @var Controller|\PHPUnit_Framework_MockObject_MockObject $controller */
|
||||
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject $controller */
|
||||
$controller = $this->getMockBuilder(Controller::class)
|
||||
->setConstructorArgs(['mock', Yii::$app])
|
||||
->getMock();
|
||||
|
@ -19,7 +19,7 @@ class FeedbackFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testSendMessageWithEmail() {
|
||||
/** @var FeedbackForm|\PHPUnit_Framework_MockObject_MockObject $model */
|
||||
/** @var FeedbackForm|\PHPUnit\Framework\MockObject\MockObject $model */
|
||||
$model = $this->getMockBuilder(FeedbackForm::class)
|
||||
->setMethods(['getAccount'])
|
||||
->setConstructorArgs([[
|
||||
|
@ -1,11 +1,9 @@
|
||||
<?php
|
||||
namespace codeception\api\unit\models;
|
||||
|
||||
use api\components\User\IdentityInterface;
|
||||
use api\components\User\Jwt;
|
||||
use api\components\User\JwtIdentity;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\tests\_support\ProtectedCaller;
|
||||
use common\tests\fixtures\AccountFixture;
|
||||
use Emarref\Jwt\Claim;
|
||||
@ -14,7 +12,6 @@ use Emarref\Jwt\Token;
|
||||
use Yii;
|
||||
|
||||
class JwtIdentityTest extends TestCase {
|
||||
use Specify;
|
||||
use ProtectedCaller;
|
||||
|
||||
public function _fixtures(): array {
|
||||
@ -26,7 +23,6 @@ class JwtIdentityTest extends TestCase {
|
||||
public function testFindIdentityByAccessToken() {
|
||||
$token = $this->generateToken();
|
||||
$identity = JwtIdentity::findIdentityByAccessToken($token);
|
||||
$this->assertInstanceOf(IdentityInterface::class, $identity);
|
||||
$this->assertSame($token, $identity->getId());
|
||||
$this->assertSame($this->tester->grabFixture('accounts', 'admin')['id'], $identity->getAccount()->id);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class ConfirmEmailFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
];
|
||||
|
@ -4,7 +4,6 @@ namespace codeception\api\unit\models\authentication;
|
||||
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
|
||||
use api\models\authentication\ForgotPasswordForm;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use common\tasks\SendPasswordRecoveryEmail;
|
||||
@ -14,7 +13,6 @@ use GuzzleHttp\ClientInterface;
|
||||
use Yii;
|
||||
|
||||
class ForgotPasswordFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
@ -25,7 +23,7 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
@ -104,12 +102,13 @@ class ForgotPasswordFormTest extends TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SendPasswordRecoveryEmail $job
|
||||
* @param \yii\queue\JobInterface $job
|
||||
* @param Account $account
|
||||
* @param EmailActivation $activation
|
||||
*/
|
||||
private function assertTaskCreated($job, Account $account, EmailActivation $activation) {
|
||||
$this->assertInstanceOf(SendPasswordRecoveryEmail::class, $job);
|
||||
/** @var SendPasswordRecoveryEmail $job */
|
||||
$this->assertSame($account->username, $job->username);
|
||||
$this->assertSame($account->email, $job->email);
|
||||
$this->assertSame($account->lang, $job->locale);
|
||||
|
@ -25,7 +25,7 @@ class LoginFormTest extends TestCase {
|
||||
$_SERVER['REMOTE_ADDR'] = $this->originalRemoteAddr;
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
];
|
||||
|
@ -27,7 +27,7 @@ class LogoutFormTest extends TestCase {
|
||||
Yii::$app->set('user', $userComp);
|
||||
|
||||
$model = new LogoutForm();
|
||||
expect($model->logout())->true();
|
||||
$this->assertTrue($model->logout());
|
||||
});
|
||||
|
||||
$this->specify('if active session is presented, then delete should be called', function() {
|
||||
|
@ -4,15 +4,13 @@ namespace api\tests\_support\models\authentication;
|
||||
use api\components\User\AuthenticationResult;
|
||||
use api\models\authentication\RecoverPasswordForm;
|
||||
use api\tests\unit\TestCase;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\models\EmailActivation;
|
||||
use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class RecoverPasswordFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ use common\tests\fixtures\AccountSessionFixture;
|
||||
class RefreshTokenFormTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'sessions' => AccountSessionFixture::class,
|
||||
];
|
||||
|
@ -30,7 +30,7 @@ class RegistrationFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@ -24,7 +24,7 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'activations' => EmailActivationFixture::class,
|
||||
@ -35,21 +35,21 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
$this->specify('error.email_not_found if passed valid email, but it don\'t exists in database', function() {
|
||||
$model = new RepeatAccountActivationForm(['email' => 'me-is-not@exists.net']);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->equals(['error.email_not_found']);
|
||||
$this->assertSame(['error.email_not_found'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('error.account_already_activated if passed valid email, but account already activated', function() {
|
||||
$fixture = $this->tester->grabFixture('accounts', 'admin');
|
||||
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->equals(['error.account_already_activated']);
|
||||
$this->assertSame(['error.account_already_activated'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed valid email for not activated account', function() {
|
||||
$fixture = $this->tester->grabFixture('accounts', 'not-activated-account');
|
||||
$model = new RepeatAccountActivationForm(['email' => $fixture['email']]);
|
||||
$model->validateEmailForAccount('email');
|
||||
expect($model->getErrors('email'))->isEmpty();
|
||||
$this->assertEmpty($model->getErrors('email'));
|
||||
});
|
||||
}
|
||||
|
||||
@ -58,14 +58,14 @@ class RepeatAccountActivationFormTest extends TestCase {
|
||||
$fixture = $this->tester->grabFixture('activations', 'freshRegistrationConfirmation');
|
||||
$model = $this->createModel(['emailKey' => $fixture['key']]);
|
||||
$model->validateExistsActivation('email');
|
||||
expect($model->getErrors('email'))->equals(['error.recently_sent_message']);
|
||||
$this->assertSame(['error.recently_sent_message'], $model->getErrors('email'));
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed email has expired activation message', function() {
|
||||
$fixture = $this->tester->grabFixture('activations', 'oldRegistrationConfirmation');
|
||||
$model = $this->createModel(['emailKey' => $fixture['key']]);
|
||||
$model->validateExistsActivation('email');
|
||||
expect($model->getErrors('email'))->isEmpty();
|
||||
$this->assertEmpty($model->getErrors('email'));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class ChangeEmailFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@ -11,7 +11,7 @@ use common\tests\fixtures\UsernameHistoryFixture;
|
||||
|
||||
class ChangeUsernameFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'history' => UsernameHistoryFixture::class,
|
||||
|
@ -12,7 +12,7 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
|
||||
class SendEmailVerificationFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@ -14,7 +14,7 @@ use yii\validators\EmailValidator;
|
||||
|
||||
class SendNewEmailVerificationFormTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
|
@ -15,7 +15,7 @@ use Ramsey\Uuid\Uuid;
|
||||
class AuthenticationFormTest extends TestCase {
|
||||
use ProtectedCaller;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
'minecraftAccessKeys' => MinecraftAccessKeyFixture::class,
|
||||
@ -111,7 +111,7 @@ class AuthenticationFormTest extends TestCase {
|
||||
}
|
||||
|
||||
private function createAuthForm($status = Account::STATUS_ACTIVE) {
|
||||
/** @var LoginForm|\PHPUnit_Framework_MockObject_MockObject $loginForm */
|
||||
/** @var LoginForm|\PHPUnit\Framework\MockObject\MockObject $loginForm */
|
||||
$loginForm = $this->getMockBuilder(LoginForm::class)
|
||||
->setMethods(['getAccount'])
|
||||
->getMock();
|
||||
@ -126,7 +126,7 @@ class AuthenticationFormTest extends TestCase {
|
||||
->method('getAccount')
|
||||
->will($this->returnValue($account));
|
||||
|
||||
/** @var AuthenticationForm|\PHPUnit_Framework_MockObject_MockObject $authForm */
|
||||
/** @var AuthenticationForm|\PHPUnit\Framework\MockObject\MockObject $authForm */
|
||||
$authForm = $this->getMockBuilder(AuthenticationForm::class)
|
||||
->setMethods(['createLoginForm', 'createMinecraftAccessToken'])
|
||||
->getMock();
|
||||
|
@ -24,7 +24,7 @@ class BanFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testBan() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
/** @var Account|\PHPUnit\Framework\MockObject\MockObject $account */
|
||||
$account = $this->getMockBuilder(Account::class)
|
||||
->setMethods(['save'])
|
||||
->getMock();
|
||||
|
@ -23,7 +23,7 @@ class PardonFormTest extends TestCase {
|
||||
}
|
||||
|
||||
public function testPardon() {
|
||||
/** @var Account|\PHPUnit_Framework_MockObject_MockObject $account */
|
||||
/** @var Account|\PHPUnit\Framework\MockObject\MockObject $account */
|
||||
$account = $this->getMockBuilder(Account::class)
|
||||
->setMethods(['save'])
|
||||
->getMock();
|
||||
|
@ -3,14 +3,12 @@ namespace api\tests\_support\traits;
|
||||
|
||||
use api\tests\unit\TestCase;
|
||||
use api\traits\AccountFinder;
|
||||
use Codeception\Specify;
|
||||
use common\models\Account;
|
||||
use common\tests\fixtures\AccountFixture;
|
||||
|
||||
class AccountFinderTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => AccountFixture::class,
|
||||
];
|
||||
|
@ -3,7 +3,6 @@ namespace codeception\api\unit\validators;
|
||||
|
||||
use api\tests\unit\TestCase;
|
||||
use api\validators\EmailActivationKeyValidator;
|
||||
use Codeception\Specify;
|
||||
use common\helpers\Error as E;
|
||||
use common\models\confirmations\ForgotPassword;
|
||||
use common\models\EmailActivation;
|
||||
@ -12,7 +11,6 @@ use common\tests\fixtures\EmailActivationFixture;
|
||||
use yii\base\Model;
|
||||
|
||||
class EmailActivationKeyValidatorTest extends TestCase {
|
||||
use Specify;
|
||||
use ProtectedCaller;
|
||||
|
||||
public function testValidateAttribute() {
|
||||
@ -21,7 +19,7 @@ class EmailActivationKeyValidatorTest extends TestCase {
|
||||
public $key;
|
||||
};
|
||||
|
||||
/** @var EmailActivationKeyValidator|\PHPUnit_Framework_MockObject_MockObject $validator */
|
||||
/** @var EmailActivationKeyValidator|\PHPUnit\Framework\MockObject\MockObject $validator */
|
||||
$validator = $this->getMockBuilder(EmailActivationKeyValidator::class)
|
||||
->setMethods(['findEmailActivationModel'])
|
||||
->getMock();
|
||||
|
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tests\unit;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use Mockery;
|
||||
|
||||
class TestCase extends \Codeception\Test\Unit {
|
||||
class TestCase extends Unit {
|
||||
|
||||
/**
|
||||
* @var \common\tests\UnitTester
|
||||
@ -22,7 +25,7 @@ class TestCase extends \Codeception\Test\Unit {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class DataBehaviorTest extends TestCase {
|
||||
$model = $this->createModel();
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
expect($this->callProtected($behavior, 'getData'))->equals([]);
|
||||
$this->assertSame([], $this->callProtected($behavior, 'getData'));
|
||||
});
|
||||
|
||||
$this->specify('getting value from serialized data field should return encoded value', function() {
|
||||
@ -42,7 +42,7 @@ class DataBehaviorTest extends TestCase {
|
||||
$model->_data = serialize($data);
|
||||
/** @var DataBehavior $behavior */
|
||||
$behavior = $model->behaviors['dataBehavior'];
|
||||
expect($this->callProtected($behavior, 'getData'))->equals($data);
|
||||
$this->assertSame($data, $this->callProtected($behavior, 'getData'));
|
||||
});
|
||||
|
||||
$this->specify('getting value from invalid serialization string', function() {
|
||||
|
@ -21,24 +21,24 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
public function testCompareTime() {
|
||||
$this->specify('expect false, if passed value is less then 0', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
expect($this->callProtected($behavior, 'compareTime', -1))->false();
|
||||
$this->assertFalse($this->callProtected($behavior, 'compareTime', -1));
|
||||
});
|
||||
|
||||
$this->specify('expect true, if passed value is equals 0', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
expect($this->callProtected($behavior, 'compareTime', 0))->true();
|
||||
$this->assertTrue($this->callProtected($behavior, 'compareTime', 0));
|
||||
});
|
||||
|
||||
$this->specify('expect true, if passed value is more than 0 and current time is greater then calculated', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->owner->created_at = time() - 10;
|
||||
expect($this->callProtected($behavior, 'compareTime', 5))->true();
|
||||
$this->assertTrue($this->callProtected($behavior, 'compareTime', 5));
|
||||
});
|
||||
|
||||
$this->specify('expect false, if passed value is more than 0 and current time is less then calculated', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->owner->created_at = time() - 2;
|
||||
expect($this->callProtected($behavior, 'compareTime', 7))->false();
|
||||
$this->assertFalse($this->callProtected($behavior, 'compareTime', 7));
|
||||
});
|
||||
}
|
||||
|
||||
@ -47,14 +47,14 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->repeatTimeout = 30;
|
||||
$behavior->owner->created_at = time() - 60;
|
||||
expect($behavior->canRepeat())->true();
|
||||
$this->assertTrue($behavior->canRepeat());
|
||||
});
|
||||
|
||||
$this->specify('we cannot repeat, if created_at + repeatTimeout is less, then current time', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->repeatTimeout = 60;
|
||||
$behavior->owner->created_at = time() - 30;
|
||||
expect($behavior->canRepeat())->false();
|
||||
$this->assertFalse($behavior->canRepeat());
|
||||
});
|
||||
}
|
||||
|
||||
@ -63,14 +63,14 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->expirationTimeout = 30;
|
||||
$behavior->owner->created_at = time() - 60;
|
||||
expect($behavior->isExpired())->true();
|
||||
$this->assertTrue($behavior->isExpired());
|
||||
});
|
||||
|
||||
$this->specify('key is not expired, if created_at + expirationTimeout is less, then current time', function() {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->expirationTimeout = 60;
|
||||
$behavior->owner->created_at = time() - 30;
|
||||
expect($behavior->isExpired())->false();
|
||||
$this->assertFalse($behavior->isExpired());
|
||||
});
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->repeatTimeout = 30;
|
||||
$behavior->owner->created_at = time() - 60;
|
||||
expect($behavior->canRepeatIn())->equals($behavior->owner->created_at + $behavior->repeatTimeout);
|
||||
$this->assertSame($behavior->owner->created_at + $behavior->repeatTimeout, $behavior->canRepeatIn());
|
||||
});
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ class EmailActivationExpirationBehaviorTest extends TestCase {
|
||||
$behavior = $this->createBehavior();
|
||||
$behavior->expirationTimeout = 30;
|
||||
$behavior->owner->created_at = time() - 60;
|
||||
expect($behavior->expireIn())->equals($behavior->owner->created_at + $behavior->expirationTimeout);
|
||||
$this->assertSame($behavior->owner->created_at + $behavior->expirationTimeout, $behavior->expireIn());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ class PrimaryKeyValueBehaviorTest extends TestCase {
|
||||
public function testRefreshPrimaryKeyValue() {
|
||||
$this->specify('method should generate value for primary key field on call', function() {
|
||||
$model = new DummyModel();
|
||||
/** @var PrimaryKeyValueBehavior|\PHPUnit_Framework_MockObject_MockObject $behavior */
|
||||
/** @var PrimaryKeyValueBehavior|\PHPUnit\Framework\MockObject\MockObject $behavior */
|
||||
$behavior = $this->getMockBuilder(PrimaryKeyValueBehavior::class)
|
||||
->setMethods(['isValueExists'])
|
||||
->setConstructorArgs([[
|
||||
@ -28,12 +28,12 @@ class PrimaryKeyValueBehaviorTest extends TestCase {
|
||||
|
||||
$model->attachBehavior('primary-key-value-behavior', $behavior);
|
||||
$behavior->setPrimaryKeyValue();
|
||||
expect($model->id)->equals('mock');
|
||||
$this->assertSame('mock', $model->id);
|
||||
});
|
||||
|
||||
$this->specify('method should repeat value generation if generated value duplicate with exists', function() {
|
||||
$model = new DummyModel();
|
||||
/** @var PrimaryKeyValueBehavior|\PHPUnit_Framework_MockObject_MockObject $behavior */
|
||||
/** @var PrimaryKeyValueBehavior|\PHPUnit\Framework\MockObject\MockObject $behavior */
|
||||
$behavior = $this->getMockBuilder(PrimaryKeyValueBehavior::class)
|
||||
->setMethods(['isValueExists', 'generateValue'])
|
||||
->setConstructorArgs([[
|
||||
@ -53,7 +53,7 @@ class PrimaryKeyValueBehaviorTest extends TestCase {
|
||||
|
||||
$model->attachBehavior('primary-key-value-behavior', $behavior);
|
||||
$behavior->setPrimaryKeyValue();
|
||||
expect($model->id)->equals('3');
|
||||
$this->assertSame('3', $model->id);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,16 +32,16 @@ class AccountTest extends TestCase {
|
||||
'email' => 'erick@skrauch.net',
|
||||
'password_hash' => UserPass::make('erick@skrauch.net', '12345678'),
|
||||
]);
|
||||
expect('valid password should pass', $model->validatePassword('12345678', Account::PASS_HASH_STRATEGY_OLD_ELY))->true();
|
||||
expect('invalid password should fail', $model->validatePassword('87654321', Account::PASS_HASH_STRATEGY_OLD_ELY))->false();
|
||||
$this->assertTrue($model->validatePassword('12345678', Account::PASS_HASH_STRATEGY_OLD_ELY), 'valid password should pass');
|
||||
$this->assertFalse($model->validatePassword('87654321', Account::PASS_HASH_STRATEGY_OLD_ELY), 'invalid password should fail');
|
||||
});
|
||||
|
||||
$this->specify('modern hash algorithm should work', function() {
|
||||
$model = new Account([
|
||||
'password_hash' => Yii::$app->security->generatePasswordHash('12345678'),
|
||||
]);
|
||||
expect('valid password should pass', $model->validatePassword('12345678', Account::PASS_HASH_STRATEGY_YII2))->true();
|
||||
expect('invalid password should fail', $model->validatePassword('87654321', Account::PASS_HASH_STRATEGY_YII2))->false();
|
||||
$this->assertTrue($model->validatePassword('12345678', Account::PASS_HASH_STRATEGY_YII2), 'valid password should pass');
|
||||
$this->assertFalse($model->validatePassword('87654321', Account::PASS_HASH_STRATEGY_YII2), 'invalid password should fail');
|
||||
});
|
||||
|
||||
$this->specify('if second argument is not pass model value should be used', function() {
|
||||
@ -50,15 +50,15 @@ class AccountTest extends TestCase {
|
||||
'password_hash_strategy' => Account::PASS_HASH_STRATEGY_OLD_ELY,
|
||||
'password_hash' => UserPass::make('erick@skrauch.net', '12345678'),
|
||||
]);
|
||||
expect('valid password should pass', $model->validatePassword('12345678'))->true();
|
||||
expect('invalid password should fail', $model->validatePassword('87654321'))->false();
|
||||
$this->assertTrue($model->validatePassword('12345678'), 'valid password should pass');
|
||||
$this->assertFalse($model->validatePassword('87654321'), 'invalid password should fail');
|
||||
|
||||
$model = new Account([
|
||||
'password_hash_strategy' => Account::PASS_HASH_STRATEGY_YII2,
|
||||
'password_hash' => Yii::$app->security->generatePasswordHash('12345678'),
|
||||
]);
|
||||
expect('valid password should pass', $model->validatePassword('12345678'))->true();
|
||||
expect('invalid password should fail', $model->validatePassword('87654321'))->false();
|
||||
$this->assertTrue($model->validatePassword('12345678'), 'valid password should pass');
|
||||
$this->assertFalse($model->validatePassword('87654321'), 'invalid password should fail');
|
||||
});
|
||||
}
|
||||
|
||||
@ -70,13 +70,13 @@ class AccountTest extends TestCase {
|
||||
$this->specify('Expect true if collision with current username', function() {
|
||||
$model = new Account();
|
||||
$model->username = 'ErickSkrauch';
|
||||
expect($model->hasMojangUsernameCollision())->true();
|
||||
$this->assertTrue($model->hasMojangUsernameCollision());
|
||||
});
|
||||
|
||||
$this->specify('Expect false if some rare username without any collision on Mojang', function() {
|
||||
$model = new Account();
|
||||
$model->username = 'rare-username';
|
||||
expect($model->hasMojangUsernameCollision())->false();
|
||||
$this->assertFalse($model->hasMojangUsernameCollision());
|
||||
});
|
||||
}
|
||||
|
||||
@ -89,19 +89,19 @@ class AccountTest extends TestCase {
|
||||
public function testIsAgreedWithActualRules() {
|
||||
$this->specify('get false, if rules field set in null', function() {
|
||||
$model = new Account();
|
||||
expect($model->isAgreedWithActualRules())->false();
|
||||
$this->assertFalse($model->isAgreedWithActualRules());
|
||||
});
|
||||
|
||||
$this->specify('get false, if rules field have version less, then actual', function() {
|
||||
$model = new Account();
|
||||
$model->rules_agreement_version = 0;
|
||||
expect($model->isAgreedWithActualRules())->false();
|
||||
$this->assertFalse($model->isAgreedWithActualRules());
|
||||
});
|
||||
|
||||
$this->specify('get true, if rules field have equals rules version', function() {
|
||||
$model = new Account();
|
||||
$model->rules_agreement_version = LATEST_RULES_VERSION;
|
||||
expect($model->isAgreedWithActualRules())->true();
|
||||
$this->assertTrue($model->isAgreedWithActualRules());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ use common\tests\unit\TestCase;
|
||||
|
||||
class EmailActivationTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'emailActivations' => EmailActivationFixture::class,
|
||||
];
|
||||
|
@ -7,7 +7,7 @@ use common\tests\unit\TestCase;
|
||||
|
||||
class OauthClientQueryTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'oauthClients' => OauthClientFixture::class,
|
||||
];
|
||||
|
@ -14,7 +14,7 @@ use const common\LATEST_RULES_VERSION;
|
||||
|
||||
class OauthClientOwnerTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'oauthClients' => OauthClientFixture::class,
|
||||
];
|
||||
|
@ -14,7 +14,7 @@ use yii\queue\Queue;
|
||||
*/
|
||||
class ClearAccountSessionsTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'accounts' => fixtures\AccountFixture::class,
|
||||
'oauthSessions' => fixtures\OauthSessionFixture::class,
|
||||
|
@ -10,7 +10,7 @@ use yii\queue\Queue;
|
||||
|
||||
class ClearOauthSessionsTest extends TestCase {
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'oauthClients' => fixtures\OauthClientFixture::class,
|
||||
'oauthSessions' => fixtures\OauthSessionFixture::class,
|
||||
|
@ -24,7 +24,7 @@ class PullMojangUsernameTest extends TestCase {
|
||||
/** @var \PHPUnit\Framework\MockObject\Builder\InvocationMocker */
|
||||
private $mockedMethod;
|
||||
|
||||
public function _fixtures() {
|
||||
public function _fixtures(): array {
|
||||
return [
|
||||
'mojangUsernames' => MojangUsernameFixture::class,
|
||||
];
|
||||
|
@ -31,9 +31,8 @@
|
||||
"yiisoft/yii2-swiftmailer": "~2.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^2.5.3",
|
||||
"codeception/base": "^3.0.0",
|
||||
"codeception/specify": "^1.0.0",
|
||||
"codeception/verify": "*",
|
||||
"ely/php-code-style": "^0.3.0",
|
||||
"flow/jsonpath": "^0.4.0",
|
||||
"fzaninotto/faker": "^1.8",
|
||||
|
864
composer.lock
generated
864
composer.lock
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user