forked from KnpLabs/KnpUserBundle
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for UserManagerNone and GroupManagerNone
- Loading branch information
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSUserBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* 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)), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSUserBundle package. | ||
* | ||
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> | ||
* | ||
* 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)), | ||
); | ||
} | ||
} |