diff --git a/tests/Form/Filter/FilterRegistryTest.php b/tests/Form/Filter/FilterRegistryTest.php deleted file mode 100644 index 9e9660390d..0000000000 --- a/tests/Form/Filter/FilterRegistryTest.php +++ /dev/null @@ -1,113 +0,0 @@ - 'easyadmin.filter.type.foo', - ]; - $typeGuesser = $this->getMockBuilder(DoctrineOrmFilterTypeGuesser::class) - ->disableOriginalConstructor() - ->getMock() - ; - $this->filterRegistry = new FilterRegistry($typesMap, [$typeGuesser]); - } - - public function testHasType(): void - { - $this->assertTrue($this->filterRegistry->hasType('foo')); - $this->assertFalse($this->filterRegistry->hasType('bar')); - } - - public function testGetType(): void - { - $this->assertSame('easyadmin.filter.type.foo', $this->filterRegistry->getType('foo')); - } - - public function testGetInvalidType(): void - { - $this->setExpectedException(\Symfony\Component\Form\Exception\InvalidArgumentException::class); - - $this->filterRegistry->getType('bar'); - } - - public function testGetTypeGuesser(): void - { - $typeGuesser = $this->filterRegistry->getTypeGuesser(); - - $this->assertInstanceOf(FormTypeGuesserChain::class, $typeGuesser); - } - - public function testResolveType(): void - { - $filterType = new FooFilterType(); - $form = $this->createFilterForm($filterType); - - $this->assertSame($filterType, $this->filterRegistry->resolveType($form)); - } - - public function testResolveTypeThroughParents(): void - { - $fooFilterType = new FooFilterType(); - $foobarFilterType = new FoobarFilterType(); - $form = $this->createFilterForm($fooFilterType, $foobarFilterType); - - $this->assertSame($fooFilterType, $this->filterRegistry->resolveType($form)); - } - - public function testInvalidFilterType(): void - { - $this->setExpectedException(\Symfony\Component\Form\Exception\RuntimeException::class, 'Filter type "EasyCorp\\TestBundle\\EasyAdminBundle\\Tests\\Form\\Filter\\Fixtures\\InvalidFilterType" must implement "EasyCorp\\TestBundle\\EasyAdminBundle\\Form\\Filter\\Type\\FilterInterface".'); - - $filterType = new InvalidFilterType(); - $form = $this->createFilterForm($filterType); - - $this->filterRegistry->resolveType($form); - } - - private function createFilterForm(FormTypeInterface $filterType, ?FormTypeInterface $childFilterType = null) - { - $resolvedFormType = $this->getMockBuilder(ResolvedFormTypeInterface::class)->getMock(); - $resolvedFormType->method('getInnerType')->willReturn($filterType); - - if ($childFilterType) { - $childResolvedFormType = $this->getMockBuilder(ResolvedFormTypeInterface::class)->getMock(); - $childResolvedFormType->method('getInnerType')->willReturn($childFilterType); - $childResolvedFormType->method('getParent')->willReturn($resolvedFormType); - - $childFormConfig = $this->getMockBuilder(FormConfigInterface::class)->getMock(); - $childFormConfig->method('getType')->willReturn($childResolvedFormType); - - $childForm = $this->getMockBuilder(FormInterface::class)->getMock(); - $childForm->method('getConfig')->willReturn($childFormConfig); - - return $childForm; - } - - $formConfig = $this->getMockBuilder(FormConfigInterface::class)->getMock(); - $formConfig->method('getType')->willReturn($resolvedFormType); - - $form = $this->getMockBuilder(FormInterface::class)->getMock(); - $form->method('getConfig')->willReturn($formConfig); - - return $form; - } -} diff --git a/tests/Form/Filter/Fixtures/FooFilterType.php b/tests/Form/Filter/Fixtures/FooFilterType.php deleted file mode 100644 index 87b1f9bd24..0000000000 --- a/tests/Form/Filter/Fixtures/FooFilterType.php +++ /dev/null @@ -1,14 +0,0 @@ -