aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/User
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
downloadnextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz
nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/User')
-rw-r--r--tests/lib/User/DatabaseTest.php8
-rw-r--r--tests/lib/User/ManagerTest.php22
-rw-r--r--tests/lib/User/SessionTest.php24
-rw-r--r--tests/lib/User/UserTest.php2
4 files changed, 28 insertions, 28 deletions
diff --git a/tests/lib/User/DatabaseTest.php b/tests/lib/User/DatabaseTest.php
index 202a8225f94..65d483734d9 100644
--- a/tests/lib/User/DatabaseTest.php
+++ b/tests/lib/User/DatabaseTest.php
@@ -82,11 +82,11 @@ class DatabaseTest extends Backend {
$this->assertSame($user, $this->backend->checkPassword($user, 'newpass'));
}
- /**
- * @expectedException \OC\HintException
- * @expectedExceptionMessage password change failed
- */
+
public function testVerifyPasswordEventFail() {
+ $this->expectException(\OC\HintException::class);
+ $this->expectExceptionMessage('password change failed');
+
$user = $this->getUser();
$this->backend->createUser($user, 'pass1');
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index 4d70e30273a..58a6b550658 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -30,7 +30,7 @@ class ManagerTest extends TestCase {
/** @var EventDispatcherInterface */
private $dispatcher;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
@@ -367,10 +367,10 @@ class ManagerTest extends TestCase {
$this->assertEquals('foo', $user->getUID());
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateUserSingleBackendExists() {
+ $this->expectException(\Exception::class);
+
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
*/
@@ -420,11 +420,11 @@ class ManagerTest extends TestCase {
$this->assertFalse($manager->createUser('foo', 'bar'));
}
- /**
- * @expectedException \InvalidArgumentException
- * @expectedExceptionMessage Could not create user
- */
+
public function testCreateUserFromBackendWithBackendError() {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Could not create user');
+
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject $config */
$config = $this->createMock(IConfig::class);
/** @var \Test\Util\User\Dummy|\PHPUnit_Framework_MockObject_MockObject $backend */
@@ -439,10 +439,10 @@ class ManagerTest extends TestCase {
$manager->createUserFromBackend('MyUid', 'MyPassword', $backend);
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateUserTwoBackendExists() {
+ $this->expectException(\Exception::class);
+
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend1
*/
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index a9d466e5408..3567aa9cf62 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -271,10 +271,10 @@ class SessionTest extends \Test\TestCase {
$this->assertEquals($user, $userSession->getUser());
}
- /**
- * @expectedException \OC\User\LoginException
- */
+
public function testLoginValidPasswordDisabled() {
+ $this->expectException(\OC\User\LoginException::class);
+
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
$session->expects($this->never())
->method('set');
@@ -404,10 +404,10 @@ class SessionTest extends \Test\TestCase {
$userSession->login('foo', 'bar');
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordLoginForbiddenException
- */
+
public function testLogClientInNoTokenPasswordWith2fa() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordLoginForbiddenException::class);
+
$manager = $this->createMock(Manager::class);
$session = $this->createMock(ISession::class);
$request = $this->createMock(IRequest::class);
@@ -508,10 +508,10 @@ class SessionTest extends \Test\TestCase {
$this->assertTrue($userSession->logClientIn('john', 'I-AM-AN-APP-PASSWORD', $request, $this->throttler));
}
- /**
- * @expectedException \OC\Authentication\Exceptions\PasswordLoginForbiddenException
- */
+
public function testLogClientInNoTokenPasswordNo2fa() {
+ $this->expectException(\OC\Authentication\Exceptions\PasswordLoginForbiddenException::class);
+
$manager = $this->createMock(Manager::class);
$session = $this->createMock(ISession::class);
$request = $this->createMock(IRequest::class);
@@ -973,10 +973,10 @@ class SessionTest extends \Test\TestCase {
$this->assertFalse($userSession->createSessionToken($request, $uid, $loginName, $password));
}
- /**
- * @expectedException \OC\User\LoginException
- */
+
public function testTryTokenLoginWithDisabledUser() {
+ $this->expectException(\OC\User\LoginException::class);
+
$manager = $this->getMockBuilder('\OC\User\Manager')
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index b4964e28206..0bf582727ff 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -33,7 +33,7 @@ class UserTest extends TestCase {
/** @var EventDispatcherInterface|MockObject */
protected $dispatcher;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
}