diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php index ed591e957..5cdce5b31 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/LocationFilter.php @@ -50,7 +50,7 @@ class LocationFilter implements FilterInterface { $builder->add('accepted_location', PickUserLocationType::class, [ 'multiple' => true, - 'label' => 'pick location' + 'label' => 'pick location', ]); } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php index bf370f71b..976f4171c 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Export/ListAsideActivity.php @@ -1,10 +1,18 @@ format('H:i:s'); } @@ -118,7 +122,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface case 'createdAt': case 'updatedAt': case 'date': - return $this->dateTimeHelper->getLabel('export.aside_activity.'.$key); + return $this->dateTimeHelper->getLabel('export.aside_activity.' . $key); case 'agent_id': case 'creator_id': @@ -165,7 +169,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface }; default: - throw new \LogicException('this key is not supported : ' . $key); + throw new LogicException('this key is not supported : ' . $key); } } @@ -182,7 +186,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface 'aside_activity_type', 'date', 'duration', - 'note' + 'note', ]; } @@ -195,6 +199,11 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface return $query->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY); } + public function getTitle() + { + return 'export.aside_activity.List of aside activities'; + } + public function getType(): string { return Declarations::ASIDE_ACTIVITY_TYPE; @@ -204,8 +213,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface { $qb = $this->em->createQueryBuilder() ->from(AsideActivity::class, 'aside') - ->leftJoin('aside.agent', 'agent') - ; + ->leftJoin('aside.agent', 'agent'); $qb ->addSelect('aside.id AS id') @@ -218,8 +226,7 @@ final class ListAsideActivity implements ListInterface, GroupedExportInterface ->addSelect('IDENTITY(aside.type) AS aside_activity_type') ->addSelect('aside.date') ->addSelect('aside.duration') - ->addSelect('aside.note') - ; + ->addSelect('aside.note'); return $qb; } diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php index 2d49b3d57..7a1b6f4dc 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByDateFilter.php @@ -17,7 +17,6 @@ use Chill\MainBundle\Form\Type\Export\FilterType; use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormError; diff --git a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php index c2a3b4c54..795c813cd 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Export/Filter/ByUserFilter.php @@ -15,7 +15,6 @@ use Chill\AsideActivityBundle\Export\Declarations; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\PickUserDynamicType; use Chill\MainBundle\Templating\Entity\UserRender; -use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php index 59adf49af..c3c2a66bf 100644 --- a/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ChargeKindType.php @@ -30,7 +30,7 @@ class ChargeKindType extends AbstractType ]) ->add('kind', TextType::class, [ 'label' => 'budget.admin.form.Charge_kind_key', - 'help' => 'budget.admin.form.This kind must contains only alphabeticals characters, and dashes. This string is in use during document generation. Changes may have side effect on document' + 'help' => 'budget.admin.form.This kind must contains only alphabeticals characters, and dashes. This string is in use during document generation. Changes may have side effect on document', ]) ->add('ordering', NumberType::class) ->add('isActive', CheckboxType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php index 0605b8731..41d3a8b53 100644 --- a/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php +++ b/src/Bundle/ChillBudgetBundle/Form/Admin/ResourceKindType.php @@ -30,7 +30,7 @@ class ResourceKindType extends AbstractType ]) ->add('kind', TextType::class, [ 'label' => 'budget.admin.form.Resource_kind_key', - 'help' => 'budget.admin.form.This kind must contains only alphabeticals characters, and dashes. This string is in use during document generation. Changes may have side effect on document' + 'help' => 'budget.admin.form.This kind must contains only alphabeticals characters, and dashes. This string is in use during document generation. Changes may have side effect on document', ]) ->add('ordering', NumberType::class) ->add('isActive', CheckboxType::class, [ diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php index 10d02749a..01f5cd737 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepository.php @@ -49,8 +49,7 @@ final class ChargeKindRepository implements ChargeKindRepositoryInterface ->where($qb->expr()->eq('c.isActive', 'true')) ->orderBy('c.ordering', 'ASC') ->getQuery() - ->getResult() - ; + ->getResult(); } /** diff --git a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php index 5099a5674..fb8c9dc35 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ChargeKindRepositoryInterface.php @@ -28,8 +28,6 @@ interface ChargeKindRepositoryInterface extends ObjectRepository */ public function findAllActive(): array; - public function findOneByKind(string $kind): ?ChargeKind; - /** * @return ChargeType[] */ @@ -45,5 +43,7 @@ interface ChargeKindRepositoryInterface extends ObjectRepository public function findOneBy(array $criteria): ?ChargeKind; + public function findOneByKind(string $kind): ?ChargeKind; + public function getClassName(): string; } diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php index 140bb7cc7..f7935c5b7 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceKindRepository.php @@ -49,8 +49,7 @@ final class ResourceKindRepository implements ResourceKindRepositoryInterface ->where($qb->expr()->eq('r.isActive', 'true')) ->orderBy('r.ordering', 'ASC') ->getQuery() - ->getResult() - ; + ->getResult(); } /** diff --git a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php index b3f0a41da..12f9fd52f 100644 --- a/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php +++ b/src/Bundle/ChillBudgetBundle/Repository/ResourceRepository.php @@ -34,7 +34,7 @@ class ResourceRepository extends EntityRepository //->andWhere('c.startDate < :date') // TODO: there is a misconception here, the end date must be lower or null. startDate are never null //->andWhere('c.startDate < :date OR c.startDate IS NULL'); - ; +; if (null !== $sort) { $qb->orderBy($sort); diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index 2f401f1ec..ad2a014ed 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -13,9 +13,7 @@ namespace Chill\BudgetBundle\Service\Summary; use Chill\BudgetBundle\Entity\ChargeKind; use Chill\BudgetBundle\Entity\ResourceKind; -use Chill\BudgetBundle\Repository\ChargeKindRepository; use Chill\BudgetBundle\Repository\ChargeKindRepositoryInterface; -use Chill\BudgetBundle\Repository\ResourceKindRepository; use Chill\BudgetBundle\Repository\ResourceKindRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\Household\Household; diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index cf8c00efe..7fcda6b11 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -20,12 +20,15 @@ use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\HouseholdMember; use Chill\PersonBundle\Entity\Person; +use DateTimeImmutable; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query; use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; +use ReflectionClass; +use RuntimeException; /** * @internal @@ -47,10 +50,9 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryCharges->setParameters(Argument::type('array')) - ->will(function ($args, $query) { + ->will(static function ($args, $query) { return $query; - }) - ; + }); $queryResources = $this->prophesize(AbstractQuery::class); $queryResources->getResult()->willReturn([ @@ -61,23 +63,23 @@ final class SummaryBudgetTest extends TestCase ], ]); $queryResources->setParameters(Argument::type('array')) - ->will(function ($args, $query) { + ->will(static function ($args, $query) { return $query; - }) - ; + }); $em = $this->prophesize(EntityManagerInterface::class); $em->createNativeQuery(Argument::type('string'), Argument::type(Query\ResultSetMapping::class)) - ->will(function ($args) use ($queryResources, $queryCharges) { + ->will(static function ($args) use ($queryResources, $queryCharges) { if (false !== strpos($args[0], 'chill_budget.resource')) { return $queryResources->reveal(); } + if (false !== strpos($args[0], 'chill_budget.charge')) { return $queryCharges->reveal(); } - throw new \RuntimeException('this query does not have a stub counterpart: '.$args[0]); - }) - ; + + throw new RuntimeException('this query does not have a stub counterpart: ' . $args[0]); + }); $chargeRepository = $this->prophesize(ChargeKindRepositoryInterface::class); $chargeRepository->findAll()->willReturn([ @@ -98,24 +100,23 @@ final class SummaryBudgetTest extends TestCase $resourceRepository->findOneByKind('misc')->willReturn($misc); $translatableStringHelper = $this->prophesize(TranslatableStringHelperInterface::class); - $translatableStringHelper->localize(Argument::type('array'))->will(function ($arg) { + $translatableStringHelper->localize(Argument::type('array'))->will(static function ($arg) { return $arg[0]['fr']; }); $person = new Person(); - $personReflection = new \ReflectionClass($person); + $personReflection = new ReflectionClass($person); $personIdReflection = $personReflection->getProperty('id'); $personIdReflection->setAccessible(true); $personIdReflection->setValue($person, 1); $household = new Household(); - $householdReflection = new \ReflectionClass($household); + $householdReflection = new ReflectionClass($household); $householdId = $householdReflection->getProperty('id'); $householdId->setAccessible(true); $householdId->setValue($household, 1); $householdMember = (new HouseholdMember())->setPerson($person) - ->setStartDate(new \DateTimeImmutable('1 month ago')) - ; + ->setStartDate(new DateTimeImmutable('1 month ago')); $household->addMember($householdMember); $summaryBudget = new SummaryBudget( diff --git a/src/Bundle/ChillBudgetBundle/migrations/Version20230209161546.php b/src/Bundle/ChillBudgetBundle/migrations/Version20230209161546.php index 618b0c982..4495db8a7 100644 --- a/src/Bundle/ChillBudgetBundle/migrations/Version20230209161546.php +++ b/src/Bundle/ChillBudgetBundle/migrations/Version20230209161546.php @@ -2,6 +2,13 @@ declare(strict_types=1); +/* + * Chill is a software for social workers + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + namespace Chill\Migrations\Budget; use Doctrine\DBAL\Schema\Schema; @@ -9,6 +16,12 @@ use Doctrine\Migrations\AbstractMigration; final class Version20230209161546 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('DROP INDEX resource_kind_unique_type_idx'); + $this->addSql('DROP INDEX charge_kind_unique_type_idx'); + } + public function getDescription(): string { return 'Budget: add unique constraint on kind for charge_kind and resource_kind'; @@ -21,10 +34,4 @@ final class Version20230209161546 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX resource_kind_unique_type_idx ON chill_budget.resource_type (kind);'); $this->addSql('CREATE UNIQUE INDEX charge_kind_unique_type_idx ON chill_budget.charge_type (kind);'); } - - public function down(Schema $schema): void - { - $this->addSql('DROP INDEX resource_kind_unique_type_idx'); - $this->addSql('DROP INDEX charge_kind_unique_type_idx'); - } } diff --git a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php index 6f153acd8..eeab4932b 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php +++ b/src/Bundle/ChillDocGeneratorBundle/Controller/DocGeneratorTemplateController.php @@ -39,6 +39,7 @@ use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; use Symfony\Contracts\HttpClient\HttpClientInterface; use function strlen; +use const JSON_PRETTY_PRINT; final class DocGeneratorTemplateController extends AbstractController { @@ -255,7 +256,7 @@ final class DocGeneratorTemplateController extends AbstractController // if is test, render the data or generate the doc if ($isTest && isset($form) && $form['show_data']->getData()) { return $this->render('@ChillDocGenerator/Generator/debug_value.html.twig', [ - 'datas' => json_encode($context->getData($template, $entity, $contextGenerationData), JSON_PRETTY_PRINT) + 'datas' => json_encode($context->getData($template, $entity, $contextGenerationData), JSON_PRETTY_PRINT), ]); } elseif ($isTest) { $generated = $this->generator->generateDocFromTemplate( diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php index 0f3412859..4360413b4 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/GeneratorException.php @@ -1,19 +1,34 @@ */ private array $errors; - public function __construct(array $errors = [], \Throwable $previous = null) + public function __construct(array $errors = [], ?Throwable $previous = null) { $this->errors = $errors; - parent::__construct("Could not generate the document", 15252, - $previous); + parent::__construct( + 'Could not generate the document', + 15252, + $previous + ); } /** diff --git a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php index 85c82cf95..37540a2f8 100644 --- a/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php +++ b/src/Bundle/ChillDocGeneratorBundle/Service/Generator/ObjectReadyException.php @@ -1,11 +1,22 @@ validator->validate($collection, $this->getConstraint()); + + $this->assertNoViolation(); + } + protected function createValidator() { $personRender = $this->prophesize(PersonRenderInterface::class); @@ -37,26 +63,4 @@ class ParticipationOverlapValidatorTest extends ConstraintValidatorTestCase return new ParticipationOverlapValidator($personRender->reveal(), $thirdPartyRender->reveal()); } - - public function testOneParticipation() - { - $period = new AccompanyingPeriod(); - $person = new Person(); - - $collection = new ArrayCollection([ - new AccompanyingPeriodParticipation($period, $person) - ]); - - $this->validator->validate($collection, $this->getConstraint()); - - $this->assertNoViolation(); - } - - /** - * @return mixed - */ - public function getConstraint() - { - return new ParticipationOverlap(); - } }