mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
Merge branch 'upgrade-sf3' of framagit.org:Chill-project/Chill-Main into upgrade-sf3
merge...
This commit is contained in:
commit
38bb5da406
@ -25,6 +25,8 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||||
use Chill\MainBundle\Entity\Center;
|
use Chill\MainBundle\Entity\Center;
|
||||||
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -78,9 +80,9 @@ class CenterType extends AbstractType
|
|||||||
throw new \RuntimeException("The user is not associated with "
|
throw new \RuntimeException("The user is not associated with "
|
||||||
. "any center. Associate user with a center");
|
. "any center. Associate user with a center");
|
||||||
} elseif ($nbReachableCenters === 1) {
|
} elseif ($nbReachableCenters === 1) {
|
||||||
return 'hidden';
|
return HiddenType::class;
|
||||||
} else {
|
} else {
|
||||||
return 'entity';
|
return EntityType::class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,8 @@ class CenterType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
if (count($this->reachableCenters) > 1) {
|
if (count($this->reachableCenters) > 1) {
|
||||||
$resolver->setDefault('class', 'Chill\MainBundle\Entity\Center');
|
$resolver->setDefault('class', Center::class);
|
||||||
|
$resolver->setDefault('choices', $this->reachableCenters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +108,7 @@ class CenterType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($this->getParent() === 'hidden') {
|
if ($this->getParent() === HiddenType::class) {
|
||||||
$builder->addModelTransformer($this->transformer);
|
$builder->addModelTransformer($this->transformer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
|||||||
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||||
count($query->getDQLPart('from')) : 0;
|
count($query->getDQLPart('from')) : 0;
|
||||||
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
||||||
count($query->getDQLPart('where')) : 0;
|
$query->getDQLPart('where')->count() : 0;
|
||||||
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
||||||
count($query->getDQLPart('select')) : 0;
|
count($query->getDQLPart('select')) : 0;
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
|||||||
altered the query");
|
altered the query");
|
||||||
$this->assertGreaterThanOrEqual(
|
$this->assertGreaterThanOrEqual(
|
||||||
$nbOfWhere,
|
$nbOfWhere,
|
||||||
$query->getDQLPart('where') !== null ? count($query->getDQLPart('where')) : 0,
|
$query->getDQLPart('where') !== null ? $query->getDQLPart('where')->count() : 0,
|
||||||
"Test that there are equal or more 'where' clause after that the filter has"
|
"Test that there are equal or more 'where' clause after that the filter has"
|
||||||
. "altered the query");
|
. "altered the query");
|
||||||
$this->assertGreaterThanOrEqual(
|
$this->assertGreaterThanOrEqual(
|
||||||
|
@ -104,20 +104,32 @@ abstract class AbstractFilterTest extends KernelTestCase
|
|||||||
public function testAlterQuery(QueryBuilder $query, $data)
|
public function testAlterQuery(QueryBuilder $query, $data)
|
||||||
{
|
{
|
||||||
// retains informations about query
|
// retains informations about query
|
||||||
$nbOfFrom = count($query->getDQLPart('from'));
|
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||||
$nbOfWhere = count($query->getDQLPart('where'));
|
count($query->getDQLPart('from')) : 0;
|
||||||
$nbOfSelect = count($query->getDQLPart('select'));
|
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
||||||
|
$query->getDQLPart('where')->count() : 0;
|
||||||
|
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
||||||
|
count($query->getDQLPart('select')) : 0;
|
||||||
|
|
||||||
$this->getFilter()->alterQuery($query, $data);
|
$this->getFilter()->alterQuery($query, $data);
|
||||||
|
|
||||||
$this->assertGreaterThanOrEqual($nbOfFrom, count($query->getDQLPart('from')),
|
$this->assertGreaterThanOrEqual(
|
||||||
|
$nbOfFrom,
|
||||||
|
$query->getDQLPart('from') !== null ? count($query->getDQLPart('from')) : 0,
|
||||||
"Test that there are equal or more 'from' clause after that the filter has
|
"Test that there are equal or more 'from' clause after that the filter has
|
||||||
altered the query");
|
altered the query"
|
||||||
$this->assertGreaterThanOrEqual($nbOfWhere, count($query->getDQLPart('where')),
|
);
|
||||||
|
$this->assertGreaterThanOrEqual(
|
||||||
|
$nbOfWhere,
|
||||||
|
$query->getDQLPart('where') !== null ? $query->getDQLPart('where')->count() : 0,
|
||||||
"Test that there are equal or more 'where' clause after that the filter has"
|
"Test that there are equal or more 'where' clause after that the filter has"
|
||||||
. "altered the query");
|
. "altered the query"
|
||||||
$this->assertEquals($nbOfSelect, count($query->getDQLPart('select')),
|
);
|
||||||
"Test that the filter has no altered the 'select' part of the query");
|
$this->assertEquals(
|
||||||
|
$nbOfSelect,
|
||||||
|
$query->getDQLPart('select') !== null ? count($query->getDQLPart('select')) : 0,
|
||||||
|
"Test that the filter has no altered the 'select' part of the query"
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ use Symfony\Component\Form\Test\TypeTestCase;
|
|||||||
use Chill\MainBundle\Form\Type\CenterType;
|
use Chill\MainBundle\Form\Type\CenterType;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Entity\GroupCenter;
|
use Chill\MainBundle\Entity\GroupCenter;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +50,7 @@ class CenterTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$type = $this->prepareType($user);
|
$type = $this->prepareType($user);
|
||||||
|
|
||||||
$this->assertEquals('hidden', $type->getParent());
|
$this->assertEquals(HiddenType::class, $type->getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +73,7 @@ class CenterTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$type = $this->prepareType($user);
|
$type = $this->prepareType($user);
|
||||||
|
|
||||||
$this->assertEquals('hidden', $type->getParent());
|
$this->assertEquals(HiddenType::class, $type->getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,7 +98,7 @@ class CenterTypeTest extends TypeTestCase
|
|||||||
|
|
||||||
$type = $this->prepareType($user);
|
$type = $this->prepareType($user);
|
||||||
|
|
||||||
$this->assertEquals('entity', $type->getParent());
|
$this->assertEquals(EntityType::class, $type->getParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user