cs: Switch to a stricter way of coding - this might break in a lot of places.

This commit is contained in:
Pol Dellaiera
2021-11-30 13:33:18 +01:00
parent 28d2c42454
commit 47c5855a21
957 changed files with 9025 additions and 568 deletions

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Entity\Center;
@@ -35,7 +44,7 @@ use function json_encode;
* @internal
* @coversNothing
*/
class AccompanyingCourseApiControllerTest extends WebTestCase
final class AccompanyingCourseApiControllerTest extends WebTestCase
{
protected static EntityManagerInterface $em;
@@ -50,7 +59,7 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public static function setUpBeforeClass()
{
static::bootKernel();
self::bootKernel();
}
/**
@@ -58,7 +67,7 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function setUp()
{
$this->client = static::createClient([], [
$this->client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password',
]);
@@ -112,8 +121,8 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
$maxGenerated = 3;
$maxResults = $maxGenerated * 8;
static::bootKernel();
$em = static::$container->get(EntityManagerInterface::class);
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$center = $em->getRepository(Center::class)
->findOneBy(['name' => 'Center A']);
@@ -176,8 +185,8 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
$maxGenerated = 3;
$maxResults = $maxGenerated * 8;
static::bootKernel();
$em = static::$container->get(EntityManagerInterface::class);
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$center = $em->getRepository(Center::class)
->findOneBy(['name' => 'Center A']);
$qb = $em->createQueryBuilder();
@@ -237,8 +246,8 @@ class AccompanyingCourseApiControllerTest extends WebTestCase
$dataLength = 2;
$maxResults = 100;
static::bootKernel();
$em = static::$container->get(EntityManagerInterface::class);
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$center = $em->getRepository(Center::class)
->findOneBy(['name' => 'Center A']);
$qb = $em->createQueryBuilder();

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Entity\Center;
@@ -26,7 +35,7 @@ use function preg_match;
* @internal
* @coversNothing
*/
class AccompanyingCourseControllerTest extends WebTestCase
final class AccompanyingCourseControllerTest extends WebTestCase
{
use PrepareClientTrait;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
@@ -26,7 +35,7 @@ use function array_key_exists;
* @internal
* @coversNothing
*/
class AccompanyingPeriodControllerTest extends WebTestCase
final class AccompanyingPeriodControllerTest extends WebTestCase
{
public const CLOSING_INPUT = 'chill_personbundle_accompanyingperiod[closingDate]';
@@ -54,8 +63,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase
*/
public static function setUpBeforeClass()
{
static::bootKernel();
static::$em = static::$kernel->getContainer()
self::bootKernel();
self::$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
}
@@ -64,12 +73,12 @@ class AccompanyingPeriodControllerTest extends WebTestCase
*/
public function setUp()
{
$this->client = static::createClient([], [
$this->client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password',
]);
$center = static::$em->getRepository('ChillMainBundle:Center')
$center = self::$em->getRepository('ChillMainBundle:Center')
->findOneBy(['name' => 'Center A']);
$this->person = (new Person(new DateTime('2015-01-05')))
@@ -78,8 +87,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase
->setCenter($center)
->setGender(Person::MALE_GENDER);
static::$em->persist($this->person);
static::$em->flush();
self::$em->persist($this->person);
self::$em->flush();
}
/**
@@ -87,10 +96,10 @@ class AccompanyingPeriodControllerTest extends WebTestCase
*/
public function tearDown()
{
static::$em->refresh($this->person);
static::$em->remove($this->person);
self::$em->refresh($this->person);
self::$em->remove($this->person);
static::$em->flush();
self::$em->flush();
}
/**
@@ -557,10 +566,10 @@ class AccompanyingPeriodControllerTest extends WebTestCase
}
$this->person->addAccompanyingPeriod($period);
static::$em->persist($period);
self::$em->persist($period);
}
static::$em->flush();
self::$em->flush();
}
/**
@@ -586,7 +595,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
*/
protected function getRandomClosingMotive()
{
$motives = static::$em
$motives = self::$em
->getRepository('ChillPersonBundle:AccompanyingPeriod\ClosingMotive')
->findAll();

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Entity\Address;
@@ -30,7 +39,7 @@ use function shuffle;
* @internal
* @coversNothing
*/
class HouseholdApiControllerTest extends WebTestCase
final class HouseholdApiControllerTest extends WebTestCase
{
use PrepareClientTrait;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -24,7 +33,7 @@ use function shuffle;
* @internal
* @coversNothing
*/
class HouseholdControllerTest extends WebTestCase
final class HouseholdControllerTest extends WebTestCase
{
use PrepareClientTrait;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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 Bundle\ChillPersonBundle\Tests\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -32,7 +41,7 @@ use function shuffle;
* @internal
* @coversNothing
*/
class HouseholdMemberControllerTest extends WebTestCase
final class HouseholdMemberControllerTest extends WebTestCase
{
use PrepareClientTrait;
@@ -89,7 +98,7 @@ class HouseholdMemberControllerTest extends WebTestCase
$participation = $person->getCurrentHouseholdParticipationShareHousehold();
if (null == $participation
if (null === $participation
|| (
null === $participation->getEndDate()
&& $participation->getStartDate() <= $yesterday

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\PersonBundle\Entity\Person;
@@ -16,7 +25,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonAddressControllerTest extends WebTestCase
final class PersonAddressControllerTest extends WebTestCase
{
/**
* @var \Symfony\Component\BrowserKit\Client
@@ -40,9 +49,9 @@ class PersonAddressControllerTest extends WebTestCase
public static function setUpBeforeClass()
{
static::bootKernel();
self::bootKernel();
$em = static::$kernel->getContainer()
$em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$center = $em->getRepository('ChillMainBundle:Center')
@@ -63,15 +72,15 @@ class PersonAddressControllerTest extends WebTestCase
*/
public function setUp()
{
static::bootKernel();
self::bootKernel();
$this->em = static::$kernel->getContainer()
$this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$this->postalCode = $this->em->getRepository('ChillMainBundle:PostalCode')
->findOneBy(['code' => 1000]);
$this->client = static::createClient([], [
$this->client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password',
]);

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -23,7 +32,7 @@ use function shuffle;
* @internal
* @coversNothing
*/
class PersonApiControllerTest extends WebTestCase
final class PersonApiControllerTest extends WebTestCase
{
use PrepareClientTrait;

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -23,7 +32,7 @@ use function in_array;
* @internal
* @coversNothing
*/
class PersonControllerCreateTest extends WebTestCase
final class PersonControllerCreateTest extends WebTestCase
{
use PrepareClientTrait;
@@ -45,8 +54,8 @@ class PersonControllerCreateTest extends WebTestCase
public static function tearDownAfterClass()
{
static::bootKernel();
$em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
self::bootKernel();
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');
//remove two people created during test
$jesus = $em->getRepository('ChillPersonBundle:Person')
@@ -120,11 +129,11 @@ class PersonControllerCreateTest extends WebTestCase
'The gender input has three options: man, women and undefined'
);
$this->assertTrue(
in_array('man', $genderType->availableOptionValues()),
in_array('man', $genderType->availableOptionValues(), true),
'gender has "homme" option'
);
$this->assertTrue(
in_array('woman', $genderType->availableOptionValues()),
in_array('woman', $genderType->availableOptionValues(), true),
'gender has "femme" option'
);
$this->assertFalse($genderType->hasValue(), 'The gender input is not checked');

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -22,7 +31,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonControllerUpdateTest extends WebTestCase
final class PersonControllerUpdateTest extends WebTestCase
{
use PrepareClientTrait;
@@ -51,9 +60,9 @@ class PersonControllerUpdateTest extends WebTestCase
*/
public function setUp()
{
static::bootKernel();
self::bootKernel();
$this->em = static::$kernel->getContainer()
$this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
@@ -126,7 +135,7 @@ class PersonControllerUpdateTest extends WebTestCase
*/
public function testEditPageDeniedForUnauthorizedInsideCenter()
{
$client = static::createClient([], [
$client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_administrative',
'PHP_AUTH_PW' => 'password',
]);
@@ -141,7 +150,7 @@ class PersonControllerUpdateTest extends WebTestCase
*/
public function testEditPageDeniedForUnauthorizedOutsideCenter()
{
$client = static::createClient([], [
$client = self::createClient([], [
'PHP_AUTH_USER' => 'center b_social',
'PHP_AUTH_PW' => 'password',
]);
@@ -226,8 +235,8 @@ class PersonControllerUpdateTest extends WebTestCase
'a element .success is shown'
);
if ('birthdate' == $field || 'memo' == $field || 'countryOfBirth' == $field || 'nationality' == $field
|| 'gender' == $field) {
if ('birthdate' === $field || 'memo' === $field || 'countryOfBirth' === $field || 'nationality' === $field
|| 'gender' === $field) {
// we do not perform test on the web page contents.
} else {
$this->assertGreaterThan(0, $crawler->filter('html:contains("' . $value . '")')->count());

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
//ini_set('memory_limit', '-1');
@@ -23,7 +32,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
final class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
{
/**
* @var string The url using for editing the person's information
@@ -50,9 +59,9 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
*/
public function setUp()
{
static::bootKernel(['environment' => 'test_with_hidden_fields']);
self::bootKernel(['environment' => 'test_with_hidden_fields']);
$this->em = static::$kernel->getContainer()
$this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
@@ -70,7 +79,7 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
$this->editUrl = '/en/person/' . $this->person->getId() . '/general/edit';
$this->viewUrl = '/en/person/' . $this->person->getId() . '/general';
$this->client = static::createClient(
$this->client = self::createClient(
[
'environment' => 'test_with_hidden_fields',
],
@@ -160,8 +169,8 @@ class PersonControllerUpdateWithHiddenFieldsTest extends WebTestCase
'a element .success is shown'
);
if ('birthdate' == $field || 'memo' == $field || 'countryOfBirth' == $field || 'nationality' == $field
|| 'gender' == $field) {
if ('birthdate' === $field || 'memo' === $field || 'countryOfBirth' === $field || 'nationality' === $field
|| 'gender' === $field) {
// we do not perform test on the web page contents.
} else {
$this->assertGreaterThan(0, $crawler->filter('html:contains("' . $value . '")')->count());

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\PersonBundle\Entity\Person;
@@ -16,7 +25,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonControllerViewTest extends WebTestCase
final class PersonControllerViewTest extends WebTestCase
{
/**
* @var \Doctrine\ORM\EntityManagerInterface The entity manager
@@ -35,9 +44,9 @@ class PersonControllerViewTest extends WebTestCase
public function setUp()
{
static::bootKernel();
self::bootKernel();
$this->em = static::$kernel->getContainer()
$this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
@@ -69,7 +78,7 @@ class PersonControllerViewTest extends WebTestCase
*/
public function testViewPerson()
{
$client = static::createClient([], [
$client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password',
]);
@@ -93,7 +102,7 @@ class PersonControllerViewTest extends WebTestCase
*/
public function testViewPersonAccessDeniedForUnauthorized()
{
$client = static::createClient([], [
$client = self::createClient([], [
'PHP_AUTH_USER' => 'center b_social',
'PHP_AUTH_PW' => 'password',
]);

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\PersonBundle\Entity\Person;
@@ -16,7 +25,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
final class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
{
/**
* @var \Doctrine\ORM\EntityManagerInterface The entity manager
@@ -35,9 +44,9 @@ class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
public function setUp()
{
static::bootKernel(['environment' => 'test_with_hidden_fields']);
self::bootKernel(['environment' => 'test_with_hidden_fields']);
$this->em = static::$kernel->getContainer()
$this->em = self::$kernel->getContainer()
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
@@ -70,7 +79,7 @@ class PersonControllerViewWithHiddenFieldsTest extends WebTestCase
public function testViewPerson()
{
$this->markTestSkipped('This configuration does not allow multiple environnements');
$client = static::createClient(
$client = self::createClient(
['environment' => 'test_with_hidden_fields'],
[
'PHP_AUTH_USER' => 'center a_social',

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\PersonBundle\Entity\Person;
@@ -16,13 +25,13 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
* @internal
* @coversNothing
*/
class PersonDuplicateControllerViewTest extends WebTestCase
final class PersonDuplicateControllerViewTest extends WebTestCase
{
public function setUp()
{
static::bootKernel();
self::bootKernel();
$this->em = static::$container
$this->em = self::$container
->get('doctrine.orm.entity_manager');
$center = $this->em->getRepository('ChillMainBundle:Center')
@@ -47,7 +56,7 @@ class PersonDuplicateControllerViewTest extends WebTestCase
public function testViewDuplicatePerson()
{
$client = static::createClient([], [
$client = self::createClient([], [
'PHP_AUTH_USER' => 'center a_social',
'PHP_AUTH_PW' => 'password',
]);

View File

@@ -26,7 +26,7 @@ use function random_int;
* @internal
* @coversNothing
*/
class RelationshipApiControllerTest extends WebTestCase
final class RelationshipApiControllerTest extends WebTestCase
{
use PrepareClientTrait;
@@ -41,13 +41,13 @@ class RelationshipApiControllerTest extends WebTestCase
public function setUp()
{
static::bootKernel();
self::bootKernel();
$this->client = $this->getClientAuthenticated();
}
public function personProvider(): array
{
static::bootKernel();
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$countPersons = $em->createQueryBuilder()
->select('count(p)')
@@ -75,7 +75,7 @@ class RelationshipApiControllerTest extends WebTestCase
public function relationProvider(): array
{
static::bootKernel();
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$countPersons = $em->createQueryBuilder()
->select('count(p)')

View File

@@ -7,6 +7,15 @@
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
/**
* 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\Controller;
use Chill\MainBundle\Test\PrepareClientTrait;
@@ -20,7 +29,7 @@ use function json_decode;
* @internal
* @coversNothing
*/
class SocialIssueApiControllerTest extends WebTestCase
final class SocialIssueApiControllerTest extends WebTestCase
{
use PrepareClientTrait;