2016-01-15 12:21:27 +03:00
|
|
|
<?php
|
|
|
|
namespace tests\codeception\api\traits;
|
|
|
|
|
|
|
|
use api\traits\ApiNormalize;
|
2016-10-29 00:47:31 +03:00
|
|
|
use tests\codeception\api\unit\TestCase;
|
2016-01-15 12:21:27 +03:00
|
|
|
|
|
|
|
class ApiNormalizeTestClass {
|
|
|
|
use ApiNormalize;
|
|
|
|
}
|
|
|
|
|
2016-10-29 00:47:31 +03:00
|
|
|
class ApiNormalizerTest extends TestCase {
|
2016-01-15 12:21:27 +03:00
|
|
|
|
|
|
|
public function testNormalizeModelErrors() {
|
|
|
|
$object = new ApiNormalizeTestClass();
|
2016-10-29 00:47:31 +03:00
|
|
|
$normalized = $object->normalizeModelErrors([
|
|
|
|
'rulesAgreement' => [
|
|
|
|
'error.you_must_accept_rules',
|
|
|
|
],
|
|
|
|
'email' => [
|
|
|
|
'error.email_required',
|
|
|
|
],
|
|
|
|
'username' => [
|
|
|
|
'error.username_too_short',
|
|
|
|
'error.username_not_unique',
|
|
|
|
],
|
|
|
|
]);
|
2016-01-15 12:21:27 +03:00
|
|
|
|
2016-10-29 00:47:31 +03:00
|
|
|
$this->assertEquals([
|
|
|
|
'rulesAgreement' => 'error.you_must_accept_rules',
|
|
|
|
'email' => 'error.email_required',
|
|
|
|
'username' => 'error.username_too_short',
|
|
|
|
], $normalized);
|
2016-01-15 12:21:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|