mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ParentRoleHelperTest extends KernelTestCase
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AddressReferenceApiControllerTest extends WebTestCase
|
||||
|
@@ -21,6 +21,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class AddressToReferenceMatcherControllerTest extends WebTestCase
|
||||
|
@@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CenterControllerTest extends WebTestCase
|
||||
@@ -23,18 +24,18 @@ final class CenterControllerTest extends WebTestCase
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* This is a smoke test that ensure that the list page does show
|
||||
* This is a smoke test that ensure that the list page does show.
|
||||
*/
|
||||
public function testCenterAdminSmokeTest(): void
|
||||
{
|
||||
$client = $this->getClientAuthenticated('admin', 'password');
|
||||
|
||||
$crawler = $client->request('GET', '/fr/admin/center');
|
||||
self::assertResponseIsSuccessful("Test that /fr/admin/center does show");
|
||||
self::assertResponseIsSuccessful('Test that /fr/admin/center does show');
|
||||
|
||||
$btnEdit = $crawler->filter('.btn-edit')?->first();
|
||||
|
||||
self::assertNotNull($btnEdit, "check that there is at least one btn-edit on center page");
|
||||
self::assertNotNull($btnEdit, 'check that there is at least one btn-edit on center page');
|
||||
|
||||
$client->click($btnEdit->link());
|
||||
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* Test the export.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ExportControllerTest extends WebTestCase
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class GeographicalUnitByAddressApiControllerTest extends WebTestCase
|
||||
|
@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LoginControllerTest extends WebTestCase
|
||||
@@ -24,7 +25,7 @@ final class LoginControllerTest extends WebTestCase
|
||||
{
|
||||
$client = self::createClient();
|
||||
|
||||
//load login page and submit form
|
||||
// load login page and submit form
|
||||
$crawler = $client->request('GET', '/login');
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
|
||||
@@ -36,15 +37,15 @@ final class LoginControllerTest extends WebTestCase
|
||||
'_password' => 'password',
|
||||
]);
|
||||
|
||||
//the response is a redirection
|
||||
// the response is a redirection
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
|
||||
//the response is not a login page, but on a new page
|
||||
// the response is not a login page, but on a new page
|
||||
$this->assertDoesNotMatchRegularExpression('/\/login$/', $client->getResponse()
|
||||
->headers
|
||||
->get('location'));
|
||||
|
||||
//on the home page, there must be a logout link
|
||||
// on the home page, there must be a logout link
|
||||
$client->followRedirects(true);
|
||||
$crawler = $client->request('GET', '/');
|
||||
|
||||
@@ -52,17 +53,17 @@ final class LoginControllerTest extends WebTestCase
|
||||
->getContent());
|
||||
$logoutLinkFilter = $crawler->filter('a:contains("Se déconnecter")');
|
||||
|
||||
//check there is > 0 logout link
|
||||
// check there is > 0 logout link
|
||||
$this->assertGreaterThan(0, $logoutLinkFilter->count(), 'check that a logout link is present');
|
||||
|
||||
//click on logout link
|
||||
// click on logout link
|
||||
$client->followRedirects(false);
|
||||
$client->click($crawler->selectLink('Se déconnecter')->link());
|
||||
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
$client->followRedirect(); //redirect to login page
|
||||
$client->followRedirect(); // redirect to login page
|
||||
|
||||
//check we are back on login page
|
||||
// check we are back on login page
|
||||
$this->assertMatchesRegularExpression('/\/login$/', $client->getResponse()
|
||||
->headers
|
||||
->get('location'));
|
||||
|
@@ -16,12 +16,12 @@ use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class NotificationApiControllerTest extends WebTestCase
|
||||
@@ -57,7 +57,7 @@ final class NotificationApiControllerTest extends WebTestCase
|
||||
->setRelatedEntityId(0)
|
||||
->setSender($userB)
|
||||
->addAddressee($userA)
|
||||
->setUpdatedAt(new DateTimeImmutable());
|
||||
->setUpdatedAt(new \DateTimeImmutable());
|
||||
$em->persist($notification);
|
||||
$em->refresh($notification);
|
||||
$em->flush();
|
||||
|
@@ -12,11 +12,11 @@ declare(strict_types=1);
|
||||
namespace Controller;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use DateTime;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PermissionApiControllerTest extends WebTestCase
|
||||
@@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase
|
||||
'object' => [
|
||||
'datetime' => '1969-07-09T00:00:00+0100',
|
||||
],
|
||||
'class' => DateTime::class,
|
||||
'class' => \DateTime::class,
|
||||
'roles' => ['FOO_ROLE'],
|
||||
])
|
||||
);
|
||||
|
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PermissionsGroupControllerTest extends WebTestCase
|
||||
|
@@ -13,10 +13,10 @@ namespace Controller;
|
||||
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use function json_decode;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PostalCodeApiControllerTest extends WebTestCase
|
||||
@@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
$data = \json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']);
|
||||
|
||||
|
@@ -15,6 +15,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ScopeControllerTest extends WebTestCase
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SearchApiControllerTest extends WebTestCase
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
* Test the search controller.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SearchControllerTest extends WebTestCase
|
||||
|
@@ -14,11 +14,10 @@ namespace Chill\MainBundle\Tests\Controller;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use function array_key_exists;
|
||||
use function json_decode;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class UserApiControllerTest extends WebTestCase
|
||||
@@ -32,7 +31,7 @@ final class UserApiControllerTest extends WebTestCase
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request(Request::METHOD_GET, '/api/1.0/main/user/' . $existingUser['id'] . '.json');
|
||||
$client->request(Request::METHOD_GET, '/api/1.0/main/user/'.$existingUser['id'].'.json');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
@@ -45,10 +44,10 @@ final class UserApiControllerTest extends WebTestCase
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
$this->assertTrue(array_key_exists('count', $data));
|
||||
$data = \json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
||||
$this->assertTrue(\array_key_exists('count', $data));
|
||||
$this->assertGreaterThan(0, $data['count']);
|
||||
$this->assertTrue(array_key_exists('results', $data));
|
||||
$this->assertTrue(\array_key_exists('results', $data));
|
||||
|
||||
return $data['results'][0];
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class UserControllerTest extends WebTestCase
|
||||
@@ -56,7 +57,7 @@ final class UserControllerTest extends WebTestCase
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername('Test_user ' . uniqid());
|
||||
$user->setUsername('Test_user '.uniqid());
|
||||
$user->setPassword(self::$container->get(UserPasswordEncoderInterface::class)->encodePassword(
|
||||
$user,
|
||||
'password'
|
||||
@@ -87,7 +88,7 @@ final class UserControllerTest extends WebTestCase
|
||||
{
|
||||
$crawler = $this->client->request('GET', '/fr/admin/main/user/new');
|
||||
|
||||
$username = 'Test_user' . uniqid();
|
||||
$username = 'Test_user'.uniqid();
|
||||
$password = 'Password1234!';
|
||||
|
||||
// Fill in the form and submit it
|
||||
@@ -95,7 +96,7 @@ final class UserControllerTest extends WebTestCase
|
||||
'chill_mainbundle_user[username]' => $username,
|
||||
'chill_mainbundle_user[plainPassword][first]' => $password,
|
||||
'chill_mainbundle_user[plainPassword][second]' => $password,
|
||||
'chill_mainbundle_user[email]' => $username . '@gmail.com',
|
||||
'chill_mainbundle_user[email]' => $username.'@gmail.com',
|
||||
'chill_mainbundle_user[label]' => $username,
|
||||
]);
|
||||
|
||||
@@ -109,7 +110,7 @@ final class UserControllerTest extends WebTestCase
|
||||
'page contains the name of the user'
|
||||
);
|
||||
|
||||
//test the auth of the new client
|
||||
// test the auth of the new client
|
||||
$this->isPasswordValid($username, $password);
|
||||
}
|
||||
|
||||
@@ -120,7 +121,7 @@ final class UserControllerTest extends WebTestCase
|
||||
{
|
||||
$crawler = $this->client->request('GET', "/fr/admin/main/user/{$userId}/edit");
|
||||
|
||||
$username = 'Foo bar ' . uniqid();
|
||||
$username = 'Foo bar '.uniqid();
|
||||
$form = $crawler->selectButton('Enregistrer & fermer')->form([
|
||||
'chill_mainbundle_user[username]' => $username,
|
||||
]);
|
||||
|
@@ -23,6 +23,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class CronJobDatabaseInteractionTest extends KernelTestCase
|
||||
@@ -46,7 +47,7 @@ class CronJobDatabaseInteractionTest extends KernelTestCase
|
||||
|
||||
$entityManager = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$entityManager->createQuery("DELETE " . CronJobExecution::class . ' cje WHERE cje.key LIKE :key')
|
||||
$entityManager->createQuery('DELETE '.CronJobExecution::class.' cje WHERE cje.key LIKE :key')
|
||||
->setParameter('key', 'test-with-data')
|
||||
->execute();
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Tests\Cron;
|
||||
|
||||
use ArrayObject;
|
||||
use Chill\MainBundle\Cron\CronJobInterface;
|
||||
use Chill\MainBundle\Cron\CronManager;
|
||||
use Chill\MainBundle\Entity\CronJobExecution;
|
||||
@@ -23,10 +22,10 @@ use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Psr\Log\NullLogger;
|
||||
use function array_key_exists;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CronManagerTest extends TestCase
|
||||
@@ -43,16 +42,16 @@ final class CronManagerTest extends TestCase
|
||||
$jobToExecute->run([])->shouldBeCalled();
|
||||
|
||||
$executions = [
|
||||
['key' => $jobOld1->getKey(), 'lastStart' => new DateTimeImmutable('yesterday'), 'lastEnd' => new DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => $jobOld2->getKey(), 'lastStart' => new DateTimeImmutable('3 days ago'), 'lastEnd' => new DateTimeImmutable('36 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => $jobOld1->getKey(), 'lastStart' => new \DateTimeImmutable('yesterday'), 'lastEnd' => new \DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => $jobOld2->getKey(), 'lastStart' => new \DateTimeImmutable('3 days ago'), 'lastEnd' => new \DateTimeImmutable('36 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
// this is the oldest one
|
||||
['key' => 'to-exec', 'lastStart' => new DateTimeImmutable('1 month ago'), 'lastEnd' => new DateTimeImmutable('10 days ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => 'to-exec', 'lastStart' => new \DateTimeImmutable('1 month ago'), 'lastEnd' => new \DateTimeImmutable('10 days ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
];
|
||||
|
||||
$cronManager = new CronManager(
|
||||
$this->buildCronJobExecutionRepository($executions),
|
||||
$this->buildEntityManager([]),
|
||||
new ArrayObject([$jobOld1, $jobToExecute->reveal(), $jobOld2]),
|
||||
new \ArrayObject([$jobOld1, $jobToExecute->reveal(), $jobOld2]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
@@ -68,13 +67,13 @@ final class CronManagerTest extends TestCase
|
||||
$jobNeverExecuted->canRun(null)->willReturn(true);
|
||||
|
||||
$executions = [
|
||||
['key' => $jobAlreadyExecuted->getKey(), 'lastStart' => new DateTimeImmutable('yesterday'), 'lastEnd' => new DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => $jobAlreadyExecuted->getKey(), 'lastStart' => new \DateTimeImmutable('yesterday'), 'lastEnd' => new \DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
];
|
||||
|
||||
$cronManager = new CronManager(
|
||||
$this->buildCronJobExecutionRepository($executions),
|
||||
$this->buildEntityManager([Argument::type(CronJobExecution::class)]),
|
||||
new ArrayObject([$jobNeverExecuted->reveal(), $jobAlreadyExecuted]),
|
||||
new \ArrayObject([$jobNeverExecuted->reveal(), $jobAlreadyExecuted]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
@@ -90,13 +89,13 @@ final class CronManagerTest extends TestCase
|
||||
$jobNeverExecuted->canRun(null)->willReturn(true);
|
||||
|
||||
$executions = [
|
||||
['key' => $jobAlreadyExecuted->getKey(), 'lastStart' => new DateTimeImmutable('yesterday'), 'lastEnd' => new DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
['key' => $jobAlreadyExecuted->getKey(), 'lastStart' => new \DateTimeImmutable('yesterday'), 'lastEnd' => new \DateTimeImmutable('1 hours ago'), 'lastStatus' => CronJobExecution::SUCCESS],
|
||||
];
|
||||
|
||||
$cronManager = new CronManager(
|
||||
$this->buildCronJobExecutionRepository($executions),
|
||||
$this->buildEntityManager([Argument::type(CronJobExecution::class)]),
|
||||
new ArrayObject([$jobAlreadyExecuted, $jobNeverExecuted->reveal()]),
|
||||
new \ArrayObject([$jobAlreadyExecuted, $jobNeverExecuted->reveal()]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
@@ -116,11 +115,11 @@ final class CronManagerTest extends TestCase
|
||||
$e = new CronJobExecution($exec['key']);
|
||||
$e->setLastStart($exec['lastStart']);
|
||||
|
||||
if (array_key_exists('lastEnd', $exec)) {
|
||||
if (\array_key_exists('lastEnd', $exec)) {
|
||||
$e->setLastEnd($exec['lastEnd']);
|
||||
}
|
||||
|
||||
if (array_key_exists('lastStatus', $exec)) {
|
||||
if (\array_key_exists('lastStatus', $exec)) {
|
||||
$e->setLastStatus($exec['lastStatus']);
|
||||
}
|
||||
|
||||
|
@@ -12,12 +12,12 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Doctrine\DQL;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AgeTest extends KernelTestCase
|
||||
@@ -34,29 +34,29 @@ final class AgeTest extends KernelTestCase
|
||||
public function generateQueries(): iterable
|
||||
{
|
||||
yield [
|
||||
'SELECT AGE(a.validFrom, a.validTo) FROM ' . Address::class . ' a',
|
||||
'SELECT AGE(a.validFrom, a.validTo) FROM '.Address::class.' a',
|
||||
[],
|
||||
];
|
||||
|
||||
yield [
|
||||
'SELECT AGE(:date0, :date1) FROM ' . Address::class . ' a',
|
||||
'SELECT AGE(:date0, :date1) FROM '.Address::class.' a',
|
||||
[
|
||||
'date0' => new DateTimeImmutable('now'),
|
||||
'date1' => new DateTimeImmutable('2020-01-01'),
|
||||
'date0' => new \DateTimeImmutable('now'),
|
||||
'date1' => new \DateTimeImmutable('2020-01-01'),
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'SELECT AGE(a.validFrom, :date1) FROM ' . Address::class . ' a',
|
||||
'SELECT AGE(a.validFrom, :date1) FROM '.Address::class.' a',
|
||||
[
|
||||
'date1' => new DateTimeImmutable('now'),
|
||||
'date1' => new \DateTimeImmutable('now'),
|
||||
],
|
||||
];
|
||||
|
||||
yield [
|
||||
'SELECT AGE(:date0, a.validFrom) FROM ' . Address::class . ' a',
|
||||
'SELECT AGE(:date0, a.validFrom) FROM '.Address::class.' a',
|
||||
[
|
||||
'date0' => new DateTimeImmutable('now'),
|
||||
'date0' => new \DateTimeImmutable('now'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@@ -12,13 +12,13 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Doctrine\DQL;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class GreatestTest extends KernelTestCase
|
||||
@@ -34,11 +34,11 @@ final class GreatestTest extends KernelTestCase
|
||||
|
||||
public function testGreatestInDQL()
|
||||
{
|
||||
$dql = 'SELECT GREATEST(a.validFrom, a.validTo, :now) AS g FROM ' . Address::class . ' a WHERE a.validTo < :now and a.validFrom < :now';
|
||||
$dql = 'SELECT GREATEST(a.validFrom, a.validTo, :now) AS g FROM '.Address::class.' a WHERE a.validTo < :now and a.validFrom < :now';
|
||||
|
||||
$actual = $this->entityManager
|
||||
->createQuery($dql)
|
||||
->setParameter('now', $now = new DateTimeImmutable('now'), Types::DATE_IMMUTABLE)
|
||||
->setParameter('now', $now = new \DateTimeImmutable('now'), Types::DATE_IMMUTABLE)
|
||||
->setMaxResults(3)
|
||||
->getResult();
|
||||
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class JsonBuildObjectTest extends KernelTestCase
|
||||
@@ -52,10 +53,9 @@ class JsonBuildObjectTest extends KernelTestCase
|
||||
|
||||
public function provideQueries(): iterable
|
||||
{
|
||||
yield ["SELECT JSON_BUILD_OBJECT(1, 2, 3, 4) FROM " . Address::class . " a", [], []];
|
||||
yield ["SELECT JSON_BUILD_OBJECT('st', a.street, 'sn', a.streetNumber) FROM " . Address::class . ' a', [], []];
|
||||
yield ['SELECT JSON_BUILD_OBJECT(1, 2, 3, 4) FROM '.Address::class.' a', [], []];
|
||||
yield ["SELECT JSON_BUILD_OBJECT('st', a.street, 'sn', a.streetNumber) FROM ".Address::class.' a', [], []];
|
||||
// next query make the test fails. But we do not need it for now.
|
||||
//yield ["SELECT JSON_BUILD_OBJECT(a.street, :param), LOWER(:param) FROM " . Address::class . " a", ['param' => 1], ['param' => Types::INTEGER]];
|
||||
// yield ["SELECT JSON_BUILD_OBJECT(a.street, :param), LOWER(:param) FROM " . Address::class . " a", ['param' => 1], ['param' => Types::INTEGER]];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JsonExtractTest extends KernelTestCase
|
||||
@@ -32,9 +33,9 @@ final class JsonExtractTest extends KernelTestCase
|
||||
|
||||
public function dataGenerateDql(): iterable
|
||||
{
|
||||
yield ['SELECT JSON_EXTRACT(c.name, \'fr\') FROM ' . Country::class . ' c', []];
|
||||
yield ['SELECT JSON_EXTRACT(c.name, \'fr\') FROM '.Country::class.' c', []];
|
||||
|
||||
yield ['SELECT JSON_EXTRACT(c.name, :lang) FROM ' . Country::class . ' c', ['lang' => 'fr']];
|
||||
yield ['SELECT JSON_EXTRACT(c.name, :lang) FROM '.Country::class.' c', ['lang' => 'fr']];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class JsonbExistsInArrayTest extends KernelTestCase
|
||||
@@ -32,7 +33,7 @@ final class JsonbExistsInArrayTest extends KernelTestCase
|
||||
public function testDQLFunctionWorks()
|
||||
{
|
||||
$result = $this->em
|
||||
->createQuery('SELECT JSONB_EXISTS_IN_ARRAY(u.attributes, :param) FROM ' . User::class . ' u')
|
||||
->createQuery('SELECT JSONB_EXISTS_IN_ARRAY(u.attributes, :param) FROM '.User::class.' u')
|
||||
->setParameter('param', 'fr')
|
||||
->getResult();
|
||||
|
||||
|
@@ -12,13 +12,13 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Doctrine\DQL;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class LeastTest extends KernelTestCase
|
||||
@@ -34,11 +34,11 @@ final class LeastTest extends KernelTestCase
|
||||
|
||||
public function testGreatestInDQL()
|
||||
{
|
||||
$dql = 'SELECT LEAST(a.validFrom, a.validTo, :now) AS g FROM ' . Address::class . ' a WHERE a.validTo < :now and a.validFrom < :now';
|
||||
$dql = 'SELECT LEAST(a.validFrom, a.validTo, :now) AS g FROM '.Address::class.' a WHERE a.validTo < :now and a.validFrom < :now';
|
||||
|
||||
$actual = $this->entityManager
|
||||
->createQuery($dql)
|
||||
->setParameter('now', $now = new DateTimeImmutable('now'), Types::DATE_IMMUTABLE)
|
||||
->setParameter('now', $now = new \DateTimeImmutable('now'), Types::DATE_IMMUTABLE)
|
||||
->setMaxResults(3)
|
||||
->getResult();
|
||||
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
* Test the point model methods.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PointTest extends KernelTestCase
|
||||
|
@@ -15,13 +15,12 @@ use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class NotificationTest extends KernelTestCase
|
||||
@@ -117,7 +116,7 @@ final class NotificationTest extends KernelTestCase
|
||||
->setSender($em->find(User::class, $senderId))
|
||||
->setRelatedEntityId(0)
|
||||
->setRelatedEntityClass(AccompanyingPeriod::class)
|
||||
->setUpdatedAt(new DateTimeImmutable())
|
||||
->setUpdatedAt(new \DateTimeImmutable())
|
||||
->setMessage('Fake message');
|
||||
|
||||
foreach ($addressesIds as $addresseeId) {
|
||||
@@ -132,7 +131,7 @@ final class NotificationTest extends KernelTestCase
|
||||
$this->toDelete[] = [Notification::class, $notification->getId()];
|
||||
|
||||
$this->assertEquals($senderId, $notification->getSender()->getId());
|
||||
$this->assertCount(count($addressesIds), $notification->getUnreadBy());
|
||||
$this->assertCount(\count($addressesIds), $notification->getUnreadBy());
|
||||
|
||||
$unreadIds = $notification->getUnreadBy()->map(static fn (User $u) => $u->getId());
|
||||
|
||||
|
@@ -19,6 +19,7 @@ use Prophecy\PhpUnit\ProphecyTrait;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class UserTest extends TestCase
|
||||
@@ -44,7 +45,6 @@ class UserTest extends TestCase
|
||||
->filter(fn (User\UserScopeHistory $userScopeHistory) => $userScopeHistory->getScope() === $scopeA)
|
||||
->first()->getEndDate()
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function testUserJobHistory()
|
||||
@@ -67,5 +67,4 @@ class UserTest extends TestCase
|
||||
->first()->getEndDate()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class EntityWorkflowTest extends TestCase
|
||||
|
@@ -14,14 +14,12 @@ namespace Export;
|
||||
use Chill\MainBundle\Export\AccompanyingCourseExportHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\PersonBundle\Repository\AccompanyingPeriodACLAwareRepositoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class AccompanyingCourseExportHelperTest extends KernelTestCase
|
||||
@@ -114,5 +112,4 @@ class AccompanyingCourseExportHelperTest extends KernelTestCase
|
||||
|
||||
return [$periodA, $periodB, $periodC];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,22 +28,20 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophet;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Test the export manager.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ExportManagerTest extends KernelTestCase
|
||||
@@ -111,23 +109,22 @@ final class ExportManagerTest extends KernelTestCase
|
||||
$filters
|
||||
);
|
||||
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFoo, $centers));
|
||||
$this->assertEquals(1, count($obtained));
|
||||
$this->assertEquals(1, \count($obtained));
|
||||
$this->assertContains('foo', array_keys($obtained));
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportBar, $centers));
|
||||
$this->assertEquals(1, count($obtained));
|
||||
$this->assertEquals(1, \count($obtained));
|
||||
$this->assertContains('bar', array_keys($obtained));
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFooBar, $centers));
|
||||
$this->assertEquals(2, count($obtained));
|
||||
$this->assertEquals(2, \count($obtained));
|
||||
$this->assertContains('bar', array_keys($obtained));
|
||||
$this->assertContains('foo', array_keys($obtained));
|
||||
|
||||
// test with empty centers
|
||||
$obtained = iterator_to_array($exportManager->getAggregatorsApplyingOn($exportFooBar, []));
|
||||
$this->assertEquals(0, count($obtained));
|
||||
$this->assertEquals(0, \count($obtained));
|
||||
}
|
||||
|
||||
public function testFiltersApplyingOn()
|
||||
@@ -161,27 +158,27 @@ final class ExportManagerTest extends KernelTestCase
|
||||
);
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFoo, $centers));
|
||||
$this->assertEquals(1, count($obtained));
|
||||
$this->assertEquals(1, \count($obtained));
|
||||
$this->assertContains('foo', array_keys($obtained));
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportBar, $centers));
|
||||
$this->assertEquals(1, count($obtained));
|
||||
$this->assertEquals(1, \count($obtained));
|
||||
$this->assertContains('bar', array_keys($obtained));
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFooBar, $centers));
|
||||
$this->assertEquals(2, count($obtained));
|
||||
$this->assertEquals(2, \count($obtained));
|
||||
$this->assertContains('bar', array_keys($obtained));
|
||||
$this->assertContains('foo', array_keys($obtained));
|
||||
|
||||
$obtained = iterator_to_array($exportManager->getFiltersApplyingOn($exportFooBar, []));
|
||||
$this->assertEquals(0, count($obtained));
|
||||
$this->assertEquals(0, \count($obtained));
|
||||
}
|
||||
|
||||
public function testFormattersByTypes()
|
||||
{
|
||||
$exportManager = $this->createExportManager();
|
||||
|
||||
//create a formatter
|
||||
// create a formatter
|
||||
$formatterFoo = $this->prophet->prophesize();
|
||||
$formatterFoo->willImplement(\Chill\MainBundle\Export\FormatterInterface::class);
|
||||
$formatterFoo->getType()->willReturn('foo');
|
||||
@@ -259,7 +256,7 @@ final class ExportManagerTest extends KernelTestCase
|
||||
case '_header':
|
||||
return 'export';
|
||||
|
||||
default: throw new RuntimeException(sprintf('The value %s is not valid', $value));
|
||||
default: throw new \RuntimeException(sprintf('The value %s is not valid', $value));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -297,7 +294,7 @@ final class ExportManagerTest extends KernelTestCase
|
||||
'_header' => 'foo_header',
|
||||
'cat a' => 'label cat a',
|
||||
'cat b' => 'label cat b',
|
||||
default => throw new RuntimeException(sprintf('This value (%s) is not valid', $value)),
|
||||
default => throw new \RuntimeException(sprintf('This value (%s) is not valid', $value)),
|
||||
});
|
||||
$aggregator->addRole()->willReturn(null);
|
||||
$aggregator->addRole()->shouldBeCalled();
|
||||
@@ -314,7 +311,7 @@ final class ExportManagerTest extends KernelTestCase
|
||||
$filters
|
||||
);
|
||||
|
||||
//add formatter interface
|
||||
// add formatter interface
|
||||
$formatter = new \Chill\MainBundle\Export\Formatter\SpreadSheetFormatter(
|
||||
self::$container->get(TranslatorInterface::class),
|
||||
$exportManager
|
||||
@@ -486,7 +483,7 @@ final class ExportManagerTest extends KernelTestCase
|
||||
|
||||
public function testNonExistingFormatter()
|
||||
{
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$exportManager = $this->createExportManager();
|
||||
|
||||
@@ -501,11 +498,11 @@ final class ExportManagerTest extends KernelTestCase
|
||||
* user 'center a_social' from database.
|
||||
*/
|
||||
protected function createExportManager(
|
||||
?LoggerInterface $logger = null,
|
||||
?EntityManagerInterface $em = null,
|
||||
?AuthorizationCheckerInterface $authorizationChecker = null,
|
||||
?AuthorizationHelper $authorizationHelper = null,
|
||||
?UserInterface $user = null,
|
||||
LoggerInterface $logger = null,
|
||||
EntityManagerInterface $em = null,
|
||||
AuthorizationCheckerInterface $authorizationChecker = null,
|
||||
AuthorizationHelper $authorizationHelper = null,
|
||||
UserInterface $user = null,
|
||||
array $exports = [],
|
||||
array $aggregators = [],
|
||||
array $filters = [],
|
||||
@@ -541,20 +538,26 @@ class DummyFilterWithApplying implements FilterInterface
|
||||
{
|
||||
return 'dummy';
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {}
|
||||
|
||||
public function getFormDefaultData(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return ['dummy filter', []];
|
||||
}
|
||||
|
||||
public function addRole(): ?string
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data) {}
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return $this->applyOn;
|
||||
|
@@ -23,10 +23,10 @@ use Doctrine\Persistence\ObjectRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class IdToEntityDataTransformerTest extends TestCase
|
||||
@@ -35,8 +35,8 @@ final class IdToEntityDataTransformerTest extends TestCase
|
||||
|
||||
public function testReverseTransformMulti()
|
||||
{
|
||||
$o1 = new stdClass();
|
||||
$o2 = new stdClass();
|
||||
$o1 = new \stdClass();
|
||||
$o2 = new \stdClass();
|
||||
|
||||
$repository = $this->prophesize(ObjectRepository::class);
|
||||
$repository->findOneBy(Argument::exact(['id' => 1]))->willReturn($o1);
|
||||
@@ -58,7 +58,7 @@ final class IdToEntityDataTransformerTest extends TestCase
|
||||
|
||||
public function testReverseTransformSingle()
|
||||
{
|
||||
$o = new stdClass();
|
||||
$o = new \stdClass();
|
||||
|
||||
$repository = $this->prophesize(ObjectRepository::class);
|
||||
$repository->findOneBy(Argument::exact(['id' => 1]))->willReturn($o);
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PickCenterTypeTest extends TypeTestCase
|
||||
@@ -31,7 +32,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
public function testUserCanReachMultipleCenters(): never
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
//prepare user
|
||||
// prepare user
|
||||
$centerA = $this->prepareCenter(1, 'centerA');
|
||||
$centerB = $this->prepareCenter(2, 'centerB');
|
||||
$groupCenterA = (new GroupCenter())
|
||||
@@ -54,7 +55,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
public function testUserCanReachMultipleSameCenter(): never
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
//prepare user
|
||||
// prepare user
|
||||
$center = $this->prepareCenter(1, 'center');
|
||||
$groupCenterA = (new GroupCenter())
|
||||
->setCenter($center);
|
||||
@@ -76,7 +77,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
public function testUserCanReachSingleCenter(): never
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
//prepare user
|
||||
// prepare user
|
||||
$center = $this->prepareCenter(1, 'center');
|
||||
$groupCenter = (new GroupCenter())
|
||||
->setCenter($center);
|
||||
@@ -91,7 +92,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
/**
|
||||
* prepare a mocked center, with and id and name given.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Center
|
||||
@@ -101,7 +102,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
|
||||
$prophecyCenter = $prophet->prophesize();
|
||||
$prophecyCenter->willExtend('\\' . \Chill\MainBundle\Entity\Center::class);
|
||||
$prophecyCenter->willExtend('\\'.\Chill\MainBundle\Entity\Center::class);
|
||||
$prophecyCenter->getId()->willReturn($id);
|
||||
$prophecyCenter->getName()->willReturn($name);
|
||||
|
||||
@@ -119,7 +120,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
{
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
|
||||
//create a center transformer
|
||||
// create a center transformer
|
||||
$centerTransformerProphecy = $prophet->prophesize();
|
||||
$centerTransformerProphecy
|
||||
->willExtend(\Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer::class);
|
||||
@@ -127,7 +128,7 @@ final class PickCenterTypeTest extends TypeTestCase
|
||||
|
||||
$tokenProphecy = $prophet->prophesize();
|
||||
$tokenProphecy
|
||||
->willImplement('\\' . \Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
|
||||
->willImplement('\\'.\Symfony\Component\Security\Core\Authentication\Token\TokenInterface::class);
|
||||
$tokenProphecy->getUser()->willReturn($user);
|
||||
$token = $tokenProphecy->reveal();
|
||||
|
||||
|
@@ -17,13 +17,13 @@ use Chill\MainBundle\Form\Type\PickPostalCodeType;
|
||||
use Chill\MainBundle\Repository\PostalCodeRepositoryInterface;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
use Symfony\Component\Form\PreloadedExtension;
|
||||
use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PickPostalCodeTypeTest extends TypeTestCase
|
||||
@@ -49,7 +49,7 @@ final class PickPostalCodeTypeTest extends TypeTestCase
|
||||
$postalCodeRepository->find(Argument::any())
|
||||
->will(static function ($args) {
|
||||
$postalCode = new PostalCode();
|
||||
$reflectionClass = new ReflectionClass($postalCode);
|
||||
$reflectionClass = new \ReflectionClass($postalCode);
|
||||
$id = $reflectionClass->getProperty('id');
|
||||
$id->setAccessible(true);
|
||||
$id->setValue($postalCode, (int) $args[0]);
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PickRollingDateTypeTest extends TypeTestCase
|
||||
|
@@ -31,6 +31,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ScopePickerTypeTest extends TypeTestCase
|
||||
|
@@ -27,14 +27,13 @@ use Symfony\Component\Translation\Translator;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class NotificationMailerTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testPostPersistComment(): void
|
||||
{
|
||||
$user1 = (new User())->setEmail('user1@foo.com');
|
||||
@@ -50,7 +49,7 @@ class NotificationMailerTest extends TestCase
|
||||
;
|
||||
|
||||
$comment = (new NotificationComment())
|
||||
->setContent("foo bar baz")
|
||||
->setContent('foo bar baz')
|
||||
->setCreatedBy($user2)
|
||||
;
|
||||
$notification->addComment($comment);
|
||||
@@ -60,7 +59,7 @@ class NotificationMailerTest extends TestCase
|
||||
// a mail only to user1 and user3 should have been sent
|
||||
$mailer->send(Argument::that(function (Email $email) {
|
||||
foreach ($email->getTo() as $address) {
|
||||
if ($address->getAddress() === 'user1@foo.com' || $address->getAddress() === 'user3@foo.com') {
|
||||
if ('user1@foo.com' === $address->getAddress() || 'user3@foo.com' === $address->getAddress()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +88,7 @@ class NotificationMailerTest extends TestCase
|
||||
;
|
||||
|
||||
$comment = (new NotificationComment())
|
||||
->setContent("foo bar baz")
|
||||
->setContent('foo bar baz')
|
||||
->setCreatedBy($user2)
|
||||
;
|
||||
$notification->addComment($comment);
|
||||
@@ -99,7 +98,7 @@ class NotificationMailerTest extends TestCase
|
||||
// a mail only to user1 and user3 should have been sent
|
||||
$mailer->send(Argument::that(function (Email $email) {
|
||||
foreach ($email->getTo() as $address) {
|
||||
if ($address->getAddress() === 'user1@foo.com') {
|
||||
if ('user1@foo.com' === $address->getAddress()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -122,7 +121,4 @@ class NotificationMailerTest extends TestCase
|
||||
new Translator('fr')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PersistNotificationOnTerminateEventSubscriberTest extends TestCase
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
* Test the Page class.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PageTest extends KernelTestCase
|
||||
@@ -72,6 +73,7 @@ final class PageTest extends KernelTestCase
|
||||
* @param int $number
|
||||
* @param int $itemPerPage
|
||||
* @param int $expectedItemPerPage
|
||||
*
|
||||
* @dataProvider generateGetFirstItemNumber
|
||||
*/
|
||||
public function testGetFirstItemNumber(
|
||||
@@ -88,6 +90,7 @@ final class PageTest extends KernelTestCase
|
||||
* @param int $number
|
||||
* @param int $itemPerPage
|
||||
* @param int $expectedItemPerPage
|
||||
*
|
||||
* @dataProvider generateGetLastItemNumber
|
||||
*/
|
||||
public function testGetLastItemNumber(
|
||||
@@ -108,7 +111,7 @@ final class PageTest extends KernelTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $itemPerPage
|
||||
* @param int $itemPerPage
|
||||
* @param string $route
|
||||
*
|
||||
* @return Page
|
||||
|
@@ -20,6 +20,7 @@ use function count;
|
||||
* Test the paginator class.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PaginatorTest extends KernelTestCase
|
||||
@@ -108,10 +109,11 @@ final class PaginatorTest extends KernelTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerPage
|
||||
* @param int $currentPage
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerPage
|
||||
* @param int $currentPage
|
||||
* @param bool $expectedHasNextPage
|
||||
*
|
||||
* @dataProvider generateHasNextPage
|
||||
*/
|
||||
public function testHasNextPage(
|
||||
@@ -128,10 +130,11 @@ final class PaginatorTest extends KernelTestCase
|
||||
/**
|
||||
* test the HasPage function.
|
||||
*
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerpage
|
||||
* @param int $pageNumber
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerpage
|
||||
* @param int $pageNumber
|
||||
* @param bool $expectedHasPage
|
||||
*
|
||||
* @dataProvider generateHasPage
|
||||
*/
|
||||
public function testHasPage(
|
||||
@@ -149,6 +152,7 @@ final class PaginatorTest extends KernelTestCase
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerPage
|
||||
* @param int $currentPage
|
||||
*
|
||||
* @dataProvider generateHasPreviousPage
|
||||
*/
|
||||
public function testHasPreviousPage(
|
||||
@@ -169,6 +173,7 @@ final class PaginatorTest extends KernelTestCase
|
||||
* @param int $totalItems
|
||||
* @param int $itemPerPage
|
||||
* @param int $expectedPageNumber
|
||||
*
|
||||
* @dataProvider generatePageNumber
|
||||
*/
|
||||
public function testPageNumber($totalItems, $itemPerPage, $expectedPageNumber)
|
||||
@@ -176,7 +181,7 @@ final class PaginatorTest extends KernelTestCase
|
||||
$paginator = $this->generatePaginator($totalItems, $itemPerPage);
|
||||
|
||||
$this->assertEquals($expectedPageNumber, $paginator->countPages());
|
||||
$this->assertEquals($expectedPageNumber, count($paginator));
|
||||
$this->assertEquals($expectedPageNumber, \count($paginator));
|
||||
}
|
||||
|
||||
public function testPagesGenerator()
|
||||
@@ -212,7 +217,7 @@ final class PaginatorTest extends KernelTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $itemPerPage
|
||||
* @param int $itemPerPage
|
||||
* @param string $route
|
||||
*
|
||||
* @return Paginator
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PhonenumberHelperTest extends KernelTestCase
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
* Test the route loader.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class RouteLoaderTest extends KernelTestCase
|
||||
|
@@ -15,6 +15,7 @@ namespace Chill\MainBundle\Tests\Search;
|
||||
* Description of AbstractSearch.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AbstractSearchTest extends \PHPUnit\Framework\TestCase
|
||||
|
@@ -13,10 +13,10 @@ namespace Search;
|
||||
|
||||
use Chill\MainBundle\Search\SearchApiQuery;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function is_string;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SearchApiQueryTest extends TestCase
|
||||
@@ -65,7 +65,7 @@ final class SearchApiQueryTest extends TestCase
|
||||
->setSelectPertinence('1')
|
||||
->setFromClause('badaboum');
|
||||
|
||||
$this->assertTrue(is_string($q->buildQuery()));
|
||||
$this->assertTrue(\is_string($q->buildQuery()));
|
||||
$this->assertEquals([], $q->buildParameters());
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class SearchProviderTest extends TestCase
|
||||
@@ -30,12 +31,12 @@ final class SearchProviderTest extends TestCase
|
||||
{
|
||||
$this->search = new SearchProvider();
|
||||
|
||||
//add a default service
|
||||
// add a default service
|
||||
$this->addSearchService(
|
||||
$this->createDefaultSearchService('I am default', 10),
|
||||
'default'
|
||||
);
|
||||
//add a domain service
|
||||
// add a domain service
|
||||
$this->addSearchService(
|
||||
$this->createNonDefaultDomainSearchService('I am domain bar', 20, false),
|
||||
'bar'
|
||||
@@ -44,7 +45,7 @@ final class SearchProviderTest extends TestCase
|
||||
|
||||
public function testAccentued()
|
||||
{
|
||||
//$this->markTestSkipped('accentued characters must be implemented');
|
||||
// $this->markTestSkipped('accentued characters must be implemented');
|
||||
|
||||
$terms = $this->p('manço bélier aztèque à saloù ê');
|
||||
|
||||
@@ -56,7 +57,7 @@ final class SearchProviderTest extends TestCase
|
||||
|
||||
public function testAccentuedCapitals()
|
||||
{
|
||||
//$this->markTestSkipped('accentued characters must be implemented');
|
||||
// $this->markTestSkipped('accentued characters must be implemented');
|
||||
|
||||
$terms = $this->p('MANÉÀ oÛ lÎ À');
|
||||
|
||||
@@ -122,7 +123,7 @@ final class SearchProviderTest extends TestCase
|
||||
{
|
||||
$response = $this->search->getSearchResults('default search');
|
||||
|
||||
//$this->markTestSkipped();
|
||||
// $this->markTestSkipped();
|
||||
|
||||
$this->assertEquals([
|
||||
'I am default',
|
||||
@@ -131,7 +132,7 @@ final class SearchProviderTest extends TestCase
|
||||
|
||||
public function testSearchResultDomainSearch()
|
||||
{
|
||||
//add a search service which will be supported
|
||||
// add a search service which will be supported
|
||||
$this->addSearchService(
|
||||
$this->createNonDefaultDomainSearchService('I am domain foo', 100, true),
|
||||
'foo'
|
||||
@@ -153,7 +154,7 @@ final class SearchProviderTest extends TestCase
|
||||
|
||||
public function testSearchWithinSpecificSearchName()
|
||||
{
|
||||
//add a search service which will be supported
|
||||
// add a search service which will be supported
|
||||
$this->addSearchService(
|
||||
$this->createNonDefaultDomainSearchService('I am domain foo', 100, true),
|
||||
'foo'
|
||||
@@ -244,7 +245,7 @@ final class SearchProviderTest extends TestCase
|
||||
$mock = $this
|
||||
->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class);
|
||||
|
||||
//set the mock as default
|
||||
// set the mock as default
|
||||
$mock->expects($this->any())
|
||||
->method('isActiveByDefault')
|
||||
->will($this->returnValue(true));
|
||||
@@ -253,7 +254,7 @@ final class SearchProviderTest extends TestCase
|
||||
->method('getOrder')
|
||||
->will($this->returnValue($order));
|
||||
|
||||
//set the return value
|
||||
// set the return value
|
||||
$mock->expects($this->any())
|
||||
->method('renderResult')
|
||||
->will($this->returnValue($result));
|
||||
@@ -266,7 +267,7 @@ final class SearchProviderTest extends TestCase
|
||||
$mock = $this
|
||||
->getMockForAbstractClass(\Chill\MainBundle\Search\AbstractSearch::class);
|
||||
|
||||
//set the mock as default
|
||||
// set the mock as default
|
||||
$mock->expects($this->any())
|
||||
->method('isActiveByDefault')
|
||||
->will($this->returnValue(false));
|
||||
@@ -279,7 +280,7 @@ final class SearchProviderTest extends TestCase
|
||||
->method('supports')
|
||||
->will($this->returnValue($domain));
|
||||
|
||||
//set the return value
|
||||
// set the return value
|
||||
$mock->expects($this->any())
|
||||
->method('renderResult')
|
||||
->will($this->returnValue($result));
|
||||
|
@@ -12,12 +12,11 @@ declare(strict_types=1);
|
||||
namespace Search\Utils;
|
||||
|
||||
use Chill\MainBundle\Search\Utils\ExtractDateFromPattern;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function array_map;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ExtractDateFromPatternTest extends TestCase
|
||||
@@ -49,10 +48,10 @@ final class ExtractDateFromPatternTest extends TestCase
|
||||
|
||||
$this->assertCount($count, $result->getFound());
|
||||
$this->assertEquals($filtered, $result->getFilteredSubject());
|
||||
$this->assertContainsOnlyInstancesOf(DateTimeImmutable::class, $result->getFound());
|
||||
$this->assertContainsOnlyInstancesOf(\DateTimeImmutable::class, $result->getFound());
|
||||
|
||||
$dates = array_map(
|
||||
static fn (DateTimeImmutable $d) => $d->format('Y-m-d'),
|
||||
$dates = \array_map(
|
||||
static fn (\DateTimeImmutable $d) => $d->format('Y-m-d'),
|
||||
$result->getFound()
|
||||
);
|
||||
|
||||
|
@@ -17,6 +17,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ExtractPhonenumberFromPatternTest extends KernelTestCase
|
||||
|
@@ -24,10 +24,10 @@ use Chill\MainBundle\Test\PrepareScopeTrait;
|
||||
use Chill\MainBundle\Test\PrepareUserTrait;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AuthorizationHelperTest extends KernelTestCase
|
||||
@@ -78,7 +78,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
// without scopes
|
||||
[
|
||||
true,
|
||||
in_array($centerA, $ah->getReachableCenters(
|
||||
\in_array($centerA, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_1',
|
||||
null
|
||||
@@ -87,7 +87,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
[
|
||||
true,
|
||||
in_array($centerA, $ah->getReachableCenters(
|
||||
\in_array($centerA, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_2',
|
||||
null
|
||||
@@ -96,7 +96,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
[
|
||||
true,
|
||||
in_array($centerB, $ah->getReachableCenters(
|
||||
\in_array($centerB, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_2',
|
||||
null
|
||||
@@ -105,7 +105,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
[
|
||||
false,
|
||||
in_array($centerB, $ah->getReachableCenters(
|
||||
\in_array($centerB, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_1',
|
||||
null
|
||||
@@ -115,7 +115,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
// with scope
|
||||
[
|
||||
true,
|
||||
in_array($centerA, $ah->getReachableCenters(
|
||||
\in_array($centerA, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_1',
|
||||
$scopeB
|
||||
@@ -124,7 +124,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
[
|
||||
false,
|
||||
in_array($centerA, $ah->getReachableCenters(
|
||||
\in_array($centerA, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_2',
|
||||
$scopeC
|
||||
@@ -133,7 +133,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
],
|
||||
[
|
||||
true,
|
||||
in_array($centerB, $ah->getReachableCenters(
|
||||
\in_array($centerB, $ah->getReachableCenters(
|
||||
$userA,
|
||||
'CHILL_ROLE_2',
|
||||
$scopeA
|
||||
@@ -193,7 +193,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
'CHILL_ROLE_1',
|
||||
$centerB,
|
||||
'Assert that a scope not reachable is not found within accessible scopes.'
|
||||
. ' Trying on filter centering',
|
||||
.' Trying on filter centering',
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -224,7 +224,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
/**
|
||||
* @dataProvider dataProvider_getReachableScopes
|
||||
*
|
||||
* @param bool $expectedResult
|
||||
* @param bool $expectedResult
|
||||
* @param string $message
|
||||
*/
|
||||
public function testGetReachableScopes(
|
||||
@@ -240,7 +240,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
|
||||
$this->assertEquals(
|
||||
$expectedResult,
|
||||
in_array($testedScope, $reachableScopes, true),
|
||||
\in_array($testedScope, $reachableScopes, true),
|
||||
$message
|
||||
);
|
||||
}
|
||||
@@ -258,8 +258,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
$entity->getScope()->willReturn($scope);
|
||||
|
||||
@@ -313,8 +313,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
{
|
||||
$centerA = $this->prepareCenter(1, 'center');
|
||||
$centerB = $this->prepareCenter(2, 'centerB');
|
||||
$scopeA = $this->prepareScope(3, 'other'); //the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
|
||||
$scopeA = $this->prepareScope(3, 'other'); // the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
'center' => $centerA, 'permissionsGroup' => [
|
||||
@@ -354,7 +354,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
{
|
||||
$center = $this->prepareCenter(1, 'center');
|
||||
$centerB = $this->prepareCenter(1, 'centerB');
|
||||
$scopeB = $this->prepareScope(2, 'other'); //the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(2, 'other'); // the user will be granted this scope
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
'center' => $center, 'permissionsGroup' => [
|
||||
@@ -383,7 +383,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
$this->assertTrue($helper->userHasAccess(
|
||||
@@ -407,7 +407,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
$this->assertTrue($helper->userHasAccess(
|
||||
@@ -419,8 +419,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
|
||||
public function testUserHasAccessUserHasNoCenterEntityWithScope()
|
||||
{
|
||||
$centerA = $this->prepareCenter(1, 'center'); //the user will have this center
|
||||
$centerB = $this->prepareCenter(2, 'centerB'); //the entity will have another center
|
||||
$centerA = $this->prepareCenter(1, 'center'); // the user will have this center
|
||||
$centerB = $this->prepareCenter(2, 'centerB'); // the entity will have another center
|
||||
$scope = $this->prepareScope(1, 'default');
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
@@ -431,8 +431,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($centerB);
|
||||
$entity->getScope()->willReturn($scope);
|
||||
|
||||
@@ -452,7 +452,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
|
||||
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));
|
||||
@@ -471,8 +471,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasScopeInterface::class);
|
||||
$entity->getCenter()->willReturn($center);
|
||||
$entity->getScope()->willReturn($scope);
|
||||
|
||||
@@ -503,7 +503,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
]);
|
||||
$helper = $this->getAuthorizationHelper();
|
||||
$entity = $this->prophesize();
|
||||
$entity->willImplement('\\' . \Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->willImplement('\\'.\Chill\MainBundle\Entity\HasCenterInterface::class);
|
||||
$entity->getCenter()->willReturn($centerA);
|
||||
|
||||
$this->assertFalse($helper->userHasAccess($user, $entity->reveal(), 'CHILL_ROLE'));
|
||||
@@ -512,8 +512,8 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
public function testUserHasAccessUserHasNoScopeEntityWithScope()
|
||||
{
|
||||
$center = $this->prepareCenter(1, 'center');
|
||||
$scopeA = $this->prepareScope(1, 'default'); //the entity will have this scope
|
||||
$scopeB = $this->prepareScope(2, 'other'); //the user will be granted this scope
|
||||
$scopeA = $this->prepareScope(1, 'default'); // the entity will have this scope
|
||||
$scopeB = $this->prepareScope(2, 'other'); // the user will be granted this scope
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
'center' => $center, 'permissionsGroup' => [
|
||||
@@ -535,9 +535,9 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
{
|
||||
$centerA = $this->prepareCenter(1, 'center');
|
||||
$centerB = $this->prepareCenter(2, 'centerB');
|
||||
$scopeA = $this->prepareScope(3, 'other'); //the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
|
||||
$scopeC = $this->prepareScope(5, 'other'); //the user will be granted this scope
|
||||
$scopeA = $this->prepareScope(3, 'other'); // the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
|
||||
$scopeC = $this->prepareScope(5, 'other'); // the user will be granted this scope
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
'center' => $centerA, 'permissionsGroup' => [
|
||||
@@ -560,7 +560,7 @@ final class AuthorizationHelperTest extends KernelTestCase
|
||||
$center = $this->prepareCenter(1, 'center');
|
||||
$centerB = $this->prepareCenter(2, 'centerB');
|
||||
$centerC = $this->prepareCenter(3, 'centerC');
|
||||
$scopeB = $this->prepareScope(4, 'other'); //the user will be granted this scope
|
||||
$scopeB = $this->prepareScope(4, 'other'); // the user will be granted this scope
|
||||
$user = $this->prepareUser([
|
||||
[
|
||||
'center' => $center, 'permissionsGroup' => [
|
||||
|
@@ -13,13 +13,11 @@ namespace Chill\MainBundle\Tests\Security\PasswordRecover;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Security\PasswordRecover\TokenManager;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class TokenManagerTest extends KernelTestCase
|
||||
@@ -42,7 +40,7 @@ final class TokenManagerTest extends KernelTestCase
|
||||
{
|
||||
$tokenManager = $this->tokenManager;
|
||||
$user = (new User())->setUsernameCanonical('test');
|
||||
$expiration = new DateTimeImmutable('tomorrow');
|
||||
$expiration = new \DateTimeImmutable('tomorrow');
|
||||
|
||||
$tokens = $tokenManager->generate($user, $expiration);
|
||||
|
||||
@@ -56,12 +54,12 @@ final class TokenManagerTest extends KernelTestCase
|
||||
|
||||
public function testGenerateEmptyUsernameCanonical()
|
||||
{
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
$tokenManager = $this->tokenManager;
|
||||
// set a username, but not a username canonical
|
||||
$user = (new User())->setUsername('test');
|
||||
$expiration = new DateTimeImmutable('tomorrow');
|
||||
$expiration = new \DateTimeImmutable('tomorrow');
|
||||
|
||||
$tokenManager->generate($user, $expiration);
|
||||
}
|
||||
@@ -70,7 +68,7 @@ final class TokenManagerTest extends KernelTestCase
|
||||
{
|
||||
$tokenManager = $this->tokenManager;
|
||||
$user = (new User())->setUsernameCanonical('test');
|
||||
$expiration = new DateTimeImmutable('tomorrow');
|
||||
$expiration = new \DateTimeImmutable('tomorrow');
|
||||
|
||||
$tokens = $tokenManager->generate($user, $expiration);
|
||||
|
||||
@@ -83,8 +81,8 @@ final class TokenManagerTest extends KernelTestCase
|
||||
$this->assertTrue($verification);
|
||||
|
||||
// test with altering token
|
||||
$this->assertFalse($tokenManager->verify($hash . '5', $token, $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token . '25', $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash.'5', $token, $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token.'25', $user, $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token, $user->setUsernameCanonical('test2'), $timestamp));
|
||||
$this->assertFalse($tokenManager->verify($hash, $token, $user, (string) ($timestamp + 1)));
|
||||
}
|
||||
@@ -93,7 +91,7 @@ final class TokenManagerTest extends KernelTestCase
|
||||
{
|
||||
$tokenManager = $this->tokenManager;
|
||||
$user = (new User())->setUsernameCanonical('test');
|
||||
$expiration = (new DateTimeImmutable('now'))->sub(new DateInterval('PT1S'));
|
||||
$expiration = (new \DateTimeImmutable('now'))->sub(new \DateInterval('PT1S'));
|
||||
|
||||
$tokens = $tokenManager->generate($user, $expiration);
|
||||
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CenterResolverDispatcherTest extends KernelTestCase
|
||||
|
@@ -19,6 +19,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class DefaultScopeResolverTest extends TestCase
|
||||
|
@@ -20,6 +20,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ScopeResolverDispatcherTest extends TestCase
|
||||
@@ -54,6 +55,7 @@ final class ScopeResolverDispatcherTest extends TestCase
|
||||
* @var Scope[]
|
||||
*/
|
||||
private array $scopes = [];
|
||||
|
||||
public function __construct(Scope $scopeA, Scope $scopeB)
|
||||
{
|
||||
$this->scopes = [$scopeA, $scopeB];
|
||||
|
@@ -12,11 +12,7 @@ declare(strict_types=1);
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Serializer\Normalizer\DateNormalizer;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Prophecy\Prophet;
|
||||
use stdClass;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -24,6 +20,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class DateNormalizerTest extends KernelTestCase
|
||||
@@ -37,8 +34,8 @@ final class DateNormalizerTest extends KernelTestCase
|
||||
|
||||
public function generateDataNormalize()
|
||||
{
|
||||
$datetime = DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 15:05:01+02:00');
|
||||
$date = DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 00:00:00+02:00');
|
||||
$datetime = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 15:05:01+02:00');
|
||||
$date = \DateTime::createFromFormat('Y-m-d H:i:sO', '2021-06-05 00:00:00+02:00');
|
||||
|
||||
yield [
|
||||
['datetime' => '2021-06-05T15:05:01+0200', 'datetime8601' => '2021-06-05T15:05:01+02:00'],
|
||||
@@ -76,18 +73,18 @@ final class DateNormalizerTest extends KernelTestCase
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new DateTime(), 'json'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new DateTimeImmutable(), 'json'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new DateTime(), 'docgen'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new DateTimeImmutable(), 'docgen'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => DateTimeImmutable::class]));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => DateTimeInterface::class]));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => DateTime::class]));
|
||||
$this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new stdClass(), 'docgen'));
|
||||
$this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new DateTime(), 'xml'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'json'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTimeImmutable(), 'json'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'docgen'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(new \DateTimeImmutable(), 'docgen'));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTimeImmutable::class]));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTimeInterface::class]));
|
||||
$this->assertTrue($this->buildDateNormalizer()->supportsNormalization(null, 'docgen', ['docgen:expects' => \DateTime::class]));
|
||||
$this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new \stdClass(), 'docgen'));
|
||||
$this->assertFalse($this->buildDateNormalizer()->supportsNormalization(new \DateTime(), 'xml'));
|
||||
}
|
||||
|
||||
private function buildDateNormalizer(?string $locale = null): DateNormalizer
|
||||
private function buildDateNormalizer(string $locale = null): DateNormalizer
|
||||
{
|
||||
$requestStack = $this->prophet->prophesize(RequestStack::class);
|
||||
$parameterBag = new ParameterBag();
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class DoctrineExistingEntityNormalizerTest extends KernelTestCase
|
||||
|
@@ -21,6 +21,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PhonenumberNormalizerTest extends TestCase
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Component\Clock\MockClock;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class CollateAddressWithReferenceOrPostalCodeCronJobTest extends TestCase
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class CollateAddressWithReferenceOrPostalCodeTest extends KernelTestCase
|
||||
|
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Services\AddressGeographicalUnit;
|
||||
|
||||
use Chill\MainBundle\Entity\CronJobExecution;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
@@ -20,6 +19,7 @@ use Symfony\Component\Clock\MockClock;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends KernelTestCase
|
||||
@@ -32,13 +32,13 @@ final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends
|
||||
// 10 + 5 executions
|
||||
$job = new \Chill\MainBundle\Service\AddressGeographicalUnit\RefreshAddressToGeographicalUnitMaterializedViewCronJob(
|
||||
$this->prophesize(Connection::class)->reveal(),
|
||||
new MockClock(new DateTimeImmutable('2023-07-01T00:00:00'))
|
||||
new MockClock(new \DateTimeImmutable('2023-07-01T00:00:00'))
|
||||
);
|
||||
|
||||
$hoursAgo23 = new CronJobExecution($job->getKey());
|
||||
$hoursAgo23->setLastStart(new DateTimeImmutable('2023-06-30T01:00:00'));
|
||||
$hoursAgo23->setLastStart(new \DateTimeImmutable('2023-06-30T01:00:00'));
|
||||
$hoursAgo25 = new CronJobExecution($job->getKey());
|
||||
$hoursAgo25->setLastStart(new DateTimeImmutable('2023-06-29T23:00:00'));
|
||||
$hoursAgo25->setLastStart(new \DateTimeImmutable('2023-06-29T23:00:00'));
|
||||
|
||||
$executedForFirstTime = $executedAfter23 = $executedAfter25 = 0;
|
||||
|
||||
@@ -71,7 +71,7 @@ final class RefreshAddressToGeographicalUnitMaterializedViewCronJobTest extends
|
||||
);
|
||||
|
||||
$lastExecution = new CronJobExecution($job->getKey());
|
||||
$lastExecution->setLastStart(new DateTimeImmutable('2 days ago'));
|
||||
$lastExecution->setLastStart(new \DateTimeImmutable('2 days ago'));
|
||||
|
||||
$this->assertIsBool($job->canRun($lastExecution));
|
||||
|
||||
|
@@ -20,6 +20,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AddressReferenceBaseImporterTest extends KernelTestCase
|
||||
@@ -46,7 +47,7 @@ final class AddressReferenceBaseImporterTest extends KernelTestCase
|
||||
public function testImportAddress(): void
|
||||
{
|
||||
$postalCode = (new PostalCode())
|
||||
->setRefPostalCodeId($postalCodeId = '1234' . uniqid())
|
||||
->setRefPostalCodeId($postalCodeId = '1234'.uniqid())
|
||||
->setPostalCodeSource('testing')
|
||||
->setCode('TEST456')
|
||||
->setName('testing');
|
||||
|
@@ -11,9 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Services\Import;
|
||||
|
||||
use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\AddressReference;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Repository\AddressReferenceRepository;
|
||||
use Chill\MainBundle\Repository\CountryRepository;
|
||||
@@ -24,6 +22,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class AddressToReferenceMatcherTest extends KernelTestCase
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class GeographicalUnitBaseImporterTest extends KernelTestCase
|
||||
|
@@ -19,6 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PostalCodeBaseImporterTest extends KernelTestCase
|
||||
@@ -47,9 +48,9 @@ final class PostalCodeBaseImporterTest extends KernelTestCase
|
||||
{
|
||||
$this->importer->importCode(
|
||||
'BE',
|
||||
'tested with pattern ' . ($uniqid = uniqid()),
|
||||
'tested with pattern '.($uniqid = uniqid()),
|
||||
'12345',
|
||||
$refPostalCodeId = 'test' . uniqid(),
|
||||
$refPostalCodeId = 'test'.uniqid(),
|
||||
'test',
|
||||
50.0,
|
||||
5.0,
|
||||
@@ -59,7 +60,7 @@ final class PostalCodeBaseImporterTest extends KernelTestCase
|
||||
$this->importer->finalize();
|
||||
|
||||
$postalCodes = $this->postalCodeRepository->findByPattern(
|
||||
'with pattern ' . $uniqid,
|
||||
'with pattern '.$uniqid,
|
||||
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
|
||||
);
|
||||
|
||||
@@ -72,7 +73,7 @@ final class PostalCodeBaseImporterTest extends KernelTestCase
|
||||
|
||||
$this->importer->importCode(
|
||||
'BE',
|
||||
'tested with adapted pattern ' . ($uniqid = uniqid()),
|
||||
'tested with adapted pattern '.($uniqid = uniqid()),
|
||||
'12345',
|
||||
$refPostalCodeId,
|
||||
'test',
|
||||
@@ -84,7 +85,7 @@ final class PostalCodeBaseImporterTest extends KernelTestCase
|
||||
$this->importer->finalize();
|
||||
|
||||
$postalCodes = $this->postalCodeRepository->findByPattern(
|
||||
'with pattern ' . $uniqid,
|
||||
'with pattern '.$uniqid,
|
||||
$this->countryRepository->findOneBy(['countryCode' => 'BE'])
|
||||
);
|
||||
|
||||
|
@@ -18,6 +18,7 @@ use Symfony\Component\Routing\RouteCollection;
|
||||
* This class provide functional test for MenuComposer.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class MenuComposerTest extends KernelTestCase
|
||||
|
@@ -13,12 +13,11 @@ namespace Services\RollingDate;
|
||||
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class RollingDateConverterTest extends TestCase
|
||||
@@ -63,7 +62,7 @@ final class RollingDateConverterTest extends TestCase
|
||||
|
||||
public function testConversionFixedDate()
|
||||
{
|
||||
$rollingDate = new RollingDate(RollingDate::T_FIXED_DATE, new DateTimeImmutable('2022-01-01'));
|
||||
$rollingDate = new RollingDate(RollingDate::T_FIXED_DATE, new \DateTimeImmutable('2022-01-01'));
|
||||
|
||||
$this->assertEquals(
|
||||
'2022-01-01',
|
||||
@@ -78,7 +77,7 @@ final class RollingDateConverterTest extends TestCase
|
||||
$actual = $this->converter->convert($rollingDate);
|
||||
|
||||
$this->assertEquals(
|
||||
(int) (new DateTimeImmutable('now'))->format('Y') - 1,
|
||||
(int) (new \DateTimeImmutable('now'))->format('Y') - 1,
|
||||
(int) $actual->format('Y')
|
||||
);
|
||||
$this->assertEquals(1, (int) $actual->format('m'));
|
||||
@@ -90,11 +89,11 @@ final class RollingDateConverterTest extends TestCase
|
||||
*/
|
||||
public function testConvertOnPivotDate(string $roll, string $expectedDateTime, string $format)
|
||||
{
|
||||
$pivot = DateTimeImmutable::createFromFormat('Y-m-d His', '2022-11-07 000000');
|
||||
$pivot = \DateTimeImmutable::createFromFormat('Y-m-d His', '2022-11-07 000000');
|
||||
$rollingDate = new RollingDate($roll, null, $pivot);
|
||||
|
||||
$this->assertEquals(
|
||||
DateTime::createFromFormat($format, $expectedDateTime),
|
||||
\DateTime::createFromFormat($format, $expectedDateTime),
|
||||
$this->converter->convert($rollingDate)
|
||||
);
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* @internal we do not want to test the markdown transformation. We just want to
|
||||
* test that the markdown is correctly transformed into html, and that the html
|
||||
* is safe.
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class ChillMarkdownRenderExtensionTest extends TestCase
|
||||
|
@@ -16,13 +16,11 @@ use Chill\MainBundle\Entity\Country;
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Iterator;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class AddressRenderTest extends KernelTestCase
|
||||
@@ -32,7 +30,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
self::bootKernel();
|
||||
}
|
||||
|
||||
public function addressDataProviderBEWithBuilding(): Iterator
|
||||
public function addressDataProviderBEWithBuilding(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -52,7 +50,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'Résidence "Les Bleuets" — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderBEWithSteps(): Iterator
|
||||
public function addressDataProviderBEWithSteps(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -72,7 +70,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'esc 4 — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithBuilding(): Iterator
|
||||
public function addressDataProviderFRWithBuilding(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -92,7 +90,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'Résidence "Les Bleuets" — 5, Rue ABC — 012345 Locality — France'];
|
||||
}
|
||||
|
||||
public function addressDataProviderFRWithSteps(): Iterator
|
||||
public function addressDataProviderFRWithSteps(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -112,7 +110,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'esc 4 — 5, Rue ABC — 012345 Locality — France'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderBE(): Iterator
|
||||
public function complexAddressDataProviderBE(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -136,7 +134,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'Résidence "Les Bleuets" - appart 1 - ét 2 - coul 3 - esc 4 — Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function complexAddressDataProviderFR(): Iterator
|
||||
public function complexAddressDataProviderFR(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -162,7 +160,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'appart 1 - ét 2 - coul 3 - esc 4 — Résidence "Les Bleuets" — 5, Rue ABC — A droite de la porte — 012345 Locality CEDEX — France'];
|
||||
}
|
||||
|
||||
public function noFullAddressDataProviderBE(): Iterator
|
||||
public function noFullAddressDataProviderBE(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -179,7 +177,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, '012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderBE(): Iterator
|
||||
public function simpleAddressDataProviderBE(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
@@ -197,7 +195,7 @@ final class AddressRenderTest extends KernelTestCase
|
||||
yield [$addr, 'Rue ABC, 5 — 012345 Locality — Belgium'];
|
||||
}
|
||||
|
||||
public function simpleAddressDataProviderFR(): Iterator
|
||||
public function simpleAddressDataProviderFR(): \Iterator
|
||||
{
|
||||
$addr = new Address();
|
||||
$country = (new Country())
|
||||
|
@@ -21,7 +21,6 @@ class TestHelper
|
||||
/**
|
||||
* create a client authenticated with an user.
|
||||
*
|
||||
*
|
||||
* @return \Symfony\Component\BrowserKit\AbstractBrowser authenticated client
|
||||
*/
|
||||
public static function getAuthenticatedClientOptions(
|
||||
|
@@ -18,6 +18,7 @@ use PHPUnit\Framework\TestCase;
|
||||
* tests for CountriesInfos.
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class CountriesInfoTest extends TestCase
|
||||
|
@@ -12,36 +12,34 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Util;
|
||||
|
||||
use Chill\MainBundle\Util\DateRangeCovering;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function usort;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class DateRangeCoveringTest extends TestCase
|
||||
{
|
||||
public function testCoveringWithMinCover1()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-12-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2011-06-01'), 2)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-06-01'), 3)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-06-01'), 3)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-12-01'),
|
||||
new \DateTime('2010-12-01'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -53,10 +51,10 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover1NoCoveringWithNullDates()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2021-10-05'), new DateTime('2021-10-18'), 521)
|
||||
->add(new DateTime('2021-10-26'), null, 663)
|
||||
->add(new \DateTime('2021-10-05'), new \DateTime('2021-10-18'), 521)
|
||||
->add(new \DateTime('2021-10-26'), null, 663)
|
||||
->compute();
|
||||
|
||||
$this->assertFalse($cover->hasIntersections());
|
||||
@@ -64,12 +62,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover1WithTwoIntersections()
|
||||
{
|
||||
$cover = new DateRangeCovering(1, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(1, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-12-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2011-06-01'), 2)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-12-01'), 3)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2020-06-01'), 4)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-12-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2011-06-01'), 2)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-12-01'), 3)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2020-06-01'), 4)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -79,7 +77,7 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$intersections = $cover->getIntersections();
|
||||
|
||||
// sort the intersections to compare them in expected order
|
||||
usort($intersections, static function ($a, $b) {
|
||||
\usort($intersections, static function ($a, $b) {
|
||||
if ($a[0] === $b[0]) {
|
||||
return $a[1] <=> $b[1];
|
||||
}
|
||||
@@ -89,12 +87,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
// first intersection
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$intersections[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-12-01'),
|
||||
new \DateTime('2010-12-01'),
|
||||
$intersections[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -106,12 +104,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
// second intersection
|
||||
$this->assertEquals(
|
||||
new DateTime('2019-06-01'),
|
||||
new \DateTime('2019-06-01'),
|
||||
$intersections[1][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2019-12-01'),
|
||||
new \DateTime('2019-12-01'),
|
||||
$intersections[1][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -124,25 +122,25 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 4)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 5)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
||||
->compute();
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-06-01'),
|
||||
new \DateTime('2010-06-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-01'),
|
||||
new \DateTime('2010-09-01'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -156,14 +154,14 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2AndThreePeriodsCovering()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2009-01-01'), new DateTime('2010-09-15'), 4)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 5)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 6)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), 4)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 5)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 6)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -171,12 +169,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-04-01'),
|
||||
new \DateTime('2010-04-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-15'),
|
||||
new \DateTime('2010-09-15'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -191,14 +189,14 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover2AndThreePeriodsCoveringWithNullMetadata()
|
||||
{
|
||||
$cover = new DateRangeCovering(2, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(2, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), null)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), null)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), null)
|
||||
->add(new DateTime('2009-01-01'), new DateTime('2010-09-15'), null)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), null)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), null)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), null)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), null)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), null)
|
||||
->add(new \DateTime('2009-01-01'), new \DateTime('2010-09-15'), null)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), null)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), null)
|
||||
->compute();
|
||||
|
||||
$this->assertTrue($cover->hasIntersections());
|
||||
@@ -206,12 +204,12 @@ final class DateRangeCoveringTest extends TestCase
|
||||
$this->assertCount(1, $cover->getIntersections());
|
||||
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-04-01'),
|
||||
new \DateTime('2010-04-01'),
|
||||
$cover->getIntersections()[0][0],
|
||||
'assert date start are the intersection'
|
||||
);
|
||||
$this->assertEquals(
|
||||
new DateTime('2010-09-15'),
|
||||
new \DateTime('2010-09-15'),
|
||||
$cover->getIntersections()[0][1],
|
||||
'assert date end are the intersection'
|
||||
);
|
||||
@@ -220,13 +218,13 @@ final class DateRangeCoveringTest extends TestCase
|
||||
|
||||
public function testCoveringWithMinCover3Absent()
|
||||
{
|
||||
$cover = new DateRangeCovering(3, new DateTimeZone('Europe/Brussels'));
|
||||
$cover = new DateRangeCovering(3, new \DateTimeZone('Europe/Brussels'));
|
||||
$cover
|
||||
->add(new DateTime('2010-01-01'), new DateTime('2010-10-01'), 1)
|
||||
->add(new DateTime('2010-06-01'), new DateTime('2010-09-01'), 2)
|
||||
->add(new DateTime('2010-04-01'), new DateTime('2010-12-01'), 3)
|
||||
->add(new DateTime('2019-01-01'), new DateTime('2019-10-01'), 4)
|
||||
->add(new DateTime('2019-06-01'), new DateTime('2019-09-01'), 5)
|
||||
->add(new \DateTime('2010-01-01'), new \DateTime('2010-10-01'), 1)
|
||||
->add(new \DateTime('2010-06-01'), new \DateTime('2010-09-01'), 2)
|
||||
->add(new \DateTime('2010-04-01'), new \DateTime('2010-12-01'), 3)
|
||||
->add(new \DateTime('2019-01-01'), new \DateTime('2019-10-01'), 4)
|
||||
->add(new \DateTime('2019-06-01'), new \DateTime('2019-09-01'), 5)
|
||||
->compute();
|
||||
$this->assertFalse($cover->hasIntersections());
|
||||
$this->assertIsArray($cover->getIntersections());
|
||||
|
@@ -23,19 +23,16 @@ use Prophecy\Argument;
|
||||
use Prophecy\Call\Call;
|
||||
use Prophecy\Exception\Prediction\FailedPredictionException;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use ReflectionClass;
|
||||
use stdClass;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\Workflow\Event\Event;
|
||||
use Symfony\Component\Workflow\Marking;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
use Symfony\Component\Workflow\Transition;
|
||||
use Symfony\Component\Workflow\WorkflowInterface;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
final class NotificationOnTransitionTest extends TestCase
|
||||
@@ -51,10 +48,10 @@ final class NotificationOnTransitionTest extends TestCase
|
||||
$entityWorkflow = new EntityWorkflow();
|
||||
$entityWorkflow
|
||||
->setWorkflowName('workflow_name')
|
||||
->setRelatedEntityClass(stdClass::class)
|
||||
->setRelatedEntityClass(\stdClass::class)
|
||||
->setRelatedEntityId(1);
|
||||
// force an id to entityWorkflow:
|
||||
$reflection = new ReflectionClass($entityWorkflow);
|
||||
$reflection = new \ReflectionClass($entityWorkflow);
|
||||
$id = $reflection->getProperty('id');
|
||||
$id->setAccessible(true);
|
||||
$id->setValue($entityWorkflow, 1);
|
||||
@@ -68,7 +65,7 @@ final class NotificationOnTransitionTest extends TestCase
|
||||
$em->persist(Argument::type(Notification::class))->should(
|
||||
static function ($args) use ($dest) {
|
||||
/** @var Call[] $args */
|
||||
if (1 !== count($args)) {
|
||||
if (1 !== \count($args)) {
|
||||
throw new FailedPredictionException('no notification sent');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user