41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?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'], ['-223']];
 | 
						|
    }
 | 
						|
}
 |