mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-03 21:34:59 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,20 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
@@ -22,59 +12,59 @@ namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
|
||||
/**
|
||||
* Add tests for ActivityReasonAggregator
|
||||
* Add tests for ActivityReasonAggregator.
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
|
||||
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.reason_aggregator');
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
public function getAggregator()
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array('level' => 'reasons'),
|
||||
array('level' => 'categories')
|
||||
);
|
||||
return [
|
||||
['level' => 'reasons'],
|
||||
['level' => 'categories'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return array(
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity'),
|
||||
@@ -86,8 +76,7 @@ class ActivityReasonAggregatorTest extends AbstractAggregatorTest
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category')
|
||||
);
|
||||
->join('reasons.category', 'category'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
@@ -22,58 +12,58 @@ namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
|
||||
/**
|
||||
* Add tests for ActivityTypeAggregator
|
||||
* Add tests for ActivityTypeAggregator.
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
|
||||
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.type_aggregator');
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
public function getAggregator()
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array()
|
||||
);
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return array(
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity'),
|
||||
@@ -85,8 +75,7 @@ class ActivityTypeAggregatorTest extends AbstractAggregatorTest
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category')
|
||||
);
|
||||
->join('reasons.category', 'category'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
@@ -22,57 +12,58 @@ namespace Chill\ActivityBundle\Tests\Aggregator;
|
||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||
|
||||
/**
|
||||
* Add tests for ActivityUsernAggregator
|
||||
* Add tests for ActivityUsernAggregator.
|
||||
*
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator
|
||||
*/
|
||||
private $aggregator;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
|
||||
|
||||
|
||||
$this->aggregator = $container->get('chill.activity.export.user_aggregator');
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
public function getAggregator()
|
||||
{
|
||||
return $this->aggregator;
|
||||
}
|
||||
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array()
|
||||
);
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return array(
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity'),
|
||||
@@ -84,8 +75,7 @@ class ActivityUserAggregatorTest extends AbstractAggregatorTest
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category')
|
||||
);
|
||||
->join('reasons.category', 'category'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,32 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class CountActivityTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var
|
||||
* @var
|
||||
*/
|
||||
private $export;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
|
||||
$this->export = $container->get('chill.activity.export.count_activity');
|
||||
}
|
||||
|
||||
|
||||
public function getExport()
|
||||
{
|
||||
return $this->export;
|
||||
@@ -34,17 +39,16 @@ class CountActivityTest extends AbstractExportTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array()
|
||||
);
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
public function getModifiersCombination()
|
||||
{
|
||||
return array(
|
||||
array('activity'),
|
||||
array('activity', 'person')
|
||||
);
|
||||
return [
|
||||
['activity'],
|
||||
['activity', 'person'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||
@@ -22,67 +12,33 @@ namespace Chill\ActivityBundle\Tests\Export\Export;
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ListActivityTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\ActivityBundle\Export\Export\ListActivity
|
||||
*/
|
||||
private $export;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
|
||||
$this->export = $container->get('chill.activity.export.list_activity');
|
||||
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array('fields' => array(
|
||||
'id',
|
||||
'date',
|
||||
'durationTime',
|
||||
'attendee',
|
||||
'user_username',
|
||||
'circle_name',
|
||||
'type_name',
|
||||
'person_firstname',
|
||||
'person_lastname',
|
||||
'person_id'
|
||||
)),
|
||||
array('fields' => array(
|
||||
'id',
|
||||
'list_reasons'
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
public function getModifiersCombination()
|
||||
{
|
||||
return array(
|
||||
array('activity'),
|
||||
array('activity', 'person')
|
||||
);
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
public function getExport()
|
||||
@@ -90,4 +46,33 @@ class ListActivityTest extends AbstractExportTest
|
||||
return $this->export;
|
||||
}
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return [
|
||||
['fields' => [
|
||||
'id',
|
||||
'date',
|
||||
'durationTime',
|
||||
'attendee',
|
||||
'user_username',
|
||||
'circle_name',
|
||||
'type_name',
|
||||
'person_firstname',
|
||||
'person_lastname',
|
||||
'person_id',
|
||||
]],
|
||||
['fields' => [
|
||||
'id',
|
||||
'list_reasons',
|
||||
]],
|
||||
];
|
||||
}
|
||||
|
||||
public function getModifiersCombination()
|
||||
{
|
||||
return [
|
||||
['activity'],
|
||||
['activity', 'person'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -1,32 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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\Export;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractExportTest;
|
||||
|
||||
/**
|
||||
* Test the "sum" part of StatActivityDuration
|
||||
* Test the "sum" part of StatActivityDuration.
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class StatActivityDurationSumTest extends AbstractExportTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\ActivityBundle\Export\Export\StatActivityDuration
|
||||
*/
|
||||
private $export;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
/* @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
|
||||
$this->export = $container->get('chill.activity.export.sum_activity_duration');
|
||||
}
|
||||
|
||||
|
||||
public function getExport()
|
||||
{
|
||||
return $this->export;
|
||||
@@ -34,17 +41,16 @@ class StatActivityDurationSumTest extends AbstractExportTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
return array(
|
||||
array()
|
||||
);
|
||||
return [
|
||||
[],
|
||||
];
|
||||
}
|
||||
|
||||
public function getModifiersCombination()
|
||||
{
|
||||
return array(
|
||||
array('activity'),
|
||||
array('activity', 'person')
|
||||
);
|
||||
return [
|
||||
['activity'],
|
||||
['activity', 'person'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,20 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2017 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Filter;
|
||||
@@ -23,37 +13,34 @@ use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\PersonBundle\Export\Filter\GenderFilter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
|
||||
$this->filter = $container->get('chill.activity.export.reason_filter');
|
||||
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
@@ -61,36 +48,35 @@ class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager')
|
||||
;
|
||||
|
||||
$reasons = $em->createQuery("SELECT reason "
|
||||
. "FROM ChillActivityBundle:ActivityReason reason")
|
||||
->getResult();
|
||||
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
$reasons = $em->createQuery('SELECT reason '
|
||||
. 'FROM ChillActivityBundle:ActivityReason reason')
|
||||
->getResult();
|
||||
|
||||
// generate an array of 5 different combination of results
|
||||
for ($i=0; $i < 5; $i++) {
|
||||
$r[] = array('reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1)));
|
||||
for ($i = 0; 5 > $i; ++$i) {
|
||||
$r[] = ['reasons' => new ArrayCollection(array_splice($reasons, ($i + 1) * -1))];
|
||||
}
|
||||
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return array(
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity'),
|
||||
@@ -102,8 +88,7 @@ class ActivityReasonFilterTest extends AbstractFilterTest
|
||||
->select('count(activity.id)')
|
||||
->from('ChillActivityBundle:Activity', 'activity')
|
||||
->join('activity.reasons', 'reasons')
|
||||
->join('reasons.category', 'category')
|
||||
);
|
||||
->join('reasons.category', 'category'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,56 +1,47 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2017 Champs Libres Cooperative <info@champs-libres.coop>
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\ActivityBundle\Tests\Filter;
|
||||
|
||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter
|
||||
*/
|
||||
private $filter;
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
static::bootKernel();
|
||||
|
||||
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
|
||||
$this->filter = $container->get('chill.activity.export.'
|
||||
. 'person_having_an_activity_between_date_filter');
|
||||
|
||||
|
||||
// add a fake request with a default locale (used in translatable string)
|
||||
$prophet = new \Prophecy\Prophet;
|
||||
$prophet = new \Prophecy\Prophet();
|
||||
$request = $prophet->prophesize();
|
||||
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
|
||||
$request->getLocale()->willReturn('fr');
|
||||
|
||||
|
||||
$container->get('request_stack')
|
||||
->push($request->reveal());
|
||||
->push($request->reveal());
|
||||
}
|
||||
|
||||
|
||||
public function getFilter()
|
||||
{
|
||||
return $this->filter;
|
||||
@@ -58,49 +49,33 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
|
||||
public function getFormData()
|
||||
{
|
||||
$date_from = \DateTime::createFromFormat('Y-m-d', '2015-01-15');
|
||||
$date_to = new \DateTime(); // today
|
||||
$date_from = DateTime::createFromFormat('Y-m-d', '2015-01-15');
|
||||
$date_to = new DateTime(); // today
|
||||
$reasons = $this->getActivityReasons();
|
||||
|
||||
|
||||
$data = array();
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$data[] = array(
|
||||
$data = [];
|
||||
|
||||
for ($i = 0; 4 > $i; ++$i) {
|
||||
$data[] = [
|
||||
'date_from' => $date_from,
|
||||
'date_to' => $date_to,
|
||||
'reasons' => array_slice($reasons, 0, 1 + $i)
|
||||
);
|
||||
'date_to' => $date_to,
|
||||
'reasons' => array_slice($reasons, 0, 1 + $i),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all activity reasons
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason[]
|
||||
*/
|
||||
private function getActivityReasons()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
return static::$kernel->getContainer()
|
||||
->get('chill_activity.repository.reason')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
public function getQueryBuilders()
|
||||
{
|
||||
if (static::$kernel === null) {
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
|
||||
$em = static::$kernel->getContainer()
|
||||
->get('doctrine.orm.entity_manager');
|
||||
|
||||
return array(
|
||||
|
||||
return [
|
||||
$em->createQueryBuilder()
|
||||
->select('count(person.id)')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
@@ -112,6 +87,22 @@ class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest
|
||||
->join('activity.person', 'person')
|
||||
// add a fake where clause
|
||||
->where('person.id > 0'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all activity reasons.
|
||||
*
|
||||
* @return \Chill\ActivityBundle\Entity\ActivityReason[]
|
||||
*/
|
||||
private function getActivityReasons()
|
||||
{
|
||||
if (null === static::$kernel) {
|
||||
static::bootKernel();
|
||||
}
|
||||
|
||||
return static::$kernel->getContainer()
|
||||
->get('chill_activity.repository.reason')
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user