mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-05-05 02:23:42 +02:00
add tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
4b8558522b
commit
1eb3b565db
|
@ -54,6 +54,11 @@ class Test extends TestCase {
|
|||
'url' => '/saml/notProvisioned',
|
||||
'verb' => 'GET',
|
||||
],
|
||||
[
|
||||
'name' => 'SAML#genericError',
|
||||
'url' => '/saml/error',
|
||||
'verb' => 'GET',
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->assertSame($expected, $routes);
|
||||
|
|
|
@ -27,6 +27,7 @@ use OCA\User_SAML\UserBackend;
|
|||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\ILogger;
|
||||
use OCP\IRequest;
|
||||
use OCP\ISession;
|
||||
|
@ -55,6 +56,8 @@ class SAMLControllerTest extends TestCase {
|
|||
private $userManager;
|
||||
/** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $logger;
|
||||
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l;
|
||||
/** @var SAMLController */
|
||||
private $samlController;
|
||||
|
||||
|
@ -70,6 +73,13 @@ class SAMLControllerTest extends TestCase {
|
|||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->logger = $this->createMock(ILogger::class);
|
||||
$this->l = $this->createMock(IL10N::class);
|
||||
|
||||
$this->l->expects($this->any())->method('t')->willReturnCallback(
|
||||
function($param) {
|
||||
return $param;
|
||||
}
|
||||
);
|
||||
|
||||
$this->samlController = new SAMLController(
|
||||
'user_saml',
|
||||
|
@ -81,7 +91,8 @@ class SAMLControllerTest extends TestCase {
|
|||
$this->config,
|
||||
$this->urlGenerator,
|
||||
$this->userManager,
|
||||
$this->logger
|
||||
$this->logger,
|
||||
$this->l
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -378,4 +389,22 @@ class SAMLControllerTest extends TestCase {
|
|||
$expected = new TemplateResponse('user_saml', 'notProvisioned', [], 'guest');
|
||||
$this->assertEquals($expected, $this->samlController->notProvisioned());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataTestGenericError
|
||||
*
|
||||
* @param string $messageSend
|
||||
* @param string $messageExpected
|
||||
*/
|
||||
public function testGenericError($messageSend, $messageExpected) {
|
||||
$expected = new TemplateResponse('user_saml', 'error', ['message' => $messageExpected], 'guest');
|
||||
$this->assertEquals($expected, $this->samlController->genericError($messageSend));
|
||||
}
|
||||
|
||||
public function dataTestGenericError() {
|
||||
return [
|
||||
['messageSend' => '', 'messageExpected' => 'Unknown error, please check the log file for more details.'],
|
||||
['messageSend' => 'test message', 'messageExpected' => 'test message'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue