apply more cs rules for php-cs

This commit is contained in:
2023-10-17 13:27:03 +02:00
parent 0b0cbed9db
commit bc2041cbdd
1485 changed files with 8169 additions and 9620 deletions

View File

@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
class AccompanyingPeriodWorkTest extends TestCase
@@ -58,7 +59,6 @@ class AccompanyingPeriodWorkTest extends TestCase
public function testReferrerHistoryOnDifferentDays(): void
{
$work = new AccompanyingPeriodWork();
$userA = new User();
$userB = new User();

View File

@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class ResourceTest extends TestCase

View File

@@ -11,7 +11,6 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Tests\Entity;
use ArrayIterator;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
@@ -19,12 +18,10 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Person;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTime;
use DateTimeInterface;
use function count;
/**
* @internal
*
* @coversNothing
*/
final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
@@ -44,12 +41,12 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals(AccompanyingPeriod::STEP_CONFIRMED, $period->getStepHistories()->first()->getStep());
$period->setOpeningDate($aMonthAgo = new DateTime('1 month ago'));
$period->setOpeningDate($aMonthAgo = new \DateTime('1 month ago'));
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals($aMonthAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
$period->setOpeningDate($tenDaysAgo = new DateTime('10 days ago'));
$period->setOpeningDate($tenDaysAgo = new \DateTime('10 days ago'));
$this->assertCount(1, $period->getStepHistories());
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date, the start date of the first history should change');
@@ -57,13 +54,13 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$period->setStep(AccompanyingPeriod::STEP_CLOSED);
$this->assertCount(2, $period->getStepHistories());
$period->setOpeningDate($tomorrow = new DateTime('tomorrow'));
$period->setOpeningDate($tomorrow = new \DateTime('tomorrow'));
$this->assertEquals($tenDaysAgo, $period->getStepHistories()->first()->getStartDate(), 'when changing the opening date to a later one and no history after, start date should change');
}
public function testClosingEqualOpening()
{
$datetime = new DateTime('now');
$datetime = new \DateTime('now');
$period = new AccompanyingPeriod($datetime);
$period->setClosingDate($datetime);
@@ -73,8 +70,8 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
public function testClosingIsAfterOpeningConsistency()
{
$datetime1 = new DateTime('now');
$datetime2 = new DateTime('tomorrow');
$datetime1 = new \DateTime('now');
$datetime2 = new \DateTime('tomorrow');
$period = new AccompanyingPeriod($datetime1);
$period->setClosingDate($datetime2);
@@ -86,8 +83,8 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
public function testClosingIsBeforeOpeningConsistency()
{
$datetime1 = new DateTime('tomorrow');
$datetime2 = new DateTime('now');
$datetime1 = new \DateTime('tomorrow');
$datetime2 = new \DateTime('now');
$period = new AccompanyingPeriod($datetime1);
$period->setClosingDate($datetime2);
@@ -156,7 +153,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
usort($locations, static fn (AccompanyingPeriod\AccompanyingPeriodLocationHistory $a, AccompanyingPeriod\AccompanyingPeriodLocationHistory $b) => $a->getStartDate() <=> $b->getStartDate());
$iterator = new ArrayIterator($locations);
$iterator = new \ArrayIterator($locations);
$iterator->rewind();
do {
@@ -174,7 +171,6 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
} while ($iterator->valid());
}
public function testHistoryLocationNotHavingBothAtStart()
{
$period = new AccompanyingPeriod();
@@ -197,15 +193,15 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
public function testIsClosed()
{
$period = new AccompanyingPeriod(new DateTime());
$period->setClosingDate(new DateTime('tomorrow'));
$period = new AccompanyingPeriod(new \DateTime());
$period->setClosingDate(new \DateTime('tomorrow'));
$this->assertFalse($period->isOpen());
}
public function testIsOpen()
{
$period = new AccompanyingPeriod(new DateTime());
$period = new AccompanyingPeriod(new \DateTime());
$this->assertTrue($period->isOpen());
}
@@ -215,7 +211,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$person = new Person();
$person2 = new Person();
$person3 = new Person();
$period = new AccompanyingPeriod(new DateTime());
$period = new AccompanyingPeriod(new \DateTime());
$participation0 = $period->createParticipationFor($person);
$period->createParticipationFor($person2);
@@ -238,7 +234,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
if ($participationL instanceof AccompanyingPeriodParticipation) {
$this->assertSame($participationL, $participation);
$this->assertTrue($participationL->getEndDate() instanceof DateTimeInterface);
$this->assertTrue($participationL->getEndDate() instanceof \DateTimeInterface);
}
$participation = $period->getOpenParticipationContainsPerson($person);
@@ -260,7 +256,7 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
public function testPinnedComment()
{
$period = new AccompanyingPeriod(new DateTime());
$period = new AccompanyingPeriod(new \DateTime());
$comment = new Comment();
$replacingComment = new Comment();
@@ -271,14 +267,14 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertSame($period->getPinnedComment(), $comment);
$this->assertNull($comment->getAccompanyingPeriod());
$this->assertEquals(0, count($period->getComments()));
$this->assertEquals(0, \count($period->getComments()));
$period->setPinnedComment($replacingComment);
$this->assertSame($period->getPinnedComment(), $replacingComment);
$this->assertNull($replacingComment->getAccompanyingPeriod());
$this->assertSame($period, $comment->getAccompanyingPeriod());
$this->assertEquals(1, count($period->getComments()));
$this->assertEquals(1, \count($period->getComments()));
$this->assertContains($comment, $period->getComments());
$period->setPinnedComment(null);
@@ -286,14 +282,14 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertNull($period->getPinnedComment());
$this->assertSame($period, $comment->getAccompanyingPeriod());
$this->assertSame($period, $replacingComment->getAccompanyingPeriod());
$this->assertEquals(2, count($period->getComments()));
$this->assertEquals(2, \count($period->getComments()));
$this->assertContains($comment, $period->getComments());
$this->assertContains($replacingComment, $period->getComments());
}
public function testRequestor()
{
$period = new AccompanyingPeriod(new DateTime());
$period = new AccompanyingPeriod(new \DateTime());
$person = new Person();
$thirdParty = new ThirdParty();

View File

@@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class HouseholdMemberTest extends TestCase

View File

@@ -16,12 +16,11 @@ use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\HouseholdComposition;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class HouseholdTest extends TestCase
@@ -31,38 +30,38 @@ final class HouseholdTest extends TestCase
$household = new Household();
$household->addMember($householdMemberA = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2020-01-01'))
->setEndDate(new DateTimeImmutable('2020-12-31'))
->setStartDate(new \DateTimeImmutable('2020-01-01'))
->setEndDate(new \DateTimeImmutable('2020-12-31'))
->setPerson(new Person()));
$household->addMember($householdMemberB = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2020-06-01'))
->setEndDate(new DateTimeImmutable('2021-06-31'))
->setStartDate(new \DateTimeImmutable('2020-06-01'))
->setEndDate(new \DateTimeImmutable('2021-06-31'))
->setPerson(new Person()));
$household->addMember($householdMemberC = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2021-01-01'))
->setStartDate(new \DateTimeImmutable('2021-01-01'))
->setEndDate(null)
->setPerson(new Person()));
$members = $household->getMembersOnRange(new DateTimeImmutable('2019-01-01'), null);
$members = $household->getMembersOnRange(new \DateTimeImmutable('2019-01-01'), null);
$this->assertCount(3, $members);
$this->assertContains($householdMemberA, $members);
$this->assertContains($householdMemberB, $members);
$this->assertContains($householdMemberC, $members);
$members = $household->getMembersOnRange(new DateTimeImmutable('2020-01-01'), new DateTimeImmutable('2020-07-01'));
$members = $household->getMembersOnRange(new \DateTimeImmutable('2020-01-01'), new \DateTimeImmutable('2020-07-01'));
$this->assertCount(2, $members);
$this->assertContains($householdMemberA, $members);
$this->assertContains($householdMemberB, $members);
$this->assertNotContains($householdMemberC, $members);
$members = $household->getMembersOnRange(new DateTimeImmutable('2020-01-01'), new DateTimeImmutable('2022-12-31'));
$members = $household->getMembersOnRange(new \DateTimeImmutable('2020-01-01'), new \DateTimeImmutable('2022-12-31'));
$this->assertCount(3, $members);
$this->assertContains($householdMemberA, $members);
$this->assertContains($householdMemberB, $members);
$this->assertContains($householdMemberC, $members);
$members = $household->getMembersOnRange(new DateTimeImmutable('2021-01-01'), new DateTimeImmutable('2022-12-31'));
$members = $household->getMembersOnRange(new \DateTimeImmutable('2021-01-01'), new \DateTimeImmutable('2022-12-31'));
$this->assertCount(2, $members);
$this->assertNotContains($householdMemberA, $members);
$this->assertContains($householdMemberB, $members);
@@ -74,16 +73,16 @@ final class HouseholdTest extends TestCase
$household = new Household();
$lastAddress = new Address();
$lastAddress->setValidFrom($yesterday = new DateTime('yesterday'));
$lastAddress->setValidTo(new DateTime('tomorrow'));
$lastAddress->setValidFrom($yesterday = new \DateTime('yesterday'));
$lastAddress->setValidTo(new \DateTime('tomorrow'));
$household->addAddress($lastAddress);
$this->assertNull($lastAddress->getValidTo());
$this->assertEquals($yesterday, $lastAddress->getValidFrom());
$previousAddress = new Address();
$previousAddress->setValidFrom($oneMonthAgo = new DateTime('1 month ago'));
$previousAddress->setValidTo(new DateTime('now'));
$previousAddress->setValidFrom($oneMonthAgo = new \DateTime('1 month ago'));
$previousAddress->setValidTo(new \DateTime('now'));
$household->addAddress($previousAddress);
$addresses = $household->getAddressesOrdered();
@@ -96,8 +95,8 @@ final class HouseholdTest extends TestCase
$this->assertNull($lastAddress->getValidTo());
$futureAddress = new Address();
$futureAddress->setValidFrom($tomorrow = new DateTime('tomorrow'));
$futureAddress->setValidTo(new DateTime('2150-01-01'));
$futureAddress->setValidFrom($tomorrow = new \DateTime('tomorrow'));
$futureAddress->setValidTo(new \DateTime('2150-01-01'));
$household->addAddress($futureAddress);
$addresses = $household->getAddressesOrdered();
@@ -118,22 +117,22 @@ final class HouseholdTest extends TestCase
$household = new Household();
$household->addComposition(($first = new HouseholdComposition())
->setStartDate(new DateTimeImmutable('2021-12-01')));
->setStartDate(new \DateTimeImmutable('2021-12-01')));
$this->assertNull($first->getEndDate());
$household->addComposition(($second = new HouseholdComposition())
->setStartDate(new DateTimeImmutable('2021-12-31')));
->setStartDate(new \DateTimeImmutable('2021-12-31')));
$this->assertEquals(new DateTimeImmutable('2021-12-31'), $first->getEndDate());
$this->assertEquals(new DateTimeImmutable('2021-12-31'), $second->getStartDate());
$this->assertEquals(new \DateTimeImmutable('2021-12-31'), $first->getEndDate());
$this->assertEquals(new \DateTimeImmutable('2021-12-31'), $second->getStartDate());
$household->addComposition(($inside = new HouseholdComposition())
->setStartDate(new DateTimeImmutable('2021-12-15')));
->setStartDate(new \DateTimeImmutable('2021-12-15')));
$this->assertEquals(new DateTimeImmutable('2021-12-15'), $first->getEndDate());
$this->assertEquals(new DateTimeImmutable('2021-12-31'), $second->getStartDate());
$this->assertEquals(new DateTimeImmutable('2021-12-31'), $inside->getEndDate());
$this->assertEquals(new \DateTimeImmutable('2021-12-15'), $first->getEndDate());
$this->assertEquals(new \DateTimeImmutable('2021-12-31'), $second->getStartDate());
$this->assertEquals(new \DateTimeImmutable('2021-12-31'), $inside->getEndDate());
}
public function testHouseholdGetPersonsDuringMembership()
@@ -145,29 +144,29 @@ final class HouseholdTest extends TestCase
$household->addMember(
$member1 = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2021-01-01'))
->setEndDate(new DateTimeImmutable('2021-12-01'))
->setStartDate(new \DateTimeImmutable('2021-01-01'))
->setEndDate(new \DateTimeImmutable('2021-12-01'))
->setPerson($person1)
);
$household->addMember(
$member2a = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2021-01-01'))
->setEndDate(new DateTimeImmutable('2021-05-01'))
->setStartDate(new \DateTimeImmutable('2021-01-01'))
->setEndDate(new \DateTimeImmutable('2021-05-01'))
->setPerson($person2)
);
$household->addMember(
$member2b = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2021-11-01'))
->setEndDate(new DateTimeImmutable('2022-06-01'))
->setStartDate(new \DateTimeImmutable('2021-11-01'))
->setEndDate(new \DateTimeImmutable('2022-06-01'))
->setPerson($person2)
);
$household->addMember(
$memberOut = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('2019-01-01'))
->setEndDate(new DateTimeImmutable('2019-12-01'))
->setStartDate(new \DateTimeImmutable('2019-01-01'))
->setEndDate(new \DateTimeImmutable('2019-12-01'))
->setPerson($personOut)
);

View File

@@ -17,13 +17,12 @@ use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\HouseholdMember;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use DateTimeImmutable;
/**
* Unit tests for the person Entity.
*
* @internal
*
* @coversNothing
*/
final class PersonTest extends \PHPUnit\Framework\TestCase
@@ -34,18 +33,18 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testAccompanyingPeriodOrderSameDateOpening()
{
$d = new DateTime('2013/2/1');
$d = new \DateTime('2013/2/1');
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$g = new DateTime('2013/4/1');
$g = new \DateTime('2013/4/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period);
$f = new DateTime('2013/2/1');
$f = new \DateTime('2013/2/1');
$p->open(new AccompanyingPeriod($f));
$e = new DateTime('2013/3/1');
$e = new \DateTime('2013/3/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period);
@@ -62,18 +61,18 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
{
$d = new DateTime('2013/2/1');
$d = new \DateTime('2013/2/1');
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new DateTime('2013/3/1');
$e = new \DateTime('2013/3/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period);
$f = new DateTime('2013/1/1');
$f = new \DateTime('2013/1/1');
$p->open(new AccompanyingPeriod($f));
$g = new DateTime('2013/4/1');
$g = new \DateTime('2013/4/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period);
@@ -91,18 +90,18 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testDateCoveringWithCoveringAccompanyingPeriod()
{
$d = new DateTime('2013/2/1');
$d = new \DateTime('2013/2/1');
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new DateTime('2013/3/1');
$e = new \DateTime('2013/3/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period);
$f = new DateTime('2013/1/1');
$f = new \DateTime('2013/1/1');
$p->open(new AccompanyingPeriod($f));
$g = new DateTime('2013/4/1');
$g = new \DateTime('2013/4/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
$p->close($period);
@@ -118,7 +117,7 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testGetCurrentAccompanyingPeriod()
{
$d = new DateTime('yesterday');
$d = new \DateTime('yesterday');
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
@@ -128,8 +127,8 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
$this->assertTrue($period->isOpen());
$this->assertEquals($d, $period->getOpeningDate());
//close and test
$period->setClosingDate(new DateTime('tomorrow'));
// close and test
$period->setClosingDate(new \DateTime('tomorrow'));
$shouldBeNull = $p->getCurrentAccompanyingPeriod();
$this->assertNull($shouldBeNull);
@@ -145,15 +144,15 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
->setShareHousehold(false);
$membership1 = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('10 years ago'))
->setEndDate(new DateTimeImmutable('5 years ago'))
->setStartDate(new \DateTimeImmutable('10 years ago'))
->setEndDate(new \DateTimeImmutable('5 years ago'))
->setPerson($person)
->setPosition($positionShare);
$household->addMember($membership1);
$membership2 = (new HouseholdMember())
->setStartDate(new DateTimeImmutable('4 years ago'))
->setEndDate(new DateTimeImmutable('2 years ago'))
->setStartDate(new \DateTimeImmutable('4 years ago'))
->setEndDate(new \DateTimeImmutable('2 years ago'))
->setPerson($person)
->setPosition($positionNotShare);
$household->addMember($membership2);
@@ -163,10 +162,10 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
$this->assertFalse($person->isSharingHousehold());
$this->assertTrue($person->isSharingHousehold(
new DateTimeImmutable('6 years ago')
new \DateTimeImmutable('6 years ago')
));
$this->assertFalse($person->isSharingHousehold(
new DateTimeImmutable('3 years ago')
new \DateTimeImmutable('3 years ago')
));
}
@@ -177,15 +176,15 @@ final class PersonTest extends \PHPUnit\Framework\TestCase
*/
public function testNotOpenAFileReOpenedLater()
{
$d = new DateTime('2013/2/1');
$d = new \DateTime('2013/2/1');
$p = new Person();
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
$e = new DateTime('2013/3/1');
$e = new \DateTime('2013/3/1');
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
$p->close($period);
$f = new DateTime('2013/1/1');
$f = new \DateTime('2013/1/1');
$p->open(new AccompanyingPeriod($f));
$r = $p->checkAccompanyingPeriodsAreNotCollapsing();

View File

@@ -16,6 +16,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class SocialActionTest extends TestCase

View File

@@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class SocialIssueTest extends TestCase