From d5d3866122c1ffb6d636c2a980962ed70ece0a79 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 20 Jul 2022 23:17:05 +0200 Subject: [PATCH] fix conflict with where clause in indicator ; initiate a filter test --- .../Export/Export/CountAccompanyingCourse.php | 3 - .../Export/StatAccompanyingCourseDuration.php | 3 - .../Export/Filter/SocialIssueFilter.php | 6 +- .../Export/Filter/StepFilter.php | 7 ++- .../Export/Filter/SocialIssueFilterTest.php | 63 +++++++++++++++++++ 5 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php index 69ab19a55..b7b57d3cd 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountAccompanyingCourse.php @@ -93,9 +93,6 @@ class CountAccompanyingCourse implements ExportInterface, GroupedExportInterface $qb->select('COUNT(acp.id) AS export_result') ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') - ->where($expr->neq( - 'acp.step', $expr->literal('DRAFT') - )) ; return $qb; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php index 639fa56a4..8747c288a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/StatAccompanyingCourseDuration.php @@ -131,9 +131,6 @@ class StatAccompanyingCourseDuration implements ExportInterface, GroupedExportIn ELSE :force_closingDate END ) - acp.openingDate ) AS export_result') - ->where($expr->neq( - 'acp.step', $expr->literal('DRAFT') - )) ->setParameter('force_closingDate', $force_closingdate) ; diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php index f82873dcd..b26e523eb 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialIssueFilter.php @@ -82,10 +82,10 @@ class SocialIssueFilter implements FilterInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->join('acp.socialIssues', 's'); + $qb->join('acp.socialIssues', 'si'); $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('s.id', ':socialissues'); + $clause = $qb->expr()->in('si.id', ':socialissues'); if ($where instanceof Andx) { $where->add($clause); @@ -128,7 +128,7 @@ class SocialIssueFilter implements FilterInterface return $item->getId(); }, $array); - $unique_ids = array_unique($ids); dump($unique_ids); + $unique_ids = array_unique($ids); return array_values( array_intersect_key($array, $unique_ids)); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php index 4c2183a7a..ac47be949 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/StepFilter.php @@ -70,8 +70,11 @@ class StepFilter implements FilterInterface $where = $qb->getDQLPart('where'); $clause = $qb->expr()->eq('acp.step', ':step'); - // override original where clause - $where = $qb->expr()->andX($clause); + if ($where instanceof Andx) { + $where->add($clause); + } else { + $where = $qb->expr()->andX($clause); + } $qb->add('where', $where); $qb->setParameter('step', $data['accepted_step']); diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php new file mode 100644 index 000000000..ed520e90b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialIssueFilterTest.php @@ -0,0 +1,63 @@ +filter = self::$container->get('chill.person.export.filter_socialissue'); + } catch (ServiceNotFoundException $e) { + $this->markTestSkipped('Filter service is not found'); + } + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + return [ + ['accepted_socialissue' => [ + + ]], + ['accepted_socialissue' => [ + + ]], + ['accepted_socialissue' => [ + + ]], + ]; + } + + public function getQueryBuilders() + { + // TODO: Implement getQueryBuilders() method. + } + +} \ No newline at end of file