cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,13 +1,26 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Validator\Person;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
use Datetime;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use function str_repeat;
/**
* @internal
* @coversNothing
*/
class PersonValidationTest extends KernelTestCase
{
private ValidatorInterface $validator;
@@ -18,38 +31,47 @@ class PersonValidationTest extends KernelTestCase
$this->validator = self::$container->get(ValidatorInterface::class);
}
public function testFirstnameValidation()
{
$person = (new Person())
->setFirstname(\str_repeat('a', 500));
$errors = $this->validator->validate($person, null, ["creation"]);
foreach ($errors->getIterator() as $error) {
if (Length::TOO_LONG_ERROR === $error->getCode()) {
$this->assertTrue(true,
"error code for firstname too long is present");
return;
}
}
$this->assertTrue(false,
"error code for fistname too long is present");
}
public function testBirthdateInFuture()
{
$person = (new Person())
->setBirthdate(new \Datetime('+2 months'));
$errors = $this->validator->validate($person, null, ["creation"]);
->setBirthdate(new Datetime('+2 months'));
$errors = $this->validator->validate($person, null, ['creation']);
foreach ($errors->getIterator() as $error) {
if (Birthdate::BIRTHDATE_INVALID_CODE === $error->getCode()) {
$this->assertTrue(true,
"error code for birthdate invalid is present");
$this->assertTrue(
true,
'error code for birthdate invalid is present'
);
return;
}
}
$this->assertTrue(false,
"error code for birthdate invalid is present");
$this->assertTrue(
false,
'error code for birthdate invalid is present'
);
}
public function testFirstnameValidation()
{
$person = (new Person())
->setFirstname(str_repeat('a', 500));
$errors = $this->validator->validate($person, null, ['creation']);
foreach ($errors->getIterator() as $error) {
if (Length::TOO_LONG_ERROR === $error->getCode()) {
$this->assertTrue(
true,
'error code for firstname too long is present'
);
return;
}
}
$this->assertTrue(
false,
'error code for fistname too long is present'
);
}
}