mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 23:04:58 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
<?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 Chill\PersonBundle\Tests\Validator\Household;
|
||||
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequentialValidator;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequentialValidator;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
public function testEmptyPerson()
|
||||
@@ -20,7 +32,7 @@ class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTest
|
||||
$person = new Person();
|
||||
|
||||
$this->validator->validate($person, $constraint);
|
||||
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
@@ -31,18 +43,15 @@ class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTest
|
||||
$person = new Person();
|
||||
$household = new Household();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(true)
|
||||
;
|
||||
->setShareHousehold(true);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person)
|
||||
;
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new \DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person)
|
||||
;
|
||||
->setStartDate(new DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person);
|
||||
|
||||
$this->validator->validate($person, $constraint);
|
||||
|
||||
@@ -50,10 +59,9 @@ class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTest
|
||||
->setParameters([
|
||||
'%person_name%' => 'name',
|
||||
'%from%' => '01-01-2011',
|
||||
'%nbHousehold%' => 2
|
||||
'%nbHousehold%' => 2,
|
||||
])
|
||||
->assertRaised()
|
||||
;
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testMembershipCoveringNoShareHousehold()
|
||||
@@ -63,38 +71,34 @@ class HouseholdMembershipSequentialValidatorTest extends ConstraintValidatorTest
|
||||
$person = new Person();
|
||||
$household = new Household();
|
||||
$position = (new Position())
|
||||
->setShareHousehold(false)
|
||||
;
|
||||
->setShareHousehold(false);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new \DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person)
|
||||
;
|
||||
->setStartDate(new DateTimeImmutable('2010-01-01'))
|
||||
->setPerson($person);
|
||||
$membership = (new HouseholdMember())
|
||||
->setPosition($position)
|
||||
->setStartDate(new \DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person)
|
||||
;
|
||||
->setStartDate(new DateTimeImmutable('2011-01-01'))
|
||||
->setPerson($person);
|
||||
|
||||
$this->validator->validate($person, $constraint);
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
protected function getConstraint()
|
||||
{
|
||||
return new HouseholdMembershipSequential([
|
||||
'message' => 'msg'
|
||||
]);
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
$render = $this->createMock(PersonRender::class);
|
||||
$render->method('renderString')
|
||||
->willReturn('name')
|
||||
;
|
||||
->willReturn('name');
|
||||
|
||||
return new HouseholdMembershipSequentialValidator($render);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getConstraint()
|
||||
{
|
||||
return new HouseholdMembershipSequential([
|
||||
'message' => 'msg',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -1,39 +1,28 @@
|
||||
<?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 Chill\PersonBundle\Tests\Validator\Household;
|
||||
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolderValidator;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolder;
|
||||
use Chill\PersonBundle\Validator\Constraints\Household\MaxHolderValidator;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class MaxHolderValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideInvalidHousehold
|
||||
*/
|
||||
public function testHouseholdInvalid(Household $household, $parameters)
|
||||
{
|
||||
$constraint = $this->getConstraint();
|
||||
|
||||
$this->validator->validate($household, $constraint);
|
||||
|
||||
$this->buildViolation('msg')
|
||||
->setParameters($parameters)
|
||||
->assertRaised()
|
||||
;
|
||||
}
|
||||
|
||||
protected function getConstraint()
|
||||
{
|
||||
return new MaxHolder([
|
||||
'message' => 'msg',
|
||||
'messageInfinity' => 'msgInfinity'
|
||||
]);
|
||||
}
|
||||
|
||||
public function provideInvalidHousehold()
|
||||
{
|
||||
$household = new Household();
|
||||
@@ -43,34 +32,57 @@ 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 [
|
||||
$household,
|
||||
$household,
|
||||
[
|
||||
'{{ start }}' => '01-06-2010',
|
||||
'{{ end }}' => '01-07-2010'
|
||||
]
|
||||
'{{ start }}' => '01-06-2010',
|
||||
'{{ end }}' => '01-07-2010',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidHousehold
|
||||
*
|
||||
* @param mixed $parameters
|
||||
*/
|
||||
public function testHouseholdInvalid(Household $household, $parameters)
|
||||
{
|
||||
$constraint = $this->getConstraint();
|
||||
|
||||
$this->validator->validate($household, $constraint);
|
||||
|
||||
$this->buildViolation('msg')
|
||||
->setParameters($parameters)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
protected function createValidator()
|
||||
{
|
||||
return new MaxHolderValidator();
|
||||
}
|
||||
|
||||
protected function getConstraint()
|
||||
{
|
||||
return new MaxHolder([
|
||||
'message' => 'msg',
|
||||
'messageInfinity' => 'msgInfinity',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user