In my form, I defined the field:

$builder->add('sum_of_rates', IntegerType::class, [
    'empty_data' => '',
    'constraints' => [
        new NotBlank(),
        new Range(RangeValues\DefaultNumberRange::getValues())
    ]
])

My unit test:

public function setUp() {
    parent::setUp();
    self::bootKernel();
    $this->formFactory = self::$kernel->getContainer()->get('form.factory');
}

public function testValidateForm() 
{
.
.
.

    $form = $this->formFactory->create(CreditContractFormType::class, 
CreditContractDocument::class);
    $form->submit($testData["data"]);
    $form->isValid() returns here true

.
.
.
}

$testData["data"] looks like this:

array:13 [
  "correct_file" => true
  "readable" => true
  "complete" => true
  "correct_aligned" => true
  "date" => "2010-01-01"
  "customer_name" => "kaktus"
  "bank_name" => "kaktus"
  "purchase_price" => 10000
  "done_deposit" => 10000
  "monthly_rate" => 10000
  "sum_of_rates" => 123.45
  "annual_interest" => 10000
  "financeable" => true
]

$form->isValid() returns true. Why is the behavior so strange? The field sum_of_rates has not an integer value. If sum_of_rates consists a string sum_of_rates="abcde", $form->isValid() returns properly false.

0 Answers