Skip to content

Commit

Permalink
Added tests for UserManagerNone and GroupManagerNone
Browse files Browse the repository at this point in the history
  • Loading branch information
covex-nn committed May 22, 2018
1 parent ff1ef94 commit 8be05a6
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Tests/Model/GroupManagerNoneTest.php
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)),
);
}
}
50 changes: 50 additions & 0 deletions Tests/Model/UserManagerNoneTest.php
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)),
);
}
}

0 comments on commit 8be05a6

Please sign in to comment.