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,16 +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 Chill\PersonBundle\Tests\Household;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Household\MembersEditorFactory;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Validator\Validator\ValidatorInterface;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* @internal
* @coversNothing
*/
class MembersEditorTest extends TestCase
{
private MembersEditorFactory $factory;
@@ -22,61 +32,20 @@ class MembersEditorTest extends TestCase
$this->factory = new MembersEditorFactory($validator);
}
public function testMovePersonWithSharedHousehold()
{
$person = new Person();
$position = (new Position())
->setShareHousehold(true)
;
$household1 = new Household();
$household2 = new Household();
$editor = $this->factory->createEditor($household1);
$editor->addMovement(
\DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01'),
$person,
$position);
$persistables = $editor->getPersistable();
$this->assertEquals(\count($persistables), 1);
$membership1 = $persistables[0];
$this->assertSame($household1, $membership1->getHousehold());
$this->assertNull($membership1->getEndDate());
// move to another household
$date = \DateTimeImmutable::createFromFormat('Y-m-d', '2021-01-01');
$editor = $this->factory->createEditor($household2);
$editor->addMovement(
$date,
$person,
$position);
$persistables = $editor->getPersistable();
$this->assertEquals(1, count($persistables));
$membership2 = $persistables[0];
$this->assertSame($household2, $membership2->getHousehold());
$this->assertNull($membership2->getEndDate());
$this->assertNotNull($membership1->getEndDate(),
"assert that the membership1 is closed");
$this->assertEquals($date, $membership1->getEndDate());
}
public function testMovePersonWithoutSharedHousehold()
{
$person = new Person();
$position = (new Position())
->setShareHousehold(false)
;
->setShareHousehold(false);
$household1 = new Household();
$household2 = new Household();
$editor = $this->factory->createEditor($household1);
$editor->addMovement(
\DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01'),
DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01'),
$person,
$position);
$position
);
$persistables = $editor->getPersistable();
$this->assertEquals(1, count($persistables));
@@ -86,12 +55,13 @@ class MembersEditorTest extends TestCase
$this->assertNull($membership1->getEndDate());
// move to another household
$date = \DateTimeImmutable::createFromFormat('Y-m-d', '2021-01-01');
$date = DateTimeImmutable::createFromFormat('Y-m-d', '2021-01-01');
$editor = $this->factory->createEditor($household2);
$editor->addMovement(
$date,
$person,
$position);
$position
);
$persistables = $editor->getPersistable();
$this->assertEquals(1, count($persistables));
@@ -99,7 +69,53 @@ class MembersEditorTest extends TestCase
$membership2 = $person->getHouseholdParticipations()->last();
$this->assertNull($membership2->getEndDate());
$this->assertSame($household2, $membership2->getHousehold());
$this->assertNull($membership1->getEndDate(),
"assert that the membership1 is not closed");
$this->assertNull(
$membership1->getEndDate(),
'assert that the membership1 is not closed'
);
}
public function testMovePersonWithSharedHousehold()
{
$person = new Person();
$position = (new Position())
->setShareHousehold(true);
$household1 = new Household();
$household2 = new Household();
$editor = $this->factory->createEditor($household1);
$editor->addMovement(
DateTimeImmutable::createFromFormat('Y-m-d', '2020-01-01'),
$person,
$position
);
$persistables = $editor->getPersistable();
$this->assertEquals(\count($persistables), 1);
$membership1 = $persistables[0];
$this->assertSame($household1, $membership1->getHousehold());
$this->assertNull($membership1->getEndDate());
// move to another household
$date = DateTimeImmutable::createFromFormat('Y-m-d', '2021-01-01');
$editor = $this->factory->createEditor($household2);
$editor->addMovement(
$date,
$person,
$position
);
$persistables = $editor->getPersistable();
$this->assertEquals(1, count($persistables));
$membership2 = $persistables[0];
$this->assertSame($household2, $membership2->getHousehold());
$this->assertNull($membership2->getEndDate());
$this->assertNotNull(
$membership1->getEndDate(),
'assert that the membership1 is closed'
);
$this->assertEquals($date, $membership1->getEndDate());
}
}