mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Перенесена логика join операции для современных серверов.
Нужно признать, что перенесена она так себе, но в будущем я обязательно это перепишу.
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace tests\codeception\common\unit\validators;
|
||||
|
||||
use Codeception\Specify;
|
||||
use common\validators\UuidValidator;
|
||||
use Faker\Provider\Uuid;
|
||||
use tests\codeception\common\unit\TestCase;
|
||||
use yii\base\Model;
|
||||
|
||||
class UuidValidatorTest extends TestCase {
|
||||
use Specify;
|
||||
|
||||
public function testValidateAttribute() {
|
||||
$this->specify('expected error if passed empty value', function() {
|
||||
$model = new UuidTestModel();
|
||||
expect($model->validate())->false();
|
||||
expect($model->getErrors('attribute'))->equals(['Attribute must be valid uuid']);
|
||||
});
|
||||
|
||||
$this->specify('expected error if passed invalid string', function() {
|
||||
$model = new UuidTestModel();
|
||||
$model->attribute = '123456789';
|
||||
expect($model->validate())->false();
|
||||
expect($model->getErrors('attribute'))->equals(['Attribute must be valid uuid']);
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed valid uuid', function() {
|
||||
$model = new UuidTestModel();
|
||||
$model->attribute = Uuid::uuid();
|
||||
expect($model->validate())->true();
|
||||
});
|
||||
|
||||
$this->specify('no errors if passed uuid string without dashes and converted to standart value', function() {
|
||||
$model = new UuidTestModel();
|
||||
$originalUuid = Uuid::uuid();
|
||||
$model->attribute = str_replace('-', '', $originalUuid);
|
||||
expect($model->validate())->true();
|
||||
expect($model->attribute)->equals($originalUuid);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UuidTestModel extends Model {
|
||||
public $attribute;
|
||||
|
||||
public function rules() {
|
||||
return [
|
||||
['attribute', UuidValidator::class],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user