mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-05-04 10:03:42 +02:00
add unit tests
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
c839dc1e73
commit
89da6ce72d
|
@ -69,6 +69,9 @@ class SAMLControllerTest extends TestCase {
|
|||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->samlSettings = $this->createMock(SAMLSettings::class);
|
||||
$this->userBackend = $this->createMock(UserBackend::class);
|
||||
$this->userBackend->expects($this->any())
|
||||
->method('testEncodedObjectGUID')
|
||||
->willReturnArgument(0);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
|
@ -275,11 +278,11 @@ class SAMLControllerTest extends TestCase {
|
|||
->with('/')
|
||||
->willReturn('https://nextcloud.com/absolute/');
|
||||
$this->userBackend
|
||||
->expects($this->at(0))
|
||||
->expects($this->once())
|
||||
->method('autoprovisionAllowed')
|
||||
->willReturn(true);
|
||||
$this->userBackend
|
||||
->expects($this->at(1))
|
||||
->expects($this->once())
|
||||
->method('createUserIfNotExists')
|
||||
->with('MyUid');
|
||||
$this->userBackend
|
||||
|
@ -332,11 +335,11 @@ class SAMLControllerTest extends TestCase {
|
|||
->with('user_saml.SAML.notProvisioned')
|
||||
->willReturn('https://nextcloud.com/notprovisioned/');
|
||||
$this->userBackend
|
||||
->expects($this->at(0))
|
||||
->expects($this->once())
|
||||
->method('autoprovisionAllowed')
|
||||
->willReturn(true);
|
||||
$this->userBackend
|
||||
->expects($this->at(1))
|
||||
->expects($this->once())
|
||||
->method('createUserIfNotExists')
|
||||
->with('MyUid');
|
||||
$this->userBackend
|
||||
|
|
|
@ -281,5 +281,25 @@ class UserBackendTest extends TestCase {
|
|||
$this->userBackend->updateAttributes('ExistingUser', ['email' => 'new@example.com', 'displayname' => 'New Displayname', 'quota' => '']);
|
||||
}
|
||||
|
||||
public function objectGuidProvider() {
|
||||
return [
|
||||
['Joey No Conversion', 'Joey No Conversion'],
|
||||
['no@convers.ion', 'no@convers.ion'],
|
||||
['a0aa9ed8-6b48-1034-8ad7-8fb78330d80a', 'a0aa9ed8-6b48-1034-8ad7-8fb78330d80a'],
|
||||
['EDE70D16-B9D5-4E9A-ABD7-614D17246E3F', 'EDE70D16-B9D5-4E9A-ABD7-614D17246E3F'],
|
||||
['Tm8gY29udmVyc2lvbgo=', 'Tm8gY29udmVyc2lvbgo='],
|
||||
['ASfjU2OYEd69ZgAVF4pePA==', '53E32701-9863-DE11-BD66-0015178A5E3C'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider objectGuidProvider
|
||||
*/
|
||||
public function testTestEncodedObjectGUID(string $input, string $expectation) {
|
||||
$this->getMockedBuilder(['getDisplayName', 'setDisplayName']);
|
||||
$uid = $this->userBackend->testEncodedObjectGUID($input);
|
||||
$this->assertSame($expectation, $uid);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue