Refactor InformativeValidator.
This commit is contained in:
+3
-4
@@ -3,16 +3,15 @@
|
|||||||
namespace App\Models\Validation\Messages;
|
namespace App\Models\Validation\Messages;
|
||||||
|
|
||||||
use App\Models\Validation\Messages\InformativeValidator;
|
use App\Models\Validation\Messages\InformativeValidator;
|
||||||
use App\Models\Validation\Validators\UpperRangeValidator;
|
use App\Models\Validation\Validators\Validator;
|
||||||
|
|
||||||
class UpperRangeInformativeValidator extends InformativeValidator {
|
class NextInformativeValidator extends InformativeValidator {
|
||||||
protected InformativeValidator $nextValidator;
|
protected InformativeValidator $nextValidator;
|
||||||
|
|
||||||
public function __construct(string $message, UpperRangeValidator $validator, InformativeValidator $nextValidator)
|
public function __construct(string $message, Validator $validator, InformativeValidator $nextValidator)
|
||||||
{
|
{
|
||||||
$this->setMessage($message);
|
$this->setMessage($message);
|
||||||
$this->setValidator($validator);
|
$this->setValidator($validator);
|
||||||
$this->nextValidator = $nextValidator;
|
$this->nextValidator = $nextValidator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4,10 +4,11 @@ namespace Tests\Unit;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
use App\Models\Validation\Messages\UpperRangeInformativeValidator;
|
use App\Models\Validation\Messages\NextInformativeValidator;
|
||||||
use App\Models\Validation\Messages\OkInformativeValidator;
|
use App\Models\Validation\Messages\OkInformativeValidator;
|
||||||
use App\Models\Validation\Validators\UpperRangeValidator;
|
use App\Models\Validation\Validators\UpperRangeValidator;
|
||||||
use App\Models\Validation\Validators\OkValidator;
|
use App\Models\Validation\Validators\OkValidator;
|
||||||
|
use App\Models\Validation\Validators\Validator;
|
||||||
|
|
||||||
class UpperRangeInformativeValidatorTest extends TestCase
|
class UpperRangeInformativeValidatorTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -45,11 +46,11 @@ class UpperRangeInformativeValidatorTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUpValidator(int $value, int $rangeLimit): UpperRangeInformativeValidator
|
public function setUpValidator(int $value, int $rangeLimit): NextInformativeValidator
|
||||||
{
|
{
|
||||||
$upperRangeValidator = new UpperRangeValidator($value, $rangeLimit, new OkValidator());
|
$upperRangeValidator = new UpperRangeValidator($value, $rangeLimit, new OkValidator());
|
||||||
|
|
||||||
return new UpperRangeInformativeValidator(
|
return new NextInformativeValidator(
|
||||||
$this->messages['error'],
|
$this->messages['error'],
|
||||||
$upperRangeValidator,
|
$upperRangeValidator,
|
||||||
new OkInformativeValidator($this->messages['ok']),
|
new OkInformativeValidator($this->messages['ok']),
|
||||||
|
|||||||
Reference in New Issue
Block a user