Skip to content

Commit 6e65a8f

Browse files
committed
Added tests for UserManagerNone and GroupManagerNone
1 parent 163262e commit 6e65a8f

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

Tests/Model/GroupManagerNoneTest.php

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSUserBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\UserBundle\Tests\Model;
13+
14+
use FOS\UserBundle\Model\GroupManagerNone;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class GroupManagerNoneTest extends TestCase
18+
{
19+
/**
20+
* @dataProvider methodsProvider
21+
* @expectedException \RuntimeException
22+
*/
23+
public function testMethods($name, $arguments)
24+
{
25+
$manager = new GroupManagerNone();
26+
27+
call_user_func_array(array($manager, $name), $arguments);
28+
}
29+
30+
public function methodsProvider()
31+
{
32+
$group = $this->getMockBuilder('FOS\UserBundle\Model\GroupInterface')->getMock();
33+
34+
return array(
35+
array('deleteGroup', array($group)),
36+
array('findGroupBy', array(array('id' => 1))),
37+
array('findGroups', array()),
38+
array('getClass', array()),
39+
array('updateGroup', array($group)),
40+
);
41+
}
42+
}

Tests/Model/UserManagerNoneTest.php

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSUserBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\UserBundle\Tests\Model;
13+
14+
use FOS\UserBundle\Model\UserManagerNone;
15+
use PHPUnit\Framework\TestCase;
16+
17+
class UserManagerNoneTest extends TestCase
18+
{
19+
/**
20+
* @dataProvider methodsProvider
21+
* @expectedException \RuntimeException
22+
*/
23+
public function testMethods($name, $arguments)
24+
{
25+
/** @var \FOS\UserBundle\Util\PasswordUpdaterInterface $passwordUpdater */
26+
$passwordUpdater = $this->getMockBuilder('FOS\UserBundle\Util\PasswordUpdaterInterface')->getMock();
27+
/** @var \FOS\UserBundle\Util\CanonicalFieldsUpdater $fieldsUpdater */
28+
$fieldsUpdater = $this->getMockBuilder('FOS\UserBundle\Util\CanonicalFieldsUpdater')
29+
->disableOriginalConstructor()
30+
->getMock();
31+
32+
$manager = new UserManagerNone($passwordUpdater, $fieldsUpdater);
33+
34+
call_user_func_array(array($manager, $name), $arguments);
35+
}
36+
37+
public function methodsProvider()
38+
{
39+
$user = $this->getMockBuilder('FOS\UserBundle\Model\UserInterface')->getMock();
40+
41+
return array(
42+
array('deleteUser', array($user)),
43+
array('findUserBy', array(array('id' => 1))),
44+
array('findUsers', array()),
45+
array('getClass', array()),
46+
array('reloadUser', array($user)),
47+
array('updateUser', array($user)),
48+
);
49+
}
50+
}

0 commit comments

Comments
 (0)