diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/Authentication | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-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/Authentication')
6 files changed, 46 insertions, 46 deletions
diff --git a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php index fb20558c95a..7060dc2a770 100644 --- a/tests/lib/Authentication/Token/DefaultTokenMapperTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenMapperTest.php @@ -145,10 +145,10 @@ class DefaultTokenMapperTest extends TestCase { $this->assertEquals($token, $dbToken); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetInvalidToken() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $token = 'thisisaninvalidtokenthatisnotinthedatabase'; $this->mapper->getToken($token); @@ -175,17 +175,17 @@ class DefaultTokenMapperTest extends TestCase { $this->assertEquals($token, $dbToken); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetTokenByIdNotFound() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $this->mapper->getTokenById(-1); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetInvalidTokenById() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $id = 42; $this->mapper->getToken($id); diff --git a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php index b90a9931937..b4e5e097847 100644 --- a/tests/lib/Authentication/Token/DefaultTokenProviderTest.php +++ b/tests/lib/Authentication/Token/DefaultTokenProviderTest.php @@ -159,10 +159,10 @@ class DefaultTokenProviderTest extends TestCase { $this->assertEquals('passme', $actual); } - /** - * @expectedException \OC\Authentication\Exceptions\PasswordlessTokenException - */ + public function testGetPasswordPasswordLessToken() { + $this->expectException(\OC\Authentication\Exceptions\PasswordlessTokenException::class); + $token = 'token1234'; $tk = new DefaultToken(); $tk->setPassword(null); @@ -170,10 +170,10 @@ class DefaultTokenProviderTest extends TestCase { $this->tokenProvider->getPassword($tk, $token); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidTokenException - */ + public function testGetPasswordDeletesInvalidToken() { + $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class); + $token = 'token1234'; $tk = new DefaultToken(); $tk->setPassword('someencryptedvalue'); @@ -222,10 +222,10 @@ class DefaultTokenProviderTest extends TestCase { $this->assertEquals('encryptedpassword', $token->getPassword()); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidTokenException - */ + public function testSetPasswordInvalidToken() { + $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class); + $token = $this->createMock(IToken::class); $tokenId = 'token123'; $password = '123456'; diff --git a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php index b58001ee7bb..58340b905c0 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenMapperTest.php @@ -171,10 +171,10 @@ class PublicKeyTokenMapperTest extends TestCase { $this->assertEquals($token, $dbToken); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetInvalidToken() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $token = 'thisisaninvalidtokenthatisnotinthedatabase'; $this->mapper->getToken($token); @@ -203,17 +203,17 @@ class PublicKeyTokenMapperTest extends TestCase { $this->assertEquals($token, $dbToken); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetTokenByIdNotFound() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $this->mapper->getTokenById(-1); } - /** - * @expectedException \OCP\AppFramework\Db\DoesNotExistException - */ + public function testGetInvalidTokenById() { + $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); + $id = '42'; $this->mapper->getToken($id); diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index aecbd969ee1..3fa7a92bb9b 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -145,10 +145,10 @@ class PublicKeyTokenProviderTest extends TestCase { $this->assertSame($password, $this->tokenProvider->getPassword($actual, $token)); } - /** - * @expectedException \OC\Authentication\Exceptions\PasswordlessTokenException - */ + public function testGetPasswordPasswordLessToken() { + $this->expectException(\OC\Authentication\Exceptions\PasswordlessTokenException::class); + $token = 'token1234'; $tk = new PublicKeyToken(); $tk->setPassword(null); @@ -156,10 +156,10 @@ class PublicKeyTokenProviderTest extends TestCase { $this->tokenProvider->getPassword($tk, $token); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidTokenException - */ + public function testGetPasswordInvalidToken() { + $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class); + $token = 'token'; $uid = 'user'; $user = 'User'; @@ -205,10 +205,10 @@ class PublicKeyTokenProviderTest extends TestCase { $this->assertSame($newpass, $this->tokenProvider->getPassword($actual, 'token')); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidTokenException - */ + public function testSetPasswordInvalidToken() { + $this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class); + $token = $this->createMock(IToken::class); $tokenId = 'token123'; $password = '123456'; diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php index 634ab97a8bf..f3762976837 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ProviderLoaderTest.php @@ -52,11 +52,11 @@ class ProviderLoaderTest extends TestCase { $this->loader = new ProviderLoader($this->appManager); } - /** - * @expectedException Exception - * @expectedExceptionMessage Could not load two-factor auth provider \OCA\MyFaulty2faApp\DoesNotExist - */ + public function testFailHardIfProviderCanNotBeLoaded() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('Could not load two-factor auth provider \\OCA\\MyFaulty2faApp\\DoesNotExist'); + $this->appManager->expects($this->once()) ->method('getEnabledAppsForUser') ->with($this->user) diff --git a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php index f776e244c27..e34d844c3a4 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ProviderManagerTest.php @@ -59,10 +59,10 @@ class ProviderManagerTest extends TestCase { ); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidProviderException - */ + public function testTryEnableInvalidProvider() { + $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class); + $user = $this->createMock(IUser::class); $this->providerManager->tryEnableProviderFor('none', $user); } @@ -105,10 +105,10 @@ class ProviderManagerTest extends TestCase { $this->assertTrue($res); } - /** - * @expectedException \OC\Authentication\Exceptions\InvalidProviderException - */ + public function testTryDisableInvalidProvider() { + $this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class); + $user = $this->createMock(IUser::class); $this->providerManager->tryDisableProviderFor('none', $user); } |