add unit tests

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-09-19 14:07:21 +02:00
parent c839dc1e73
commit 89da6ce72d
No known key found for this signature in database
GPG key ID: 7424F1874854DF23
2 changed files with 27 additions and 4 deletions

View file

@ -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

View file

@ -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);
}
}