diff options
author | Joas Schilling <coding@schilljs.com> | 2017-04-25 17:11:57 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-25 17:20:35 +0200 |
commit | ac0c21f4a7473396677ab5eb461c660532a1558e (patch) | |
tree | 819566c251668c6f3f14763aaa7f7c1c1a225a20 /tests/lib/User/UserTest.php | |
parent | 8ef25a7628d44465d4777686227407f9a2067700 (diff) | |
download | nextcloud-server-ac0c21f4a7473396677ab5eb461c660532a1558e.tar.gz nextcloud-server-ac0c21f4a7473396677ab5eb461c660532a1558e.zip |
Trigger change when a user is enabled/disabled
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/User/UserTest.php')
-rw-r--r-- | tests/lib/User/UserTest.php | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 5fc07b692f7..b53d07b0d4e 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -705,7 +705,55 @@ class UserTest extends TestCase { 'false' ); - $user = new User('foo', $backend, null, $config); + $user = $this->getMockBuilder(User::class) + ->setConstructorArgs([ + 'foo', + $backend, + null, + $config, + ]) + ->setMethods(['isEnabled', 'triggerChange']) + ->getMock(); + + $user->expects($this->once()) + ->method('isEnabled') + ->willReturn(true); + $user->expects($this->once()) + ->method('triggerChange') + ->with( + 'enabled', + 'false' + ); + + $user->setEnabled(false); + } + + public function testSetDisabledAlreadyDisabled() { + /** + * @var Backend | \PHPUnit_Framework_MockObject_MockObject $backend + */ + $backend = $this->createMock(\Test\Util\User\Dummy::class); + + $config = $this->createMock(IConfig::class); + $config->expects($this->never()) + ->method('setUserValue'); + + $user = $this->getMockBuilder(User::class) + ->setConstructorArgs([ + 'foo', + $backend, + null, + $config, + ]) + ->setMethods(['isEnabled', 'triggerChange']) + ->getMock(); + + $user->expects($this->once()) + ->method('isEnabled') + ->willReturn(false); + $user->expects($this->never()) + ->method('triggerChange'); + $user->setEnabled(false); } |