Re-associate activity exports and filters

Some filter can work on both exports and lists associated to persons and accompanyings periods. They are moved to a more common namespace.

The modifiers in list are also fixed to allow an association with these filters.
This commit is contained in:
2023-09-13 10:00:48 +02:00
parent fcc00fdf8f
commit 4e27d71bea
39 changed files with 197 additions and 114 deletions

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialActionAggregator;
use Chill\ActivityBundle\Export\Aggregator\BySocialActionAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;

View File

@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\BySocialIssueAggregator;
use Chill\ActivityBundle\Export\Aggregator\BySocialIssueAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator;
use Chill\ActivityBundle\Export\Aggregator\ByThirdpartyAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,7 +28,7 @@ final class ByThirdpartyAggregatorTest extends AbstractAggregatorTest
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.activity.export.bythirdparty_aggregator');
$this->aggregator = self::$container->get(ByThirdpartyAggregator::class);
}
public function getAggregator()

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByCreatorAggregator;
use Chill\ActivityBundle\Export\Aggregator\ByCreatorAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\CreatorScopeAggregator;
use Chill\ActivityBundle\Export\Aggregator\CreatorScopeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -20,7 +20,7 @@ use Doctrine\ORM\EntityManagerInterface;
* @internal
* @coversNothing
*/
final class UserScopeAggregatorTest extends AbstractAggregatorTest
final class CreatorScopeAggregatorTest extends AbstractAggregatorTest
{
private CreatorScopeAggregator $aggregator;

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\DateAggregator;
use Chill\ActivityBundle\Export\Aggregator\DateAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,7 +28,7 @@ final class DateAggregatorTest extends AbstractAggregatorTest
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.activity.export.date_aggregator');
$this->aggregator = self::$container->get(DateAggregator::class);
}
public function getAggregator()

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\LocationTypeAggregator;
use Chill\ActivityBundle\Export\Aggregator\LocationTypeAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,7 +28,7 @@ final class LocationTypeAggregatorTest extends AbstractAggregatorTest
{
self::bootKernel();
$this->aggregator = self::$container->get('chill.activity.export.locationtype_aggregator');
$this->aggregator = self::$container->get(LocationTypeAggregator::class);
}
public function getAggregator()

View File

@@ -13,9 +13,10 @@ namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter;
use Chill\ActivityBundle\Export\Filter\ActivityTypeFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr;
@@ -25,13 +26,13 @@ use Doctrine\ORM\Query\Expr;
*/
final class ActivityTypeFilterTest extends AbstractFilterTest
{
private ActivityTypeFilter $filter;
private \Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter $filter;
protected function setUp(): void
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.filter_activitytype');
$this->filter = self::$container->get(\Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter::class);
}
public function getFilter()
@@ -47,13 +48,14 @@ final class ActivityTypeFilterTest extends AbstractFilterTest
->from(ActivityType::class, 'at')
->select('at')
->getQuery()
->setMaxResults(1)
->getResult();
$data = [];
foreach ($array as $a) {
$data[] = [
'accepted_activitytypes' => $a,
'accepted_activitytypes' => new ArrayCollection([$a]),
];
}

View File

@@ -12,9 +12,9 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
/**
@@ -23,13 +23,13 @@ use Doctrine\ORM\EntityManagerInterface;
*/
final class BySocialActionFilterTest extends AbstractFilterTest
{
private BySocialActionFilter $filter;
private \Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter $filter;
protected function setUp(): void
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.bysocialaction_filter');
$this->filter = self::$container->get(\Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialActionFilter::class);
}
public function getFilter()
@@ -39,19 +39,22 @@ final class BySocialActionFilterTest extends AbstractFilterTest
public function getFormData(): array
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(SocialAction::class, 'sa')
->select('sa')
->getQuery()
->setMaxResults(1)
->getResult();
$data = [];
foreach ($array as $a) {
$data[] = [
'accepted_socialactions' => $a,
'accepted_socialactions' => new ArrayCollection([$a]),
];
}
@@ -60,9 +63,7 @@ final class BySocialActionFilterTest extends AbstractFilterTest
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);

View File

@@ -15,6 +15,7 @@ use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\BySocialIssueFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface;
/**
@@ -29,7 +30,7 @@ final class BySocialIssueFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.bysocialissue_filter');
$this->filter = self::$container->get(BySocialIssueFilter::class);
}
public function getFilter()
@@ -39,19 +40,21 @@ final class BySocialIssueFilterTest extends AbstractFilterTest
public function getFormData(): array
{
self::bootKernel();
$em = self::$container->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(SocialIssue::class, 'si')
->select('si')
->getQuery()
->setMaxResults(2)
->getResult();
$data = [];
foreach ($array as $a) {
$data[] = [
'accepted_socialissues' => $a,
'accepted_socialissues' => new ArrayCollection([$a]),
];
}

View File

@@ -9,10 +9,15 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
<<<<<<<< HEAD:src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php
use Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter;
========
use Chill\ActivityBundle\Export\Filter\ByCreatorFilter;
use Chill\ActivityBundle\Export\Filter\UserFilter;
>>>>>>>> 1f4d912d8 (Re-associate activity exports and filters):src/Bundle/ChillActivityBundle/Tests/Export/Filter/ByCreatorFilterTest.php
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;

View File

@@ -29,7 +29,7 @@ final class ActivityDateFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.date_filter');
$this->filter = self::$container->get(ActivityDateFilter::class);
}
public function getFilter()

View File

@@ -0,0 +1,76 @@
<?php
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\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ByCreatorFilter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class ByUserFilterTest extends AbstractFilterTest
{
private ByCreatorFilter $filter;
protected function setUp(): void
{
self::bootKernel();
$this->filter = self::$container->get(ByCreatorFilter::class);
}
public function getFilter()
{
return $this->filter;
}
public function getFormData(): array
{
$em = self::$container->get(EntityManagerInterface::class);
$array = $em->createQueryBuilder()
->from(User::class, 'u')
->select('u')
->getQuery()
->getResult();
$data = [];
foreach ($array as $a) {
$data[] = [
'accepted_users' => $a,
];
}
return $data;
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity')
->join('activity.users', 'actusers'),
];
}
}

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter;
use Chill\ActivityBundle\Export\Filter\EmergencyFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,7 +28,7 @@ final class EmergencyFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.emergency_filter');
$this->filter = self::$container->get(EmergencyFilter::class);
}
public function getFilter()

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter;
use Chill\ActivityBundle\Export\Filter\LocationTypeFilter;
use Chill\MainBundle\Entity\LocationType;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -29,7 +29,7 @@ final class LocationTypeFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.locationtype_filter');
$this->filter = self::$container->get(LocationTypeFilter::class);
}
public function getFilter()

View File

@@ -54,7 +54,7 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
$data[] = [
'date_from' => DateTime::createFromFormat('Y-m-d', '2021-07-01'),
'date_to' => DateTime::createFromFormat('Y-m-d', '2022-07-01'),
'reasons' => $a,
'reasons' => [$a],
];
}
@@ -72,7 +72,9 @@ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
return [
$em->createQueryBuilder()
->select('count(activity.id)')
->from(Activity::class, 'activity'),
->from(Activity::class, 'activity')
->join('activity.person', 'person')
,
];
}
}

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\SentReceivedFilter;
use Chill\ActivityBundle\Export\Filter\SentReceivedFilter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -28,7 +28,7 @@ final class SentReceivedFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.sentreceived_filter');
$this->filter = self::$container->get(SentReceivedFilter::class);
}
public function getFilter()

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\UserFilter;
use Chill\ActivityBundle\Export\Filter\UserFilter;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -29,7 +29,7 @@ final class UserFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.user_filter');
$this->filter = self::$container->get(UserFilter::class);
}
public function getFilter()

View File

@@ -9,10 +9,10 @@ declare(strict_types=1);
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
namespace Chill\ActivityBundle\Tests\Export\Filter;
use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Filter\ACPFilters\UserScopeFilter;
use Chill\ActivityBundle\Export\Filter\UserScopeFilter;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Doctrine\ORM\EntityManagerInterface;
@@ -29,7 +29,7 @@ final class UserScopeFilterTest extends AbstractFilterTest
{
self::bootKernel();
$this->filter = self::$container->get('chill.activity.export.userscope_filter');
$this->filter = self::$container->get(UserScopeFilter::class);
}
public function getFilter()