diff --git a/CHANGELOG.md b/CHANGELOG.md index 218cb8f25..7ce45c161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Added missing `swiftmailer` dependency ### Changed +- Risky code change for PHP 7 - Made `sonata-project/google-authenticator` an optional dependency - Moved public methods of `User` to `UserInterface` - Lowered upper composer dependencies diff --git a/src/Admin/Document/GroupAdmin.php b/src/Admin/Document/GroupAdmin.php index bcc407ec7..235e2a047 100644 --- a/src/Admin/Document/GroupAdmin.php +++ b/src/Admin/Document/GroupAdmin.php @@ -1,5 +1,7 @@ addIdentifier('name') @@ -50,7 +52,7 @@ protected function configureListFields(ListMapper $listMapper) /** * {@inheritdoc} */ - protected function configureDatagridFilters(DatagridMapper $datagridMapper) + protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { $datagridMapper ->add('name') @@ -60,7 +62,7 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) /** * {@inheritdoc} */ - protected function configureFormFields(FormMapper $formMapper) + protected function configureFormFields(FormMapper $formMapper): void { $formMapper ->tab('Group') diff --git a/src/Admin/Model/UserAdmin.php b/src/Admin/Model/UserAdmin.php index 21d075f00..6867edfcb 100644 --- a/src/Admin/Model/UserAdmin.php +++ b/src/Admin/Model/UserAdmin.php @@ -1,5 +1,7 @@ getUserManager()->updateCanonicalFields($user); $this->getUserManager()->updatePassword($user); @@ -73,7 +75,7 @@ public function preUpdate($user) /** * @param UserManagerInterface $userManager */ - public function setUserManager(UserManagerInterface $userManager) + public function setUserManager(UserManagerInterface $userManager): void { $this->userManager = $userManager; } @@ -89,7 +91,7 @@ public function getUserManager() /** * {@inheritdoc} */ - protected function configureListFields(ListMapper $listMapper) + protected function configureListFields(ListMapper $listMapper): void { $listMapper ->addIdentifier('username') @@ -109,7 +111,7 @@ protected function configureListFields(ListMapper $listMapper) /** * {@inheritdoc} */ - protected function configureDatagridFilters(DatagridMapper $filterMapper) + protected function configureDatagridFilters(DatagridMapper $filterMapper): void { $filterMapper ->add('id') @@ -122,7 +124,7 @@ protected function configureDatagridFilters(DatagridMapper $filterMapper) /** * {@inheritdoc} */ - protected function configureShowFields(ShowMapper $showMapper) + protected function configureShowFields(ShowMapper $showMapper): void { $showMapper ->with('General') @@ -161,7 +163,7 @@ protected function configureShowFields(ShowMapper $showMapper) /** * {@inheritdoc} */ - protected function configureFormFields(FormMapper $formMapper) + protected function configureFormFields(FormMapper $formMapper): void { // define group zoning $formMapper diff --git a/src/Command/TwoStepVerificationCommand.php b/src/Command/TwoStepVerificationCommand.php index 22f44a67d..9d6b02798 100644 --- a/src/Command/TwoStepVerificationCommand.php +++ b/src/Command/TwoStepVerificationCommand.php @@ -1,5 +1,7 @@ setName('sonata:user:two-step-verification'); $this->addArgument('username', InputArgument::REQUIRED, 'The username to protect with a two step verification process'); @@ -33,7 +35,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { if (!$this->getContainer()->has('sonata.user.google.authenticator.provider')) { throw new \RuntimeException('Two Step Verification process is not enabled'); diff --git a/src/Controller/AdminResettingController.php b/src/Controller/AdminResettingController.php index b1918f19d..1f11cc7e2 100644 --- a/src/Controller/AdminResettingController.php +++ b/src/Controller/AdminResettingController.php @@ -1,5 +1,7 @@ generateUrl('sonata_user_admin_resetting_reset', [ 'token' => $user->getConfirmationToken(), diff --git a/src/Controller/AdminSecurityController.php b/src/Controller/AdminSecurityController.php index 546ee9709..e23a5b535 100644 --- a/src/Controller/AdminSecurityController.php +++ b/src/Controller/AdminSecurityController.php @@ -1,5 +1,7 @@ getDefinition('twig') ->addMethodCall('addGlobal', ['sonata_user', new Reference('sonata.user.twig.global')]); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 281ff8003..fe6c107e0 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,5 +1,7 @@ hasExtension('twig')) { // add custom form widgets @@ -42,7 +44,7 @@ public function prepend(ContainerBuilder $container) /** * {@inheritdoc} */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); $configuration = new Configuration(); @@ -165,7 +167,7 @@ public function configureGoogleAuthenticator($config, ContainerBuilder $containe * @param array $config * @param ContainerBuilder $container */ - public function configureClass($config, ContainerBuilder $container) + public function configureClass($config, ContainerBuilder $container): void { if ('orm' === $config['manager_type']) { $modelType = 'entity'; @@ -183,7 +185,7 @@ public function configureClass($config, ContainerBuilder $container) * @param array $config * @param ContainerBuilder $container */ - public function configureAdminClass($config, ContainerBuilder $container) + public function configureAdminClass($config, ContainerBuilder $container): void { $container->setParameter('sonata.user.admin.user.class', $config['admin']['user']['class']); $container->setParameter('sonata.user.admin.group.class', $config['admin']['group']['class']); @@ -193,7 +195,7 @@ public function configureAdminClass($config, ContainerBuilder $container) * @param array $config * @param ContainerBuilder $container */ - public function configureTranslationDomain($config, ContainerBuilder $container) + public function configureTranslationDomain($config, ContainerBuilder $container): void { $container->setParameter('sonata.user.admin.user.translation_domain', $config['admin']['user']['translation']); $container->setParameter('sonata.user.admin.group.translation_domain', $config['admin']['group']['translation']); @@ -203,7 +205,7 @@ public function configureTranslationDomain($config, ContainerBuilder $container) * @param array $config * @param ContainerBuilder $container */ - public function configureController($config, ContainerBuilder $container) + public function configureController($config, ContainerBuilder $container): void { $container->setParameter('sonata.user.admin.user.controller', $config['admin']['user']['controller']); $container->setParameter('sonata.user.admin.group.controller', $config['admin']['group']['controller']); @@ -212,7 +214,7 @@ public function configureController($config, ContainerBuilder $container) /** * @param array $config */ - public function registerDoctrineMapping(array $config) + public function registerDoctrineMapping(array $config): void { foreach ($config['class'] as $type => $class) { if (!class_exists($class)) { @@ -250,7 +252,7 @@ public function registerDoctrineMapping(array $config) * @param ContainerBuilder $container * @param $managerType */ - protected function aliasManagers(ContainerBuilder $container, $managerType) + protected function aliasManagers(ContainerBuilder $container, $managerType): void { $container->setAlias('sonata.user.user_manager', sprintf('sonata.user.%s.user_manager', $managerType)); $container->setAlias('sonata.user.group_manager', sprintf('sonata.user.%s.group_manager', $managerType)); @@ -259,7 +261,7 @@ protected function aliasManagers(ContainerBuilder $container, $managerType) /** * @param array $config */ - private function checkManagerTypeToModelTypeMapping(array $config) + private function checkManagerTypeToModelTypeMapping(array $config): void { $managerType = $config['manager_type']; diff --git a/src/Document/BaseGroup.php b/src/Document/BaseGroup.php index ff513eda4..c0bb72d8d 100644 --- a/src/Document/BaseGroup.php +++ b/src/Document/BaseGroup.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -31,7 +33,7 @@ public function prePersist() /** * Hook on pre-update operations. */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Document/GroupManager.php b/src/Document/GroupManager.php index 42939f918..45c38795b 100644 --- a/src/Document/GroupManager.php +++ b/src/Document/GroupManager.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -31,7 +33,7 @@ public function prePersist() /** * Hook on pre-update operations. */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Entity/GroupManager.php b/src/Entity/GroupManager.php index 8a1342358..286da173b 100644 --- a/src/Entity/GroupManager.php +++ b/src/Entity/GroupManager.php @@ -1,5 +1,7 @@ originalRoles = $originalRoles ?: []; } diff --git a/src/Form/Type/ApiGroupType.php b/src/Form/Type/ApiGroupType.php index 18de24bb1..44904d3cf 100644 --- a/src/Form/Type/ApiGroupType.php +++ b/src/Form/Type/ApiGroupType.php @@ -1,5 +1,7 @@ rolesBuilder); // GET METHOD - $formBuilder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($transformer) { + $formBuilder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($transformer): void { $transformer->setOriginalRoles($event->getData()); }); // POST METHOD - $formBuilder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($transformer) { + $formBuilder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($transformer): void { $transformer->setOriginalRoles($event->getForm()->getData()); }); @@ -67,7 +69,7 @@ public function buildForm(FormBuilderInterface $formBuilder, array $options) /** * {@inheritdoc} */ - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { $attr = $view->vars['attr']; @@ -84,7 +86,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ // make expanded default value diff --git a/src/Form/Type/UserGenderListType.php b/src/Form/Type/UserGenderListType.php index abd93e974..a5af54664 100644 --- a/src/Form/Type/UserGenderListType.php +++ b/src/Form/Type/UserGenderListType.php @@ -1,5 +1,7 @@ getAuthenticationToken() instanceof UsernamePasswordToken) { return; diff --git a/src/GoogleAuthenticator/RequestListener.php b/src/GoogleAuthenticator/RequestListener.php index 6210d8321..7d1a23d16 100644 --- a/src/GoogleAuthenticator/RequestListener.php +++ b/src/GoogleAuthenticator/RequestListener.php @@ -1,5 +1,7 @@ getRequestType()) { return; diff --git a/src/Model/GroupManagerInterface.php b/src/Model/GroupManagerInterface.php index 48eb8f32b..61042948c 100644 --- a/src/Model/GroupManagerInterface.php +++ b/src/Model/GroupManagerInterface.php @@ -1,5 +1,7 @@ translator = $translator; } @@ -79,7 +81,7 @@ public function getRoles($domain = false, $expanded = true) return $roles; } - $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$roles) { + $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$roles): void { if ($isMaster) { // if the user has the MASTER permission, allow to grant access the admin roles to other users $roles[$role] = $this->translateRole($role, $domain); @@ -122,7 +124,7 @@ public function getRolesReadOnly($domain = false) return $rolesReadOnly; } - $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$rolesReadOnly) { + $this->iterateAdminRoles(function ($role, $isMaster) use ($domain, &$rolesReadOnly): void { if (!$isMaster && $this->authorizationChecker->isGranted($role)) { // although the user has no MASTER permission, allow the currently logged in user to view the role $rolesReadOnly[$role] = $this->translateRole($role, $domain); @@ -132,7 +134,7 @@ public function getRolesReadOnly($domain = false) return $rolesReadOnly; } - private function iterateAdminRoles(callable $func) + private function iterateAdminRoles(callable $func): void { // get roles from the Admin classes foreach ($this->pool->getAdminServiceIds() as $id) { diff --git a/src/Serializer/UserSerializerHandler.php b/src/Serializer/UserSerializerHandler.php index 2e04fa26b..c6919ab85 100644 --- a/src/Serializer/UserSerializerHandler.php +++ b/src/Serializer/UserSerializerHandler.php @@ -1,5 +1,7 @@ addCompilerPass(new GlobalVariablesCompilerPass()); @@ -31,7 +33,7 @@ public function build(ContainerBuilder $container) /** * {@inheritdoc} */ - public function boot() + public function boot(): void { $this->registerFormMapping(); } @@ -39,7 +41,7 @@ public function boot() /** * Register form mapping information. */ - public function registerFormMapping() + public function registerFormMapping(): void { FormHelper::registerFormTypeMapping([ 'fos_user_username' => 'FOS\UserBundle\Form\Type\UsernameFormType', diff --git a/src/Twig/GlobalVariables.php b/src/Twig/GlobalVariables.php index b3f6ac9e8..ca331daf7 100644 --- a/src/Twig/GlobalVariables.php +++ b/src/Twig/GlobalVariables.php @@ -1,5 +1,7 @@ controller = new AdminResettingController(); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->controller); } diff --git a/tests/Controller/AdminSecurityControllerTest.php b/tests/Controller/AdminSecurityControllerTest.php index 3d7742962..75870d4ca 100644 --- a/tests/Controller/AdminSecurityControllerTest.php +++ b/tests/Controller/AdminSecurityControllerTest.php @@ -1,5 +1,7 @@ controller = new AdminSecurityController(); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->controller); } diff --git a/tests/Controller/Api/GroupControllerTest.php b/tests/Controller/Api/GroupControllerTest.php index eeaef0963..caf44e439 100644 --- a/tests/Controller/Api/GroupControllerTest.php +++ b/tests/Controller/Api/GroupControllerTest.php @@ -1,5 +1,7 @@ createMock('FOS\UserBundle\Model\GroupInterface'); $groupManager = $this->createMock('Sonata\UserBundle\Model\GroupManagerInterface'); @@ -35,13 +37,13 @@ public function testGetGroupsAction() $this->assertEquals([$group], $this->createGroupController(null, $groupManager)->getGroupsAction($paramFetcher)); } - public function testGetGroupAction() + public function testGetGroupAction(): void { $group = $this->createMock('FOS\UserBundle\Model\GroupInterface'); $this->assertEquals($group, $this->createGroupController($group)->getGroupAction(1)); } - public function testGetGroupActionNotFoundException() + public function testGetGroupActionNotFoundException(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('Group (42) not found'); @@ -49,7 +51,7 @@ public function testGetGroupActionNotFoundException() $this->createGroupController()->getGroupAction(42); } - public function testPostGroupAction() + public function testPostGroupAction(): void { $group = $this->createMock('FOS\UserBundle\Model\GroupInterface'); @@ -70,7 +72,7 @@ public function testPostGroupAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $view); } - public function testPostGroupInvalidAction() + public function testPostGroupInvalidAction(): void { $groupManager = $this->createMock('Sonata\UserBundle\Model\GroupManagerInterface'); $groupManager->expects($this->once())->method('getClass')->will($this->returnValue('Sonata\UserBundle\Entity\BaseGroup')); @@ -87,7 +89,7 @@ public function testPostGroupInvalidAction() $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $view); } - public function testPutGroupAction() + public function testPutGroupAction(): void { $group = $this->createMock('FOS\UserBundle\Model\GroupInterface'); @@ -109,7 +111,7 @@ public function testPutGroupAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $view); } - public function testPutGroupInvalidAction() + public function testPutGroupInvalidAction(): void { $group = $this->createMock('FOS\UserBundle\Model\GroupInterface'); @@ -129,7 +131,7 @@ public function testPutGroupInvalidAction() $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $view); } - public function testDeleteGroupAction() + public function testDeleteGroupAction(): void { $group = $this->createMock('FOS\UserBundle\Model\GroupInterface'); @@ -142,7 +144,7 @@ public function testDeleteGroupAction() $this->assertEquals(['deleted' => true], $view); } - public function testDeleteGroupInvalidAction() + public function testDeleteGroupInvalidAction(): void { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); diff --git a/tests/Controller/Api/UserControllerTest.php b/tests/Controller/Api/UserControllerTest.php index ad482b466..2f58b9749 100644 --- a/tests/Controller/Api/UserControllerTest.php +++ b/tests/Controller/Api/UserControllerTest.php @@ -1,5 +1,7 @@ createMock('Sonata\UserBundle\Model\UserManagerInterface'); $userManager->expects($this->once())->method('getPager')->will($this->returnValue([])); @@ -34,13 +36,13 @@ public function testGetUsersAction() $this->assertEquals([], $this->createUserController(null, $userManager)->getUsersAction($paramFetcher)); } - public function testGetUserAction() + public function testGetUserAction(): void { $user = $this->createMock('Sonata\UserBundle\Model\UserInterface'); $this->assertEquals($user, $this->createUserController($user)->getUserAction(1)); } - public function testGetUserActionNotFoundException() + public function testGetUserActionNotFoundException(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('User (42) not found'); @@ -48,7 +50,7 @@ public function testGetUserActionNotFoundException() $this->createUserController()->getUserAction(42); } - public function testPostUserAction() + public function testPostUserAction(): void { $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -68,7 +70,7 @@ public function testPostUserAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $view); } - public function testPostUserInvalidAction() + public function testPostUserInvalidAction(): void { $userManager = $this->createMock('Sonata\UserBundle\Model\UserManagerInterface'); @@ -84,7 +86,7 @@ public function testPostUserInvalidAction() $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $view); } - public function testPutUserAction() + public function testPutUserAction(): void { $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -105,7 +107,7 @@ public function testPutUserAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $view); } - public function testPutUserInvalidAction() + public function testPutUserInvalidAction(): void { $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -124,7 +126,7 @@ public function testPutUserInvalidAction() $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $view); } - public function testPostUserGroupAction() + public function testPostUserGroupAction(): void { $user = $this->createMock('Sonata\UserBundle\Entity\BaseUser'); $user->expects($this->once())->method('hasGroup')->will($this->returnValue(false)); @@ -143,7 +145,7 @@ public function testPostUserGroupAction() $this->assertEquals(['added' => true], $view); } - public function testPostUserGroupInvalidAction() + public function testPostUserGroupInvalidAction(): void { $user = $this->createMock('Sonata\UserBundle\Entity\BaseUser'); $user->expects($this->once())->method('hasGroup')->will($this->returnValue(true)); @@ -166,7 +168,7 @@ public function testPostUserGroupInvalidAction() $this->assertEquals(['error' => 'User "1" already has group "1"'], $data); } - public function testDeleteUserGroupAction() + public function testDeleteUserGroupAction(): void { $user = $this->createMock('Sonata\UserBundle\Entity\BaseUser'); $user->expects($this->once())->method('hasGroup')->will($this->returnValue(true)); @@ -185,7 +187,7 @@ public function testDeleteUserGroupAction() $this->assertEquals(['removed' => true], $view); } - public function testDeleteUserGroupInvalidAction() + public function testDeleteUserGroupInvalidAction(): void { $user = $this->createMock('Sonata\UserBundle\Entity\BaseUser'); $user->expects($this->once())->method('hasGroup')->will($this->returnValue(false)); @@ -208,7 +210,7 @@ public function testDeleteUserGroupInvalidAction() $this->assertEquals(['error' => 'User "1" has not group "1"'], $data); } - public function testDeleteUserAction() + public function testDeleteUserAction(): void { $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -221,7 +223,7 @@ public function testDeleteUserAction() $this->assertEquals(['deleted' => true], $view); } - public function testDeleteUserInvalidAction() + public function testDeleteUserInvalidAction(): void { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index b6bd5fcfd..236d242d3 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -1,5 +1,7 @@ assertProcessedConfigurationEquals([ [], diff --git a/tests/DependencyInjection/SonataUserExtensionTest.php b/tests/DependencyInjection/SonataUserExtensionTest.php index 0eaf7672b..d71c90d89 100644 --- a/tests/DependencyInjection/SonataUserExtensionTest.php +++ b/tests/DependencyInjection/SonataUserExtensionTest.php @@ -1,5 +1,7 @@ setParameter('kernel.bundles', ['SonataAdminBundle' => true]); } - public function testLoadDefault() + public function testLoadDefault(): void { $this->load(); @@ -49,7 +51,7 @@ public function testLoadDefault() ); } - public function testTwigConfigParameterIsSetting() + public function testTwigConfigParameterIsSetting(): void { $fakeContainer = $this->getMockBuilder(ContainerBuilder::class) ->setMethods(['hasExtension', 'prependExtensionConfig']) @@ -71,7 +73,7 @@ public function testTwigConfigParameterIsSetting() } } - public function testTwigConfigParameterIsSet() + public function testTwigConfigParameterIsSet(): void { $fakeTwigExtension = $this->getMockBuilder(TwigExtension::class) ->setMethods(['load', 'getAlias']) @@ -95,7 +97,7 @@ public function testTwigConfigParameterIsSet() ); } - public function testTwigConfigParameterIsNotSet() + public function testTwigConfigParameterIsNotSet(): void { $this->load(); @@ -104,22 +106,22 @@ public function testTwigConfigParameterIsNotSet() $this->assertArrayNotHasKey(0, $twigConfigurations); } - public function testCorrectModelClass() + public function testCorrectModelClass(): void { $this->load(['class' => ['user' => 'Sonata\UserBundle\Tests\Entity\User']]); } - public function testCorrectModelClassWithLeadingSlash() + public function testCorrectModelClassWithLeadingSlash(): void { $this->load(['class' => ['user' => '\Sonata\UserBundle\Tests\Entity\User']]); } - public function testCorrectAdminClass() + public function testCorrectAdminClass(): void { $this->load(['admin' => ['user' => ['class' => '\Sonata\UserBundle\Tests\Admin\Entity\UserAdmin']]]); } - public function testCorrectModelClassWithNotDefaultManagerType() + public function testCorrectModelClassWithNotDefaultManagerType(): void { $this->load([ 'manager_type' => 'mongodb', @@ -134,7 +136,7 @@ public function testCorrectModelClassWithNotDefaultManagerType() ]); } - public function testIncorrectModelClass() + public function testIncorrectModelClass(): void { $this->expectException('InvalidArgumentException'); @@ -143,7 +145,7 @@ public function testIncorrectModelClass() $this->load(['class' => ['user' => 'Foo\User']]); } - public function testNotCorrespondingModelClass() + public function testNotCorrespondingModelClass(): void { $this->expectException('InvalidArgumentException'); @@ -175,7 +177,7 @@ protected function getContainerExtensions() /** * {@inheritdoc} */ - protected function load(array $configurationValues = []) + protected function load(array $configurationValues = []): void { $configs = [$this->getMinimalConfiguration(), $configurationValues]; diff --git a/tests/Document/BaseGroupTest.php b/tests/Document/BaseGroupTest.php index 9c8f7a9d7..ebe7207f9 100644 --- a/tests/Document/BaseGroupTest.php +++ b/tests/Document/BaseGroupTest.php @@ -1,5 +1,7 @@ assertEquals($today->format('U'), $user->getUpdatedAt()->format('U'), 'Should contain today\'s date'); } - public function testDateWithPrePersist() + public function testDateWithPrePersist(): void { // Given $user = new BaseUser(); @@ -51,7 +53,7 @@ public function testDateWithPrePersist() $this->assertEquals($today->format('Y-m-d'), $user->getUpdatedAt()->format('Y-m-d'), 'Should be updated today'); } - public function testDateWithPreUpdate() + public function testDateWithPreUpdate(): void { // Given $user = new BaseUser(); @@ -69,7 +71,7 @@ public function testDateWithPreUpdate() $this->assertEquals($today->format('Y-m-d'), $user->getUpdatedAt()->format('Y-m-d'), 'Should be updated today'); } - public function testSettingMultipleGroups() + public function testSettingMultipleGroups(): void { // Given $user = new BaseUser(); @@ -87,7 +89,7 @@ public function testSettingMultipleGroups() $this->assertTrue($user->hasGroup('Group 2'), 'Should have a group named "Group 2"'); } - public function testTwoStepVerificationCode() + public function testTwoStepVerificationCode(): void { // Given $user = new BaseUser(); @@ -99,7 +101,7 @@ public function testTwoStepVerificationCode() $this->assertEquals('123456', $user->getTwoStepVerificationCode(), 'Should return the two step verification code'); } - public function testToStringWithName() + public function testToStringWithName(): void { // Given $user = new BaseUser(); @@ -112,7 +114,7 @@ public function testToStringWithName() $this->assertEquals('John', $string, 'Should return the username as string representation'); } - public function testToStringWithoutName() + public function testToStringWithoutName(): void { // Given $user = new BaseUser(); diff --git a/tests/Document/Group.php b/tests/Document/Group.php index e0049a6b4..0d2ca4a91 100644 --- a/tests/Document/Group.php +++ b/tests/Document/Group.php @@ -1,5 +1,7 @@ assertEquals($today->format('U'), $user->getUpdatedAt()->format('U'), 'Should contain today\'s date'); } - public function testDateWithPrePersist() + public function testDateWithPrePersist(): void { // Given $user = new BaseUser(); @@ -51,7 +53,7 @@ public function testDateWithPrePersist() $this->assertEquals($today->format('Y-m-d'), $user->getUpdatedAt()->format('Y-m-d'), 'Should be updated today'); } - public function testDateWithPreUpdate() + public function testDateWithPreUpdate(): void { // Given $user = new BaseUser(); @@ -69,7 +71,7 @@ public function testDateWithPreUpdate() $this->assertEquals($today->format('Y-m-d'), $user->getUpdatedAt()->format('Y-m-d'), 'Should be updated today'); } - public function testSettingMultipleGroups() + public function testSettingMultipleGroups(): void { // Given $user = new BaseUser(); @@ -87,7 +89,7 @@ public function testSettingMultipleGroups() $this->assertTrue($user->hasGroup('Group 2'), 'Should have a group named "Group 2"'); } - public function testTwoStepVerificationCode() + public function testTwoStepVerificationCode(): void { // Given $user = new BaseUser(); @@ -99,7 +101,7 @@ public function testTwoStepVerificationCode() $this->assertEquals('123456', $user->getTwoStepVerificationCode(), 'Should return the two step verification code'); } - public function testToStringWithName() + public function testToStringWithName(): void { // Given $user = new BaseUser(); @@ -112,7 +114,7 @@ public function testToStringWithName() $this->assertEquals('John', $string, 'Should return the username as string representation'); } - public function testToStringWithoutName() + public function testToStringWithoutName(): void { // Given $user = new BaseUser(); diff --git a/tests/Entity/GroupManagerTest.php b/tests/Entity/GroupManagerTest.php index 359e7caa1..b27ac46e4 100644 --- a/tests/Entity/GroupManagerTest.php +++ b/tests/Entity/GroupManagerTest.php @@ -1,5 +1,7 @@ getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('orderBy')->with( @@ -33,14 +35,14 @@ public function testGetPager() ->getPager([], 1); } - public function testGetPagerWithInvalidSort() + public function testGetPagerWithInvalidSort(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid sort field \'invalid\' in \'className\' class'); $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->never())->method('andWhere'); $qb->expects($self->never())->method('orderBy'); $qb->expects($self->never())->method('setParameters'); @@ -48,11 +50,11 @@ public function testGetPagerWithInvalidSort() ->getPager([], 1, 10, ['invalid' => 'ASC']); } - public function testGetPagerWithEnabledUsers() + public function testGetPagerWithEnabledUsers(): void { $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('g.enabled = :enabled')); $qb->expects($self->once())->method('orderBy')->with( @@ -64,11 +66,11 @@ public function testGetPagerWithEnabledUsers() ->getPager(['enabled' => true], 1); } - public function testGetPagerWithDisabledUsers() + public function testGetPagerWithDisabledUsers(): void { $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('g.enabled = :enabled')); $qb->expects($self->once())->method('orderBy')->with( diff --git a/tests/Entity/User.php b/tests/Entity/User.php index e5123d258..ef6c8f7ff 100644 --- a/tests/Entity/User.php +++ b/tests/Entity/User.php @@ -1,5 +1,7 @@ getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->disableOriginalConstructor()->getMock(); diff --git a/tests/Entity/UserManagerTest.php b/tests/Entity/UserManagerTest.php index d32c9c2f3..de4cdf545 100644 --- a/tests/Entity/UserManagerTest.php +++ b/tests/Entity/UserManagerTest.php @@ -1,5 +1,7 @@ getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['u'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('orderBy')->with( @@ -32,14 +34,14 @@ public function testGetPager() ->getPager([], 1); } - public function testGetPagerWithInvalidSort() + public function testGetPagerWithInvalidSort(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid sort field \'invalid\' in \'Sonata\UserBundle\Entity\BaseUser\' class'); $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->never())->method('andWhere'); $qb->expects($self->never())->method('orderBy'); $qb->expects($self->never())->method('setParameters'); @@ -47,11 +49,11 @@ public function testGetPagerWithInvalidSort() ->getPager([], 1, 10, ['invalid' => 'ASC']); } - public function testGetPagerWithValidSortDesc() + public function testGetPagerWithValidSortDesc(): void { $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['u'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('u.enabled = :enabled')); $qb->expects($self->once())->method('setParameter')->with( @@ -66,11 +68,11 @@ public function testGetPagerWithValidSortDesc() ->getPager(['enabled' => true], 1, 10, ['email' => 'DESC']); } - public function testGetPagerWithEnabledUsers() + public function testGetPagerWithEnabledUsers(): void { $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['u'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('u.enabled = :enabled')); $qb->expects($self->once())->method('setParameter')->with( @@ -85,11 +87,11 @@ public function testGetPagerWithEnabledUsers() ->getPager(['enabled' => true], 1); } - public function testGetPagerWithDisabledUsers() + public function testGetPagerWithDisabledUsers(): void { $self = $this; $this - ->getUserManager(function ($qb) use ($self) { + ->getUserManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['u'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('u.enabled = :enabled')); $qb->expects($self->once())->method('setParameter')->with( diff --git a/tests/Form/Transformer/RestoreRolesTransformerTest.php b/tests/Form/Transformer/RestoreRolesTransformerTest.php index 7113ffd13..4afa5ee9e 100644 --- a/tests/Form/Transformer/RestoreRolesTransformerTest.php +++ b/tests/Form/Transformer/RestoreRolesTransformerTest.php @@ -1,5 +1,7 @@ expectException(\RuntimeException::class); @@ -27,7 +29,7 @@ public function testInvalidStateTransform() $transformer->transform([]); } - public function testInvalidStateReverseTransform() + public function testInvalidStateReverseTransform(): void { $this->expectException(\RuntimeException::class); @@ -37,7 +39,7 @@ public function testInvalidStateReverseTransform() $transformer->reverseTransform([]); } - public function testValidTransform() + public function testValidTransform(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); @@ -49,7 +51,7 @@ public function testValidTransform() $this->assertEquals($data, $transformer->transform($data)); } - public function testValidReverseTransform() + public function testValidReverseTransform(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); @@ -63,7 +65,7 @@ public function testValidReverseTransform() $this->assertEquals(['ROLE_FOO', 'ROLE_HIDDEN'], $transformer->reverseTransform($data)); } - public function testTransformAllowEmptyOriginalRoles() + public function testTransformAllowEmptyOriginalRoles(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); @@ -75,7 +77,7 @@ public function testTransformAllowEmptyOriginalRoles() $this->assertEquals($data, $transformer->transform($data)); } - public function testReverseTransformAllowEmptyOriginalRoles() + public function testReverseTransformAllowEmptyOriginalRoles(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); @@ -89,7 +91,7 @@ public function testReverseTransformAllowEmptyOriginalRoles() $this->assertEquals(['ROLE_FOO'], $transformer->reverseTransform($data)); } - public function testReverseTransformRevokedHierarchicalRole() + public function testReverseTransformRevokedHierarchicalRole(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); @@ -114,7 +116,7 @@ public function testReverseTransformRevokedHierarchicalRole() $this->assertNotContains($revokedRole, $processedRoles); } - public function testReverseTransformHiddenRole() + public function testReverseTransformHiddenRole(): void { $roleBuilder = $this->createMock(EditableRolesBuilder::class); diff --git a/tests/Form/Type/SecurityRolesTypeTest.php b/tests/Form/Type/SecurityRolesTypeTest.php index cc679053a..43b9cd395 100755 --- a/tests/Form/Type/SecurityRolesTypeTest.php +++ b/tests/Form/Type/SecurityRolesTypeTest.php @@ -1,5 +1,7 @@ roleBuilder); @@ -35,7 +37,7 @@ public function testGetDefaultOptions() $this->assertCount(3, $options['choices']); } - public function testGetParent() + public function testGetParent(): void { $type = new SecurityRolesType($this->roleBuilder); $this->assertEquals( @@ -44,7 +46,7 @@ public function testGetParent() ); } - public function testSubmitValidData() + public function testSubmitValidData(): void { $form = $this->factory->create($this->getSecurityRolesTypeName(), null, [ 'multiple' => true, @@ -59,7 +61,7 @@ public function testSubmitValidData() $this->assertTrue(in_array('ROLE_FOO', $form->getData())); } - public function testSubmitInvalidData() + public function testSubmitInvalidData(): void { $form = $this->factory->create($this->getSecurityRolesTypeName(), null, [ 'multiple' => true, @@ -73,7 +75,7 @@ public function testSubmitInvalidData() $this->assertNull($form->getData()); } - public function testSubmitWithHiddenRoleData() + public function testSubmitWithHiddenRoleData(): void { $originalRoles = ['ROLE_SUPER_ADMIN', 'ROLE_USER']; diff --git a/tests/Resources/XliffTest.php b/tests/Resources/XliffTest.php index cfbd494be..a56bc8c0f 100644 --- a/tests/Resources/XliffTest.php +++ b/tests/Resources/XliffTest.php @@ -1,5 +1,7 @@ createMock('FOS\UserBundle\Model\UserInterface'); @@ -44,7 +46,7 @@ public function testVoteWillAbstainWhenAUserIsLoggedInAndASuperAdmin() $this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $decision, 'Should abstain from voting'); } - public function testVoteWillDenyAccessWhenAUserIsLoggedInAndNotASuperAdmin() + public function testVoteWillDenyAccessWhenAUserIsLoggedInAndNotASuperAdmin(): void { // Given $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -70,7 +72,7 @@ public function testVoteWillDenyAccessWhenAUserIsLoggedInAndNotASuperAdmin() $this->assertEquals(VoterInterface::ACCESS_DENIED, $decision, 'Should deny access'); } - public function testVoteWillAbstainWhenAUserIsNotAvailable() + public function testVoteWillAbstainWhenAUserIsNotAvailable(): void { // Given $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); @@ -95,7 +97,7 @@ public function testVoteWillAbstainWhenAUserIsNotAvailable() $this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $decision, 'Should abstain from voting'); } - public function testVoteWillAbstainWhenAUserIsLoggedInButIsNotAFOSUser() + public function testVoteWillAbstainWhenAUserIsLoggedInButIsNotAFOSUser(): void { // Given $user = $this->createMock('FOS\UserBundle\Model\UserInterface'); diff --git a/tests/Security/EditableRolesBuilderTest.php b/tests/Security/EditableRolesBuilderTest.php index 26bc49299..b0283480d 100644 --- a/tests/Security/EditableRolesBuilderTest.php +++ b/tests/Security/EditableRolesBuilderTest.php @@ -1,5 +1,7 @@ createMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); @@ -71,7 +73,7 @@ public function testRolesFromHierarchy() $this->assertEquals($expected, $roles); } - public function testRolesFromAdminWithMasterAdmin() + public function testRolesFromAdminWithMasterAdmin(): void { $securityHandler = $this->createMock('Sonata\AdminBundle\Security\Handler\SecurityHandlerInterface'); $securityHandler->expects($this->exactly(2))->method('getBaseRole')->will($this->returnValue('ROLE_FOO_%s')); @@ -111,7 +113,7 @@ public function testRolesFromAdminWithMasterAdmin() $this->assertEquals($expected, $roles); } - public function testWithNoSecurityToken() + public function testWithNoSecurityToken(): void { $tokenStorage = $this->createMock(TokenStorageInterface::class); $tokenStorage->expects($this->any())->method('getToken')->will($this->returnValue(null)); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 771a59651..e14c4dd4d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@