mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-01 12:33:49 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class FetchQueryToSqlBuilderTest extends KernelTestCase
|
||||
@@ -35,21 +36,21 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase
|
||||
$query->addJoinClause('LEFT JOIN other d ON a.id = d.foreign_id', ['bar_baz'], [Types::STRING]);
|
||||
$query->removeJoinClause($index);
|
||||
$query->addWhereClause('b.item = ?', ['baz'], [Types::STRING]);
|
||||
$index = $query->addWhereClause('b.cancel', [ 'foz'], [Types::STRING]);
|
||||
$index = $query->addWhereClause('b.cancel', ['foz'], [Types::STRING]);
|
||||
$query->removeWhereClause($index);
|
||||
|
||||
['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
|
||||
|
||||
$filteredSql =
|
||||
implode(" ", array_filter(
|
||||
explode(" ", str_replace("\n", "", $sql)),
|
||||
fn (string $tok) => $tok !== ""
|
||||
implode(' ', array_filter(
|
||||
explode(' ', str_replace("\n", '', $sql)),
|
||||
fn (string $tok) => '' !== $tok
|
||||
))
|
||||
;
|
||||
|
||||
self::assertEquals(
|
||||
"SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ".
|
||||
"a.datecolumn::date AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?",
|
||||
'a.datecolumn::date AS doc_date FROM my_table a LEFT JOIN other b ON a.id = b.foreign_id LEFT JOIN other d ON a.id = d.foreign_id WHERE b.item = ?',
|
||||
$filteredSql
|
||||
);
|
||||
self::assertEquals(['foo', 'bar_baz', 'baz'], $params);
|
||||
@@ -68,15 +69,15 @@ class FetchQueryToSqlBuilderTest extends KernelTestCase
|
||||
['sql' => $sql, 'params' => $params, 'types' => $types] = (new FetchQueryToSqlBuilder())->toSql($query);
|
||||
|
||||
$filteredSql =
|
||||
implode(" ", array_filter(
|
||||
explode(" ", str_replace("\n", "", $sql)),
|
||||
fn (string $tok) => $tok !== ""
|
||||
implode(' ', array_filter(
|
||||
explode(' ', str_replace("\n", '', $sql)),
|
||||
fn (string $tok) => '' !== $tok
|
||||
))
|
||||
;
|
||||
|
||||
self::assertEquals(
|
||||
"SELECT 'test' AS key, jsonb_build_object('id', a.column) AS identifiers, ".
|
||||
"a.datecolumn::date AS doc_date FROM my_table a",
|
||||
'a.datecolumn::date AS doc_date FROM my_table a',
|
||||
$filteredSql
|
||||
);
|
||||
self::assertEquals([], $params);
|
||||
|
@@ -19,7 +19,6 @@ use Chill\DocStoreBundle\GenericDoc\Manager;
|
||||
use Chill\DocStoreBundle\GenericDoc\GenericDocForAccompanyingPeriodProviderInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -28,6 +27,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class ManagerTest extends KernelTestCase
|
||||
@@ -52,7 +52,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $period) {
|
||||
throw new \UnexpectedValueException("period not found");
|
||||
throw new \UnexpectedValueException('period not found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -73,7 +73,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $person) {
|
||||
throw new \UnexpectedValueException("person found");
|
||||
throw new \UnexpectedValueException('person found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -94,7 +94,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $period) {
|
||||
throw new \UnexpectedValueException("period not found");
|
||||
throw new \UnexpectedValueException('period not found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -115,7 +115,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $person) {
|
||||
throw new \UnexpectedValueException("person not found");
|
||||
throw new \UnexpectedValueException('person not found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -136,7 +136,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $person) {
|
||||
throw new \UnexpectedValueException("person not found");
|
||||
throw new \UnexpectedValueException('person not found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -157,7 +157,7 @@ class ManagerTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $period) {
|
||||
throw new \UnexpectedValueException("period not found");
|
||||
throw new \UnexpectedValueException('period not found');
|
||||
}
|
||||
|
||||
$manager = new Manager(
|
||||
@@ -174,7 +174,7 @@ class ManagerTest extends KernelTestCase
|
||||
|
||||
final readonly class SimpleGenericDocAccompanyingPeriodProvider implements GenericDocForAccompanyingPeriodProviderInterface
|
||||
{
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, ?\DateTimeImmutable $startDate = null, ?\DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$query = new FetchQuery(
|
||||
'accompanying_course_document_dummy',
|
||||
@@ -196,7 +196,7 @@ final readonly class SimpleGenericDocAccompanyingPeriodProvider implements Gener
|
||||
|
||||
final readonly class SimpleGenericDocPersonProvider implements GenericDocForPersonProviderInterface
|
||||
{
|
||||
public function buildFetchQueryForPerson(Person $person, ?DateTimeImmutable $startDate = null, ?DateTimeImmutable $endDate = null, ?string $content = null, ?string $origin = null): FetchQueryInterface
|
||||
public function buildFetchQueryForPerson(Person $person, \DateTimeImmutable $startDate = null, \DateTimeImmutable $endDate = null, string $content = null, string $origin = null): FetchQueryInterface
|
||||
{
|
||||
$query = new FetchQuery(
|
||||
'dummy_person_doc',
|
||||
|
@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
|
||||
use Chill\DocStoreBundle\GenericDoc\Providers\AccompanyingCourseDocumentGenericDocProvider;
|
||||
use Chill\DocStoreBundle\Security\Authorization\AccompanyingCourseDocumentVoter;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
@@ -23,6 +22,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase
|
||||
@@ -40,14 +40,14 @@ class AccompanyingCourseDocumentGenericDocProviderTest extends KernelTestCase
|
||||
/**
|
||||
* @dataProvider provideSearchArguments
|
||||
*/
|
||||
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content = null): void
|
||||
public function testWithoutAnyArgument(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, string $content = null): void
|
||||
{
|
||||
$period = $this->entityManager->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
|
||||
->setMaxResults(1)
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $period) {
|
||||
throw new \UnexpectedValueException("period not found");
|
||||
throw new \UnexpectedValueException('period not found');
|
||||
}
|
||||
|
||||
$security = $this->prophesize(Security::class);
|
||||
|
@@ -15,7 +15,6 @@ use Chill\DocStoreBundle\GenericDoc\FetchQueryToSqlBuilder;
|
||||
use Chill\DocStoreBundle\GenericDoc\Providers\PersonDocumentGenericDocProvider;
|
||||
use Chill\DocStoreBundle\Repository\PersonDocumentACLAwareRepositoryInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
@@ -23,6 +22,7 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class PersonDocumentGenericDocProviderTest extends KernelTestCase
|
||||
@@ -42,11 +42,12 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataBuildFetchQueryForPerson
|
||||
*
|
||||
* @throws \Doctrine\DBAL\Exception
|
||||
* @throws \Doctrine\ORM\NoResultException
|
||||
* @throws \Doctrine\ORM\NonUniqueResultException
|
||||
*/
|
||||
public function testBuildFetchQueryForPerson(?DateTimeImmutable $startDate, ?DateTimeImmutable $endDate, ?string $content): void
|
||||
public function testBuildFetchQueryForPerson(?\DateTimeImmutable $startDate, ?\DateTimeImmutable $endDate, ?string $content): void
|
||||
{
|
||||
$security = $this->prophesize(Security::class);
|
||||
$person = $this->entityManager->createQuery('SELECT a FROM '.Person::class.' a')
|
||||
@@ -54,7 +55,7 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
|
||||
->getSingleResult();
|
||||
|
||||
if (null === $person) {
|
||||
throw new \UnexpectedValueException("person found");
|
||||
throw new \UnexpectedValueException('person found');
|
||||
}
|
||||
|
||||
$provider = new PersonDocumentGenericDocProvider(
|
||||
@@ -69,16 +70,16 @@ class PersonDocumentGenericDocProviderTest extends KernelTestCase
|
||||
$nb = $this->entityManager->getConnection()
|
||||
->fetchOne("SELECT COUNT(*) AS nb FROM ({$sql}) AS sq", $params, $types);
|
||||
|
||||
self::assertIsInt($nb, "Test that the query is syntactically correct");
|
||||
self::assertIsInt($nb, 'Test that the query is syntactically correct');
|
||||
}
|
||||
|
||||
public function provideDataBuildFetchQueryForPerson(): iterable
|
||||
{
|
||||
yield [null, null, null];
|
||||
yield [new DateTimeImmutable('1 year ago'), null, null];
|
||||
yield [null, new DateTimeImmutable('1 year ago'), null];
|
||||
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), null];
|
||||
yield [new \DateTimeImmutable('1 year ago'), null, null];
|
||||
yield [null, new \DateTimeImmutable('1 year ago'), null];
|
||||
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), null];
|
||||
yield [null, null, 'test'];
|
||||
yield [new DateTimeImmutable('2 years ago'), new DateTimeImmutable('1 year ago'), 'test'];
|
||||
yield [new \DateTimeImmutable('2 years ago'), new \DateTimeImmutable('1 year ago'), 'test'];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user