feat: add MoneyValidator
fix: MoneyValidator MoneyValidator fix: moneyvalidator (fakt) moneyValidator
This commit is contained in:
40
tests/Validator/MoneyValidatorTest.php
Normal file
40
tests/Validator/MoneyValidatorTest.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Validator;
|
||||
|
||||
use App\Validator\Money;
|
||||
use App\Validator\MoneyValidator;
|
||||
|
||||
class MoneyValidatorTest extends ValidatorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider successDp
|
||||
* @param string $generatedValue
|
||||
* @return void
|
||||
*/
|
||||
public function testSuccess(string $generatedValue): void {
|
||||
$moneyValidator = new MoneyValidator();
|
||||
$moneyValidator->initialize($this->createExecutionContext(false));
|
||||
$moneyValidator->validate($generatedValue, new Money(['message' => 'foo']));
|
||||
}
|
||||
|
||||
private function successDp(): array {
|
||||
return [['122'], ['122.0'], ['122,00'], ['122'], ['2.05'], ['2,04']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider failureDp
|
||||
* @param string $generatedValue
|
||||
* @return void
|
||||
*/
|
||||
public function testFailure(string $generatedValue): void {
|
||||
$moneyValidator = new MoneyValidator();
|
||||
$moneyValidator->initialize($this->createExecutionContext(true));
|
||||
$moneyValidator->validate($generatedValue, new Money(['message' => 'foo']));
|
||||
}
|
||||
|
||||
private function failureDp(): array {
|
||||
return [['122.b'], ['a.a'], ['a'], ['2.040'], ['2,a']];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user