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

@@ -13,11 +13,8 @@ namespace Chill\PersonBundle\Tests\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use DateTime;
use Doctrine\Common\Collections\Criteria;
use LogicalException;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use function array_key_exists;
/**
* Test the creation or deletion of accompanying periods.
@@ -26,6 +23,7 @@ use function array_key_exists;
* closed) starting the 2015-01-05.
*
* @internal
*
* @coversNothing
*/
final class AccompanyingPeriodControllerTest extends WebTestCase
@@ -74,7 +72,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
$center = self::$em->getRepository(\Chill\MainBundle\Entity\Center::class)
->findOneBy(['name' => 'Center A']);
$this->person = (new Person(new DateTime('2015-01-05')))
$this->person = (new Person(new \DateTime('2015-01-05')))
->setFirstName('Roland')
->setLastName('Gallorime')
->setCenter($center)
@@ -108,7 +106,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
public function testAddNewPeriodBeforeActual()
{
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton('Créer une période d\'accompagnement')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -122,7 +120,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
$this->assertTrue(
$this->client->getResponse()->isRedirect(
'/fr/person/' . $this->person->getId() . '/accompanying-period'
'/fr/person/'.$this->person->getId().'/accompanying-period'
),
'the server redirects to /accompanying-period page'
);
@@ -149,20 +147,20 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
public function testClosingCurrentPeriod()
{
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/close');
.$this->person->getId().'/accompanying-period/close');
$form = $crawler->selectButton('Clôre la période')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
->setValue($this->getLastValueOnClosingMotive($form));
$form->get(self::CLOSING_INPUT)
->setValue((new DateTime('2015-02-01'))->format('d-m-Y'));
->setValue((new \DateTime('2015-02-01'))->format('d-m-Y'));
$cr = $this->client->submit($form);
$this->assertTrue(
$this->client->getResponse()->isRedirect(
'/fr/person/' . $this->person->getId() . '/accompanying-period'
'/fr/person/'.$this->person->getId().'/accompanying-period'
),
'the server redirects to /accompanying-period page'
);
@@ -189,14 +187,14 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
public function testClosingCurrentPeriodWithDateClosingBeforeOpeningFails()
{
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/close');
.$this->person->getId().'/accompanying-period/close');
$form = $crawler->selectButton('Clôre la période')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
->setValue($this->getLastValueOnClosingMotive($form));
$form->get(self::CLOSING_INPUT)
->setValue((new DateTime('2014-01-01'))->format('d-m-Y'));
->setValue((new \DateTime('2014-01-01'))->format('d-m-Y'));
$crawlerResponse = $this->client->submit($form);
@@ -236,7 +234,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
]);
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton('Créer une période d\'accompagnement')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -272,11 +270,11 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
*/
public function testCreatePeriodWithClosingAfterCurrentFails(): never
{
$this->markTestSkipped('Multiple period may now cover. This test is kept ' .
$this->markTestSkipped('Multiple period may now cover. This test is kept '.
'in case of a configuration may add this feature again');
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton("Créer une période d'accompagnement")->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -312,7 +310,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
public function testCreatePeriodWithClosingBeforeOpeningFails()
{
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton('Créer une période d\'accompagnement')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -358,7 +356,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
]);
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton('Créer une période d\'accompagnement')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -404,7 +402,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
]);
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton('Créer une période d\'accompagnement')->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -440,11 +438,11 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
*/
public function testCreatePeriodWithOpeningAndClosingAfterCurrentFails(): never
{
$this->markTestSkipped('Multiple period may now cover. This test is kept ' .
$this->markTestSkipped('Multiple period may now cover. This test is kept '.
'in case of a configuration may add this feature again');
$crawler = $this->client->request('GET', '/fr/person/'
. $this->person->getId() . '/accompanying-period/create');
.$this->person->getId().'/accompanying-period/create');
$form = $crawler->selectButton("Créer une période d'accompagnement")->form();
$form->get(self::CLOSING_MOTIVE_INPUT)
@@ -489,7 +487,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
// close the current period
$period = $this->person->getOpenedAccompanyingPeriod();
$period->setClosingDate(new DateTime('2015-02-05'));
$period->setClosingDate(new \DateTime('2015-02-05'));
$this->person->close($period);
$this->generatePeriods([
@@ -503,7 +501,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
$periods = $this->person->getAccompanyingPeriodsOrdered();
/** @var Criteria $criteria */
$criteria = Criteria::create();
//$criteria->where(Criteria::expr()->eq('openingDate', \DateTime::createFromFormat()))
// $criteria->where(Criteria::expr()->eq('openingDate', \DateTime::createFromFormat()))
$firstPeriod = reset($periods);
$lastPeriod = end($periods);
@@ -546,15 +544,14 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
protected function generatePeriods(array $periods)
{
foreach ($periods as $periodDef) {
$period = new AccompanyingPeriod(new DateTime($periodDef['openingDate']));
$period = new AccompanyingPeriod(new \DateTime($periodDef['openingDate']));
if (array_key_exists('closingDate', $periodDef)) {
if (!array_key_exists('closingMotive', $periodDef)) {
throw new LogicalException('you must define a closing '
. 'motive into your periods fixtures');
if (\array_key_exists('closingDate', $periodDef)) {
if (!\array_key_exists('closingMotive', $periodDef)) {
throw new \LogicalException('you must define a closing motive into your periods fixtures');
}
$period->setClosingDate(new DateTime($periodDef['closingDate']))
$period->setClosingDate(new \DateTime($periodDef['closingDate']))
->setClosingMotive($periodDef['closingMotive']);
}
@@ -571,7 +568,7 @@ final class AccompanyingPeriodControllerTest extends WebTestCase
* @var \Symfony\Component\DomCrawler\Form The form
*
* @return Chill\PersonBundle\Entity\AccompanyingPeriod The last value of closing
* motive
* motive
*/
protected function getLastValueOnClosingMotive(\Symfony\Component\DomCrawler\Form $form)
{