mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 03:08:25 +00:00 
			
		
		
		
	fix cs
This commit is contained in:
		@@ -1,5 +1,14 @@
 | 
			
		||||
<?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\MainBundle\Form\Type;
 | 
			
		||||
 | 
			
		||||
use Chill\MainBundle\Entity\LocationType;
 | 
			
		||||
@@ -40,8 +49,7 @@ class Select2LocationTypeType extends AbstractType
 | 
			
		||||
            ->setDefault('label', 'Location type')
 | 
			
		||||
            ->setDefault('label_attr', [])
 | 
			
		||||
            ->setDefault('multiple', false)
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool'])
 | 
			
		||||
        ;
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getBlockPrefix(): string
 | 
			
		||||
 
 | 
			
		||||
@@ -57,8 +57,7 @@ class Select2UserLocationType extends AbstractType
 | 
			
		||||
            ->setDefault('label', 'Current location')
 | 
			
		||||
            ->setDefault('label_attr', [])
 | 
			
		||||
            ->setDefault('multiple', false)
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool'])
 | 
			
		||||
            ;
 | 
			
		||||
            ->setAllowedTypes('multiple', ['bool']);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getBlockPrefix(): string
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,18 @@ use function is_string;
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractAggregatorTest extends KernelTestCase
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * provide data for `testAliasDidNotDisappears`.
 | 
			
		||||
     */
 | 
			
		||||
    public function dataProviderAliasDidNotDisappears()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getQueryBuilders() as $qb) {
 | 
			
		||||
            foreach ($this->getFormData() as $data) {
 | 
			
		||||
                yield [clone $qb, $data];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * provide data for `testAlterQuery`.
 | 
			
		||||
     */
 | 
			
		||||
@@ -63,18 +75,6 @@ abstract class AbstractAggregatorTest extends KernelTestCase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * provide data for `testAliasDidNotDisappears`.
 | 
			
		||||
     */
 | 
			
		||||
    public function dataProviderAliasDidNotDisappears()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getQueryBuilders() as $qb) {
 | 
			
		||||
            foreach ($this->getFormData() as $data) {
 | 
			
		||||
                yield [clone $qb, $data];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create an aggregator instance which will be used in tests.
 | 
			
		||||
     *
 | 
			
		||||
@@ -107,6 +107,28 @@ abstract class AbstractAggregatorTest extends KernelTestCase
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function getQueryBuilders();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Compare aliases array before and after that aggregator alter query.
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider dataProviderAliasDidNotDisappears
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
 | 
			
		||||
    {
 | 
			
		||||
        $aliases = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->getAggregator()->alterQuery($qb, $data);
 | 
			
		||||
 | 
			
		||||
        $alteredQuery = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
 | 
			
		||||
 | 
			
		||||
        foreach ($aliases as $alias) {
 | 
			
		||||
            $this->assertContains($alias, $alteredQuery);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * test the alteration of query by the filter.
 | 
			
		||||
     *
 | 
			
		||||
@@ -269,29 +291,4 @@ abstract class AbstractAggregatorTest extends KernelTestCase
 | 
			
		||||
            'test that the title is not empty'
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Compare aliases array before and after that aggregator alter query
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider dataProviderAliasDidNotDisappears
 | 
			
		||||
     *
 | 
			
		||||
     * @param QueryBuilder $qb
 | 
			
		||||
     * @param array $data
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
 | 
			
		||||
    {
 | 
			
		||||
        $aliases = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->getAggregator()->alterQuery($qb, $data);
 | 
			
		||||
 | 
			
		||||
        $alteredQuery = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
 | 
			
		||||
 | 
			
		||||
        foreach ($aliases as $alias) {
 | 
			
		||||
            $this->assertContains($alias, $alteredQuery);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -40,6 +40,18 @@ abstract class AbstractFilterTest extends KernelTestCase
 | 
			
		||||
        $this->prophet = $this->getProphet();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * provide data for `testAliasDidNotDisappears`.
 | 
			
		||||
     */
 | 
			
		||||
    public function dataProviderAliasDidNotDisappears()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getQueryBuilders() as $qb) {
 | 
			
		||||
            foreach ($this->getFormData() as $data) {
 | 
			
		||||
                yield [clone $qb, $data];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function dataProviderAlterQuery()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getQueryBuilders() as $qb) {
 | 
			
		||||
@@ -56,18 +68,6 @@ abstract class AbstractFilterTest extends KernelTestCase
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * provide data for `testAliasDidNotDisappears`.
 | 
			
		||||
     */
 | 
			
		||||
    public function dataProviderAliasDidNotDisappears()
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($this->getQueryBuilders() as $qb) {
 | 
			
		||||
            foreach ($this->getFormData() as $data) {
 | 
			
		||||
                yield [clone $qb, $data];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create a filter which will be used in tests.
 | 
			
		||||
     *
 | 
			
		||||
@@ -99,6 +99,28 @@ abstract class AbstractFilterTest extends KernelTestCase
 | 
			
		||||
     */
 | 
			
		||||
    abstract public function getQueryBuilders();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Compare aliases array before and after that filter alter query.
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider dataProviderAliasDidNotDisappears
 | 
			
		||||
     *
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
 | 
			
		||||
    {
 | 
			
		||||
        $aliases = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->getFilter()->alterQuery($qb, $data);
 | 
			
		||||
 | 
			
		||||
        $alteredQuery = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
 | 
			
		||||
 | 
			
		||||
        foreach ($aliases as $alias) {
 | 
			
		||||
            $this->assertContains($alias, $alteredQuery);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * test the alteration of query by the filter.
 | 
			
		||||
     *
 | 
			
		||||
@@ -211,28 +233,4 @@ abstract class AbstractFilterTest extends KernelTestCase
 | 
			
		||||
            'test that the title is not empty'
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Compare aliases array before and after that filter alter query
 | 
			
		||||
     *
 | 
			
		||||
     * @dataProvider dataProviderAliasDidNotDisappears
 | 
			
		||||
     *
 | 
			
		||||
     * @param QueryBuilder $qb
 | 
			
		||||
     * @param array $data
 | 
			
		||||
     * @return void
 | 
			
		||||
     */
 | 
			
		||||
    public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
 | 
			
		||||
    {
 | 
			
		||||
        $aliases = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->getFilter()->alterQuery($qb, $data);
 | 
			
		||||
 | 
			
		||||
        $alteredQuery = $qb->getAllAliases();
 | 
			
		||||
 | 
			
		||||
        $this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
 | 
			
		||||
 | 
			
		||||
        foreach ($aliases as $alias) {
 | 
			
		||||
            $this->assertContains($alias, $alteredQuery);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,6 @@ use Symfony\Component\Form\FormBuilderInterface;
 | 
			
		||||
 | 
			
		||||
class AdministrativeLocationFilter implements FilterInterface
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    private TranslatableStringHelper $translatableStringHelper;
 | 
			
		||||
 | 
			
		||||
    public function __construct(
 | 
			
		||||
@@ -49,7 +48,6 @@ class AdministrativeLocationFilter implements FilterInterface
 | 
			
		||||
 | 
			
		||||
    public function buildForm(FormBuilderInterface $builder)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $builder->add('accepted_locations', Select2UserLocationType::class, [
 | 
			
		||||
            'label' => 'Accepted locations',
 | 
			
		||||
            'label_attr' => [
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user