mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class EventControllerTest extends WebTestCase
|
||||
|
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class EventTypeControllerTest extends WebTestCase
|
||||
|
@@ -13,12 +13,12 @@ namespace Chill\EventBundle\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use function count;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Test the creation of participation controller.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ParticipationControllerTest extends WebTestCase
|
||||
@@ -83,7 +83,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
400,
|
||||
$this->client->getResponse()->getStatusCode(),
|
||||
'Test that /fr/event/participation/create fail if '
|
||||
. 'both person_id and persons_ids are missing'
|
||||
.'both person_id and persons_ids are missing'
|
||||
);
|
||||
|
||||
// having both person_id and persons_ids
|
||||
@@ -103,7 +103,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
400,
|
||||
$this->client->getResponse()->getStatusCode(),
|
||||
'test that /fr/event/participation/create fail if both person_id and '
|
||||
. 'persons_ids are set'
|
||||
.'persons_ids are set'
|
||||
);
|
||||
|
||||
// missing event_id
|
||||
@@ -141,7 +141,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
/** @var \Chill\EventBundle\Entity\Event $event */
|
||||
$event = $this->getRandomEventWithMultipleParticipations();
|
||||
|
||||
$crawler = $this->client->request('GET', '/fr/event/participation/' . $event->getId() .
|
||||
$crawler = $this->client->request('GET', '/fr/event/participation/'.$event->getId().
|
||||
'/edit_multiple');
|
||||
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||
@@ -157,7 +157,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
]);
|
||||
|
||||
$this->assertTrue($this->client->getResponse()
|
||||
->isRedirect('/fr/event/event/' . $event->getId() . '/show'));
|
||||
->isRedirect('/fr/event/event/'.$event->getId().'/show'));
|
||||
}
|
||||
|
||||
public function testNewActionWrongParameters()
|
||||
@@ -177,7 +177,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
400,
|
||||
$this->client->getResponse()->getStatusCode(),
|
||||
'Test that /fr/event/participation/new fail if '
|
||||
. 'both person_id and persons_ids are missing'
|
||||
.'both person_id and persons_ids are missing'
|
||||
);
|
||||
|
||||
// having both person_id and persons_ids
|
||||
@@ -197,7 +197,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
400,
|
||||
$this->client->getResponse()->getStatusCode(),
|
||||
'test that /fr/event/participation/new fail if both person_id and '
|
||||
. 'persons_ids are set'
|
||||
.'persons_ids are set'
|
||||
);
|
||||
|
||||
// missing event_id
|
||||
@@ -285,11 +285,11 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$crawler = $this->client->followRedirect();
|
||||
|
||||
$span1 = $crawler->filter('table td span.entity-person a:contains("'
|
||||
. $person1->getFirstName() . '"):contains("' . $person1->getLastname() . '")');
|
||||
$this->assertGreaterThan(0, count($span1));
|
||||
.$person1->getFirstName().'"):contains("'.$person1->getLastname().'")');
|
||||
$this->assertGreaterThan(0, \count($span1));
|
||||
$span2 = $crawler->filter('table td span.entity-person a:contains("'
|
||||
. $person2->getFirstName() . '"):contains("' . $person2->getLastname() . '")');
|
||||
$this->assertGreaterThan(0, count($span2));
|
||||
.$person2->getFirstName().'"):contains("'.$person2->getLastname().'")');
|
||||
$this->assertGreaterThan(0, \count($span2));
|
||||
|
||||
// as the container has reloaded, reload the event
|
||||
$event = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)->find($event->getId());
|
||||
@@ -338,10 +338,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$newPerson = $this->getRandomPerson();
|
||||
|
||||
// build the `persons_ids` parameter
|
||||
$persons_ids_string = implode(',', array_merge(
|
||||
$persons_id,
|
||||
[$newPerson->getId()]
|
||||
));
|
||||
$persons_ids_string = implode(',', [...$persons_id, $newPerson->getId()]);
|
||||
|
||||
$crawler = $this->client->request(
|
||||
'GET',
|
||||
@@ -360,8 +357,8 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
|
||||
// count that the one UL contains the new person string
|
||||
$firstPerson = $event->getParticipations()->first()->getPerson();
|
||||
$ul = $crawler->filter('ul:contains("' . $firstPerson->getLastName() . '")'
|
||||
. ':contains("' . $firstPerson->getFirstName() . '")');
|
||||
$ul = $crawler->filter('ul:contains("'.$firstPerson->getLastName().'")'
|
||||
.':contains("'.$firstPerson->getFirstName().'")');
|
||||
|
||||
$this->assertEquals(
|
||||
1,
|
||||
@@ -434,9 +431,9 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$crawler = $this->client->followRedirect();
|
||||
|
||||
$span = $crawler->filter('table td span.entity-person a:contains("'
|
||||
. $person->getFirstName() . '"):contains("' . $person->getLastname() . '")');
|
||||
.$person->getFirstName().'"):contains("'.$person->getLastname().'")');
|
||||
|
||||
$this->assertGreaterThan(0, count($span));
|
||||
$this->assertGreaterThan(0, \count($span));
|
||||
|
||||
// as the container has reloaded, reload the event
|
||||
$event = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)->find($event->getId());
|
||||
@@ -446,7 +443,6 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return \Chill\EventBundle\Entity\Event
|
||||
*/
|
||||
protected function getRandomEvent(mixed $centerName = 'Center A', mixed $circleName = 'social')
|
||||
@@ -456,7 +452,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
|
||||
$circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
|
||||
->findAll();
|
||||
array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true));
|
||||
array_filter($circles, static fn ($circle) => \in_array($circleName, $circle->getName(), true));
|
||||
$circle = $circles[0];
|
||||
|
||||
$events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)
|
||||
@@ -469,7 +465,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
* Return a random event only if he has more than one participation.
|
||||
*
|
||||
* @param string $centerName
|
||||
* @param type $circleName
|
||||
* @param type $circleName
|
||||
*
|
||||
* @return \Chill\EventBundle\Entity\Event
|
||||
*/
|
||||
@@ -507,7 +503,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
|
||||
$person = $persons[array_rand($persons)];
|
||||
|
||||
if (in_array($person->getId(), $this->personsIdsCache, true)) {
|
||||
if (\in_array($person->getId(), $this->personsIdsCache, true)) {
|
||||
return $this->getRandomPerson($centerName); // we try another time
|
||||
}
|
||||
$this->personsIdsCache[] = $person->getId();
|
||||
|
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class RoleControllerTest extends WebTestCase
|
||||
|
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class StatusControllerTest extends WebTestCase
|
||||
|
@@ -15,12 +15,12 @@ use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Search\EventSearch;
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Test the EventSearch class.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class EventSearchTest extends WebTestCase
|
||||
@@ -150,9 +150,9 @@ final class EventSearchTest extends WebTestCase
|
||||
'q' => '@events date-from:2016-05-30 date-to:2016-06-20',
|
||||
]);
|
||||
|
||||
/** @var DateTime $dateFrom the date from in DateTime */
|
||||
$dateFrom = DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
$dateTo = DateTime::createFromFormat('Y-m-d', '2016-06-20');
|
||||
/** @var \DateTime $dateFrom the date from in DateTime */
|
||||
$dateFrom = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
$dateTo = \DateTime::createFromFormat('Y-m-d', '2016-06-20');
|
||||
|
||||
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
|
||||
|
||||
@@ -164,7 +164,7 @@ final class EventSearchTest extends WebTestCase
|
||||
// there should not have any other results, but if any other bundle
|
||||
// add some other event, we go on next pages
|
||||
|
||||
if ($crawler->selectLink('Voir tous les résultats')->count() === 0) {
|
||||
if (0 === $crawler->selectLink('Voir tous les résultats')->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ final class EventSearchTest extends WebTestCase
|
||||
$this->assertLessThanOrEqual($dateTo, $date);
|
||||
}
|
||||
|
||||
//iterate on pagination
|
||||
// iterate on pagination
|
||||
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) use ($dateFrom) {
|
||||
$page = $this->client->click($a->link());
|
||||
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
|
||||
@@ -196,8 +196,8 @@ final class EventSearchTest extends WebTestCase
|
||||
$crawler = $this->client->request('GET', '/fr/search', [
|
||||
'q' => '@events date-from:2016-05-30',
|
||||
]);
|
||||
/** @var DateTime $dateFrom the date from in DateTime */
|
||||
$dateFrom = DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
/** @var \DateTime $dateFrom the date from in DateTime */
|
||||
$dateFrom = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
|
||||
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
|
||||
|
||||
@@ -214,7 +214,7 @@ final class EventSearchTest extends WebTestCase
|
||||
$this->assertGreaterThanOrEqual($dateFrom, $date);
|
||||
}
|
||||
|
||||
//iterate on pagination
|
||||
// iterate on pagination
|
||||
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) use ($dateFrom) {
|
||||
$page = $this->client->click($a->link());
|
||||
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
|
||||
@@ -232,8 +232,8 @@ final class EventSearchTest extends WebTestCase
|
||||
'q' => '@events date:2016-05-30',
|
||||
]);
|
||||
|
||||
/** @var DateTime $dateFrom the date from in DateTime */
|
||||
$dateTo = DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
/** @var \DateTime $dateFrom the date from in DateTime */
|
||||
$dateTo = \DateTime::createFromFormat('Y-m-d', '2016-05-30');
|
||||
|
||||
$dates = $this->iterateOnRowsToFindDate($crawler->filter('tr'));
|
||||
|
||||
@@ -241,7 +241,7 @@ final class EventSearchTest extends WebTestCase
|
||||
$this->assertLessThanOrEqual($dateTo, $date);
|
||||
}
|
||||
|
||||
if ($crawler->selectLink('Voir tous les résultats')->count() === 0) {
|
||||
if (0 === $crawler->selectLink('Voir tous les résultats')->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ final class EventSearchTest extends WebTestCase
|
||||
$this->assertLessThanOrEqual($dateTo, $date);
|
||||
}
|
||||
|
||||
//iterate on pagination
|
||||
// iterate on pagination
|
||||
$crawlerAllResults->filter('.pagination a')->each(function ($a, $i) {
|
||||
$page = $this->client->click($a->link());
|
||||
$dates = $this->iterateOnRowsToFindDate($page->filter('tr'));
|
||||
@@ -307,7 +307,7 @@ final class EventSearchTest extends WebTestCase
|
||||
{
|
||||
$event1 = (new Event())
|
||||
->setCenter($this->centerA)
|
||||
->setDate(new DateTime('2016-05-30'))
|
||||
->setDate(new \DateTime('2016-05-30'))
|
||||
->setName('Printemps européen')
|
||||
->setType($this->eventType)
|
||||
->setCircle($this->getCircle());
|
||||
@@ -316,7 +316,7 @@ final class EventSearchTest extends WebTestCase
|
||||
|
||||
$event2 = (new Event())
|
||||
->setCenter($this->centerA)
|
||||
->setDate(new DateTime('2016-06-24'))
|
||||
->setDate(new \DateTime('2016-06-24'))
|
||||
->setName('Hiver de la droite')
|
||||
->setType($this->eventType)
|
||||
->setCircle($this->getCircle());
|
||||
@@ -338,7 +338,7 @@ final class EventSearchTest extends WebTestCase
|
||||
|
||||
/** @var \Chill\MainBundle\Entity\Scope $circle */
|
||||
foreach ($circles as $circle) {
|
||||
if (in_array($name, $circle->getName(), true)) {
|
||||
if (\in_array($name, $circle->getName(), true)) {
|
||||
return $circle;
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ final class EventSearchTest extends WebTestCase
|
||||
* this function iterate on row from results of events and return the content
|
||||
* of the second column (which should contains the date) in DateTime objects.
|
||||
*
|
||||
* @return DateTime[]
|
||||
* @return \DateTime[]
|
||||
*/
|
||||
private function iterateOnRowsToFindDate(\Symfony\Component\DomCrawler\Crawler $trs)
|
||||
{
|
||||
@@ -375,8 +375,8 @@ final class EventSearchTest extends WebTestCase
|
||||
// transform the date, which should be in french, into a DateTime object
|
||||
$parts = explode(' ', (string) $tdDate->text());
|
||||
|
||||
return DateTime::createFromFormat('Y-m-d', $parts[2] .
|
||||
'-' . $months[$parts[1]] . '-' . $parts[0]);
|
||||
return \DateTime::createFromFormat('Y-m-d', $parts[2].
|
||||
'-'.$months[$parts[1]].'-'.$parts[0]);
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user