2024-01-17 13:13:27 +00:00
|
|
|
<?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 {
|
2024-01-18 13:24:45 +00:00
|
|
|
return [['122.b'], ['a.a'], ['a'], ['2.040'], ['2,a'], ['-223']];
|
2024-01-17 13:13:27 +00:00
|
|
|
}
|
|
|
|
}
|