Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/registration.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPellaeon Lin <nfsmwlin@gmail.com>2018-04-28 19:24:37 +0300
committerPellaeon Lin <nfsmwlin@gmail.com>2018-04-28 19:24:37 +0300
commit542d65f4539c22a605df54fce479d1602a3e3a44 (patch)
treed3615c722df10f6c798e156469c3ba0eb8a3dc3b /tests
parent9cc755e30905a1c0a8e4e72e7d689d9d9e142acd (diff)
Add# integration test for duplicate username
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/service/RegistrationServiceTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/integration/service/RegistrationServiceTest.php b/tests/integration/service/RegistrationServiceTest.php
index d9358d6..9d9c5a2 100644
--- a/tests/integration/service/RegistrationServiceTest.php
+++ b/tests/integration/service/RegistrationServiceTest.php
@@ -140,7 +140,43 @@ class RegistrationServiceTest extends TestCase {
$this->assertInstanceOf(IUser::class, $resulting_user);
$this->assertEquals($form_input_username, $resulting_user->getUID());
$this->assertEquals('asd@example.com', $resulting_user->getEmailAddress());
+ }
+
+ /**
+ * @depends testCreateAccountWebForm
+ * @expectedException OCA\Registration\Service\RegistrationException
+ */
+ public function testDuplicateUsernameWebForm() {
+ $reg = new Registration();
+ $reg->setEmail("pppp@example.com");
+ //$reg->setUsername("alice1");
+ $reg->setDisplayname("Alice");
+ //$reg->setPassword("asdf");
+ $reg->setEmailConfirmed(true);
+ $resulting_user = $this->service->createAccount($reg, 'alice1', 'asdf');
+ }
+
+ /*
+ * NOTE
+ * We don't need to test for duplicate emails here, because:
+ * In Webform, emails are validated not to be duplicate in validateEmail(),
+ * that is, when users first fill in their email
+ * In API, they are also validated in ApiControllerTest::validate()
+ */
+
+ /**
+ * @depends testCreateAccountWebForm
+ * @expectedException OCA\Registration\Service\RegistrationException
+ */
+ public function testDuplicateUsernameApi() {
+ $reg = new Registration();
+ $reg->setEmail("pppp@example.com");
+ $reg->setUsername("alice1");
+ $reg->setDisplayname("Alice");
+ $reg->setPassword("asdf");
+ $reg->setEmailConfirmed(true);
+ $resulting_user = $this->service->createAccount($reg);
}
}