From 6e65a8fe58d7d89bcd295a1cc91fa00f246e5ad4 Mon Sep 17 00:00:00 2001 From: "Andrey F. Mindubaev" Date: Fri, 12 Jan 2018 19:44:01 +0300 Subject: [PATCH] Added tests for UserManagerNone and GroupManagerNone --- Tests/Model/GroupManagerNoneTest.php | 42 +++++++++++++++++++++++ Tests/Model/UserManagerNoneTest.php | 50 ++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Tests/Model/GroupManagerNoneTest.php create mode 100644 Tests/Model/UserManagerNoneTest.php diff --git a/Tests/Model/GroupManagerNoneTest.php b/Tests/Model/GroupManagerNoneTest.php new file mode 100644 index 0000000000..43338d1cb9 --- /dev/null +++ b/Tests/Model/GroupManagerNoneTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace FOS\UserBundle\Tests\Model; + +use FOS\UserBundle\Model\GroupManagerNone; +use PHPUnit\Framework\TestCase; + +class GroupManagerNoneTest extends TestCase +{ + /** + * @dataProvider methodsProvider + * @expectedException \RuntimeException + */ + public function testMethods($name, $arguments) + { + $manager = new GroupManagerNone(); + + call_user_func_array(array($manager, $name), $arguments); + } + + public function methodsProvider() + { + $group = $this->getMockBuilder('FOS\UserBundle\Model\GroupInterface')->getMock(); + + return array( + array('deleteGroup', array($group)), + array('findGroupBy', array(array('id' => 1))), + array('findGroups', array()), + array('getClass', array()), + array('updateGroup', array($group)), + ); + } +} diff --git a/Tests/Model/UserManagerNoneTest.php b/Tests/Model/UserManagerNoneTest.php new file mode 100644 index 0000000000..0aabbb5609 --- /dev/null +++ b/Tests/Model/UserManagerNoneTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace FOS\UserBundle\Tests\Model; + +use FOS\UserBundle\Model\UserManagerNone; +use PHPUnit\Framework\TestCase; + +class UserManagerNoneTest extends TestCase +{ + /** + * @dataProvider methodsProvider + * @expectedException \RuntimeException + */ + public function testMethods($name, $arguments) + { + /** @var \FOS\UserBundle\Util\PasswordUpdaterInterface $passwordUpdater */ + $passwordUpdater = $this->getMockBuilder('FOS\UserBundle\Util\PasswordUpdaterInterface')->getMock(); + /** @var \FOS\UserBundle\Util\CanonicalFieldsUpdater $fieldsUpdater */ + $fieldsUpdater = $this->getMockBuilder('FOS\UserBundle\Util\CanonicalFieldsUpdater') + ->disableOriginalConstructor() + ->getMock(); + + $manager = new UserManagerNone($passwordUpdater, $fieldsUpdater); + + call_user_func_array(array($manager, $name), $arguments); + } + + public function methodsProvider() + { + $user = $this->getMockBuilder('FOS\UserBundle\Model\UserInterface')->getMock(); + + return array( + array('deleteUser', array($user)), + array('findUserBy', array(array('id' => 1))), + array('findUsers', array()), + array('getClass', array()), + array('reloadUser', array($user)), + array('updateUser', array($user)), + ); + } +}