diff --git a/src/Kunstmaan/AdminBundle/Tests/EventListener/AdminLocaleListenerTest.php b/src/Kunstmaan/AdminBundle/Tests/EventListener/AdminLocaleListenerTest.php index 5c44ad875e..9486cb3177 100644 --- a/src/Kunstmaan/AdminBundle/Tests/EventListener/AdminLocaleListenerTest.php +++ b/src/Kunstmaan/AdminBundle/Tests/EventListener/AdminLocaleListenerTest.php @@ -33,7 +33,7 @@ public function testListener($uri, $shouldPerformCheck, $tokenStorageCallCount) $storage->expects($this->exactly($tokenStorageCallCount))->method('getToken')->willReturn($token); $user->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('getAdminLocale')->willReturn(null); - $trans->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('setLocale')->willReturn(null); + $trans->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('setLocale'); $adminRouteHelper->method('isAdminRoute')->willReturn($shouldPerformCheck); $listener = new AdminLocaleListener($storage, $trans, $adminRouteHelper, 'en'); diff --git a/src/Kunstmaan/AdminBundle/Tests/EventListener/PasswordCheckListenerTest.php b/src/Kunstmaan/AdminBundle/Tests/EventListener/PasswordCheckListenerTest.php index 58ce85a634..d5906c8344 100644 --- a/src/Kunstmaan/AdminBundle/Tests/EventListener/PasswordCheckListenerTest.php +++ b/src/Kunstmaan/AdminBundle/Tests/EventListener/PasswordCheckListenerTest.php @@ -36,7 +36,7 @@ public function testListener($uri, $shouldPerformCheck, $tokenStorageCallCount) $user = $this->createMock(User::class); $router = $this->createMock(RouterInterface::class); $session = $this->createMock(Session::class); - $flash = $this->createMock(FlashBag::class); + $flash = new FlashBag(); $trans = $this->createMock(Translator::class); $adminRouteHelper = $this->createMock(AdminRouteHelper::class); $kernel = $this->createMock(KernelInterface::class); @@ -48,7 +48,6 @@ public function testListener($uri, $shouldPerformCheck, $tokenStorageCallCount) $user->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('isPasswordChanged')->willReturn(false); $router->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('generate')->willReturn('/url'); $session->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('getFlashBag')->willReturn($flash); - $flash->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('add')->willReturn(true); $trans->expects($this->exactly($shouldPerformCheck ? 1 : 0))->method('trans')->willReturn('translated-text'); $adminRouteHelper->method('isAdminRoute')->willReturn($shouldPerformCheck); $requestStack = new RequestStack(); diff --git a/src/Kunstmaan/AdminListBundle/Tests/AdminList/Configurator/AbstractDoctrineORMAdminListConfiguratorTest.php b/src/Kunstmaan/AdminListBundle/Tests/AdminList/Configurator/AbstractDoctrineORMAdminListConfiguratorTest.php index b050dfa7d4..83efd8e6b6 100644 --- a/src/Kunstmaan/AdminListBundle/Tests/AdminList/Configurator/AbstractDoctrineORMAdminListConfiguratorTest.php +++ b/src/Kunstmaan/AdminListBundle/Tests/AdminList/Configurator/AbstractDoctrineORMAdminListConfiguratorTest.php @@ -2,10 +2,15 @@ namespace Kunstmaan\AdminListBundle\Tests\AdminList\Configurator; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\ORM\AbstractQuery; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityRepository; +use Doctrine\ORM\Internal\Hydration\ArrayHydrator; +use Doctrine\ORM\Internal\Hydration\IterableResult; use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\Query; use Doctrine\ORM\QueryBuilder; use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper; use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\PermissionDefinition; @@ -28,11 +33,16 @@ class AbstractDoctrineORMAdminListConfiguratorTest extends TestCase public function setUp(): void { - $queryMock = $this->createMock(AbstractQuery::class); + $conn = $this->createMock(Connection::class); + $conn->method('getDatabasePlatform')->willReturn(new MySQLPlatform()); + $emMock = $this->createMock(EntityManagerInterface::class); + $emMock->method('getConnection')->willReturn($conn); + + $queryMock = $this->createMock(Query::class); $queryMock ->expects($this->any()) ->method('iterate') - ->willReturn($this->createMock(\Iterator::class)) + ->willReturn(new IterableResult(new ArrayHydrator($emMock))) ; $this->emMock = $this->createMock(EntityManagerInterface::class); diff --git a/src/Kunstmaan/NodeBundle/Tests/Helper/NodeHelperTest.php b/src/Kunstmaan/NodeBundle/Tests/Helper/NodeHelperTest.php index 1db998819b..e574783739 100644 --- a/src/Kunstmaan/NodeBundle/Tests/Helper/NodeHelperTest.php +++ b/src/Kunstmaan/NodeBundle/Tests/Helper/NodeHelperTest.php @@ -33,7 +33,7 @@ use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormFactory; -use Symfony\Component\HttpFoundation\ParameterBag; +use Symfony\Component\HttpFoundation\InputBag; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; @@ -711,7 +711,7 @@ private function createNodeEntities($title = 'Test page'): array public function testPageShouldHaveTab() { $request = new Request(); - $request->request = new ParameterBag(); + $request->request = new InputBag(); $formFactory = $this->getMockBuilder(FormFactory::class) ->disableOriginalConstructor() diff --git a/src/Kunstmaan/NodeSearchBundle/Tests/Services/SearchServiceTest.php b/src/Kunstmaan/NodeSearchBundle/Tests/Services/SearchServiceTest.php index 446f49db24..59f90d317e 100644 --- a/src/Kunstmaan/NodeSearchBundle/Tests/Services/SearchServiceTest.php +++ b/src/Kunstmaan/NodeSearchBundle/Tests/Services/SearchServiceTest.php @@ -24,9 +24,8 @@ public function testUnknownSearcher() $parameterBag = new ParameterBag(); $parameterBag->set('_entity', $entity); - $request = $this->createMock(Request::class); + $request = new Request(); $request->attributes = $parameterBag; - $request->query = $parameterBag; $container = $this->createMock(ContainerInterface::class); $container->method('get')->with('unknown_searcher')->willThrowException(new ServiceNotFoundException('unknown_searcher'));