mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 00:24:59 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -20,6 +20,7 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LocationValidityValidatorTest extends ConstraintValidatorTestCase
|
||||
|
@@ -24,6 +24,7 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ParticipationOverlapValidatorTest extends ConstraintValidatorTestCase
|
||||
@@ -69,7 +70,7 @@ class ParticipationOverlapValidatorTest extends ConstraintValidatorTestCase
|
||||
'{{ start }}' => (new \DateTimeImmutable('today'))->format('d-m-Y'),
|
||||
'{{ end }}' => null,
|
||||
'{{ ids }}' => [null, null],
|
||||
'{{ name }}' => 'person'
|
||||
'{{ name }}' => 'person',
|
||||
])
|
||||
->assertRaised();
|
||||
}
|
||||
@@ -95,6 +96,7 @@ class ParticipationOverlapValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
protected function createValidator(): ParticipationOverlapValidator
|
||||
{
|
||||
$personRender = $this->prophesize(PersonRenderInterface::class);
|
||||
|
@@ -18,11 +18,11 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequentialValidator;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTestCase
|
||||
@@ -48,11 +48,11 @@ final class HouseholdMembershipSequentialValidatorTest extends ConstraintValidat
|
||||
->setShareHousehold(true);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new DateTimeImmutable('2011-01-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person);
|
||||
|
||||
$this->validator->validate($person, $constraint);
|
||||
@@ -76,11 +76,11 @@ final class HouseholdMembershipSequentialValidatorTest extends ConstraintValidat
|
||||
->setShareHousehold(false);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new DateTimeImmutable('2011-01-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person);
|
||||
|
||||
$this->validator->validate($person, $constraint);
|
||||
|
@@ -16,11 +16,11 @@ use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolderValidator;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class MaxHolderValidatorTest extends ConstraintValidatorTestCase
|
||||
@@ -34,20 +34,20 @@ final class MaxHolderValidatorTest extends ConstraintValidatorTestCase
|
||||
->addMember(
|
||||
(new HouseholdMember())
|
||||
->setHolder(true)
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setEndDate(new DateTimeImmutable('2010-12-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setEndDate(new \DateTimeImmutable('2010-12-01'))
|
||||
)
|
||||
->addMember(
|
||||
(new HouseholdMember())
|
||||
->setHolder(true)
|
||||
->setStartDate(new DateTimeImmutable('2010-06-01'))
|
||||
->setEndDate(new DateTimeImmutable('2010-07-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2010-06-01'))
|
||||
->setEndDate(new \DateTimeImmutable('2010-07-01'))
|
||||
)
|
||||
->addMember(
|
||||
(new HouseholdMember())
|
||||
->setHolder(true)
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setEndDate(new DateTimeImmutable('2010-12-01'))
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setEndDate(new \DateTimeImmutable('2010-12-01'))
|
||||
);
|
||||
|
||||
yield [
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Tests\Validator\Person;
|
||||
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\Birthdate;
|
||||
use Chill\PersonBundle\Validator\Constraints\Person\BirthdateValidator;
|
||||
use DateTime;
|
||||
use Symfony\Component\Clock\MockClock;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
@@ -22,44 +21,45 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
* Test the behaviour of BirthdayValidator.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class BirthdateValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
public function testTomorrowInvalid()
|
||||
{
|
||||
$bornAfter = new DateTime('2023-08-31');
|
||||
$bornAfter = new \DateTime('2023-08-31');
|
||||
$this->validator->validate($bornAfter, $this->createConstraint());
|
||||
$this->buildViolation('msg')
|
||||
->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y'))
|
||||
->setParameter('%date%', (new \DateTime('2023-08-29'))->format('d-m-Y'))
|
||||
->setCode('3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateTodayInvalid()
|
||||
{
|
||||
$bornToday = new DateTime('2023-08-30');
|
||||
$bornToday = new \DateTime('2023-08-30');
|
||||
$this->validator->validate($bornToday, $this->createConstraint());
|
||||
$this->buildViolation('msg')
|
||||
->setParameter('%date%', (new DateTime('2023-08-29'))->format('d-m-Y'))
|
||||
->setParameter('%date%', (new \DateTime('2023-08-29'))->format('d-m-Y'))
|
||||
->setCode('3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateTooEarlyDate(): void
|
||||
{
|
||||
$bornLongTimeAgo = new DateTime('1871-03-18');
|
||||
$bornLongTimeAgo = new \DateTime('1871-03-18');
|
||||
$this->validator->validate($bornLongTimeAgo, $this->createConstraint());
|
||||
|
||||
$this->buildViolation('below')
|
||||
->setParameter('%date%', (new DateTime('1873-08-30'))->format('d-m-Y'))
|
||||
->setParameter('%date%', (new \DateTime('1873-08-30'))->format('d-m-Y'))
|
||||
->setCode('3f42fd96-0b2d-11ec-8cf3-0f3b1b1ca1c4')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testValidateYesterdayValid()
|
||||
{
|
||||
$bornYesterday = new DateTime('2023-08-29');
|
||||
$bornYesterday = new \DateTime('2023-08-29');
|
||||
$this->validator->validate($bornYesterday, $this->createConstraint());
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ final class BirthdateValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
return new Birthdate([
|
||||
'message' => 'msg',
|
||||
'belowMessage' => 'below'
|
||||
'belowMessage' => 'below',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PersonHasCenterValidatorTest extends ConstraintValidatorTestCase
|
||||
|
@@ -13,14 +13,13 @@ 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 function str_repeat;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PersonValidationTest extends KernelTestCase
|
||||
@@ -36,7 +35,7 @@ final class PersonValidationTest extends KernelTestCase
|
||||
public function testBirthdateInFuture()
|
||||
{
|
||||
$person = (new Person())
|
||||
->setBirthdate(new Datetime('+2 months'));
|
||||
->setBirthdate(new \DateTime('+2 months'));
|
||||
$errors = $this->validator->validate($person, null);
|
||||
|
||||
foreach ($errors->getIterator() as $error) {
|
||||
@@ -58,7 +57,7 @@ final class PersonValidationTest extends KernelTestCase
|
||||
public function testFirstnameValidation()
|
||||
{
|
||||
$person = (new Person())
|
||||
->setFirstname(str_repeat('a', 500));
|
||||
->setFirstname(\str_repeat('a', 500));
|
||||
$errors = $this->validator->validate($person, null);
|
||||
|
||||
foreach ($errors->getIterator() as $error) {
|
||||
|
Reference in New Issue
Block a user