fix deprecated usage of phpunit annotations
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
47a257fc90
commit
098a96ded5
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace OCA\User_SAML\Tests\Controller;
|
namespace OCA\User_SAML\Tests\Controller;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use OCA\User_SAML\Controller\SAMLController;
|
use OCA\User_SAML\Controller\SAMLController;
|
||||||
use OCA\User_SAML\Exceptions\NoUserFoundException;
|
use OCA\User_SAML\Exceptions\NoUserFoundException;
|
||||||
use OCA\User_SAML\SAMLSettings;
|
use OCA\User_SAML\SAMLSettings;
|
||||||
|
@ -114,16 +115,16 @@ class SAMLControllerTest extends TestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedExceptionMessage Type of "UnknownValue" is not supported for user_saml
|
|
||||||
* @expectedException \Exception
|
|
||||||
*/
|
|
||||||
public function testLoginWithInvalidAppValue() {
|
public function testLoginWithInvalidAppValue() {
|
||||||
$this->config
|
$this->config
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getAppValue')
|
->method('getAppValue')
|
||||||
->with('user_saml', 'type')
|
->with('user_saml', 'type')
|
||||||
->willReturn('UnknownValue');
|
->willReturn('UnknownValue');
|
||||||
|
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage('Type of "UnknownValue" is not supported for user_saml');
|
||||||
|
|
||||||
$this->samlController->login(1);
|
$this->samlController->login(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace OCA\User_SAML\Tests\Middleware;
|
namespace OCA\User_SAML\Tests\Middleware;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use OCA\User_SAML\Middleware\OnlyLoggedInMiddleware;
|
use OCA\User_SAML\Middleware\OnlyLoggedInMiddleware;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
@ -79,10 +80,6 @@ class OnlyLoggedInMiddlewareTest extends \Test\TestCase {
|
||||||
$this->onlyLoggedInMiddleware->beforeController($this->createMock(Controller::class), 'bar');
|
$this->onlyLoggedInMiddleware->beforeController($this->createMock(Controller::class), 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Exception
|
|
||||||
* @expectedExceptionMessage User is already logged-in
|
|
||||||
*/
|
|
||||||
public function testBeforeControllerWithAnnotationAndLoggedIn() {
|
public function testBeforeControllerWithAnnotationAndLoggedIn() {
|
||||||
$this->reflector
|
$this->reflector
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -94,15 +91,19 @@ class OnlyLoggedInMiddlewareTest extends \Test\TestCase {
|
||||||
->method('isLoggedIn')
|
->method('isLoggedIn')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage('User is already logged-in');
|
||||||
|
|
||||||
$this->onlyLoggedInMiddleware->beforeController($this->createMock(Controller::class), 'bar');
|
$this->onlyLoggedInMiddleware->beforeController($this->createMock(Controller::class), 'bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Exception
|
|
||||||
* @expectedExceptionMessage My Exception
|
|
||||||
*/
|
|
||||||
public function testAfterExceptionWithNormalException() {
|
public function testAfterExceptionWithNormalException() {
|
||||||
$exception = new \Exception('My Exception');
|
$exceptionMsg = 'My Exception';
|
||||||
|
$exception = new Exception($exceptionMsg);
|
||||||
|
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage($exceptionMsg);
|
||||||
|
|
||||||
$this->onlyLoggedInMiddleware->afterException($this->createMock(Controller::class), 'bar', $exception);
|
$this->onlyLoggedInMiddleware->afterException($this->createMock(Controller::class), 'bar', $exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ class OnlyLoggedInMiddlewareTest extends \Test\TestCase {
|
||||||
->with('/')
|
->with('/')
|
||||||
->willReturn($homeUrl);
|
->willReturn($homeUrl);
|
||||||
|
|
||||||
$exception = new \Exception('User is already logged-in');
|
$exception = new Exception('User is already logged-in');
|
||||||
$expected = new RedirectResponse($homeUrl);
|
$expected = new RedirectResponse($homeUrl);
|
||||||
$this->assertEquals($expected, $this->onlyLoggedInMiddleware->afterException($this->createMock(Controller::class), 'bar', $exception));
|
$this->assertEquals($expected, $this->onlyLoggedInMiddleware->afterException($this->createMock(Controller::class), 'bar', $exception));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue