mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлена поддержка запоминания языка для аккаунта
Обновлена минимальная версия Yii2 Удалено немного хлама от Yii2 Advanced Исправлены некоторые тесты
This commit is contained in:
@@ -1,11 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace tests\codeception\common\unit;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
class TestCase extends \yii\codeception\TestCase
|
||||
{
|
||||
class TestCase extends \yii\codeception\TestCase {
|
||||
|
||||
public $appConfig = '@tests/codeception/config/common/unit.php';
|
||||
|
||||
}
|
||||
|
3
tests/codeception/common/unit/fixtures/data/i18n/en.json
Normal file
3
tests/codeception/common/unit/fixtures/data/i18n/en.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"testString": "testValue"
|
||||
}
|
3
tests/codeception/common/unit/fixtures/data/i18n/ru.json
Normal file
3
tests/codeception/common/unit/fixtures/data/i18n/ru.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"testString": "тестовоеЗначение"
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
<?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' => 'nicole.paucek@schultz.info',
|
||||
],
|
||||
];
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace codeception\common\unit\validators;
|
||||
|
||||
use Codeception\Specify;
|
||||
use common\validators\LanguageValidator;
|
||||
use ReflectionClass;
|
||||
use tests\codeception\common\unit\TestCase;
|
||||
|
||||
class LanguageValidatorTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function testGetFilesNames() {
|
||||
$this->specify('get list of 2 languages: ru and en', function() {
|
||||
$model = $this->createModelWithFixturePath();
|
||||
expect($this->callProtected($model, 'getFilesNames'))->equals(['en', 'ru']);
|
||||
});
|
||||
}
|
||||
|
||||
public function testValidateValue() {
|
||||
$this->specify('get null, because language is supported', function() {
|
||||
$model = $this->createModelWithFixturePath();
|
||||
expect($this->callProtected($model, 'validateValue', 'ru'))->null();
|
||||
});
|
||||
|
||||
$this->specify('get error message, because language is unsupported', function() {
|
||||
$model = $this->createModelWithFixturePath();
|
||||
expect($this->callProtected($model, 'validateValue', 'by'))->equals([
|
||||
$model->message,
|
||||
[],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LanguageValidator
|
||||
*/
|
||||
private function createModelWithFixturePath() {
|
||||
return new class extends LanguageValidator {
|
||||
public function getFolderPath() {
|
||||
return __DIR__ . '/../fixtures/data/i18n';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private function callProtected($object, string $function, ...$args) {
|
||||
$class = new ReflectionClass($object);
|
||||
$method = $class->getMethod($function);
|
||||
$method->setAccessible(true);
|
||||
|
||||
return $method->invokeArgs($object, $args);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user