Update# add DB to RegistrationServiceTest
This commit is contained in:
parent
63837e7079
commit
c5be32bd17
|
|
@ -23,7 +23,6 @@ use OCP\IUser;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
//use \Test\TestCase;
|
|
||||||
|
|
||||||
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
||||||
use ChristophWurst\Nextcloud\Testing\TestCase;
|
use ChristophWurst\Nextcloud\Testing\TestCase;
|
||||||
|
|
@ -71,13 +70,12 @@ class RegistrationServiceTest extends TestCase {
|
||||||
$this->mailService = $this->createMock(MailService::class);
|
$this->mailService = $this->createMock(MailService::class);
|
||||||
$this->l10n = $this->createMock(IL10N::class);
|
$this->l10n = $this->createMock(IL10N::class);
|
||||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||||
$this->registrationMapper = $this->createMock(RegistrationMapper::class);
|
|
||||||
#$this->userManager = $this->createMock(IUserManager::class);
|
#$this->userManager = $this->createMock(IUserManager::class);
|
||||||
$this->userManager = \OC::$server->getUserManager();
|
$this->userManager = \OC::$server->getUserManager();
|
||||||
$this->config = $this->createMock(IConfig::class);
|
$this->config = $this->createMock(IConfig::class);
|
||||||
$this->groupManager = \OC::$server->getGroupManager();
|
$this->groupManager = \OC::$server->getGroupManager();
|
||||||
$this->defaults = $this->createMock(Defaults::class);
|
$this->defaults = $this->createMock(Defaults::class);
|
||||||
$this->random = $this->createMock(ISecureRandom::class);
|
$this->random = \OC::$server->getSecureRandom();
|
||||||
$this->usersession = $this->createMock(IUserSession::class);
|
$this->usersession = $this->createMock(IUserSession::class);
|
||||||
$this->request = $this->createMock(IRequest::class);
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->logger = $this->createMock(ILogger::class);
|
$this->logger = $this->createMock(ILogger::class);
|
||||||
|
|
@ -85,6 +83,11 @@ class RegistrationServiceTest extends TestCase {
|
||||||
$this->tokenProvider = $this->createMock(IProvider::class);
|
$this->tokenProvider = $this->createMock(IProvider::class);
|
||||||
$this->crypto = $this->createMock(ICrypto::class);
|
$this->crypto = $this->createMock(ICrypto::class);
|
||||||
|
|
||||||
|
$this->registrationMapper = new RegistrationMapper(
|
||||||
|
\OC::$server->getDatabaseConnection(),
|
||||||
|
$this->random
|
||||||
|
);
|
||||||
|
|
||||||
$this->service = new RegistrationService(
|
$this->service = new RegistrationService(
|
||||||
'registration',
|
'registration',
|
||||||
$this->mailService,
|
$this->mailService,
|
||||||
|
|
@ -105,6 +108,30 @@ class RegistrationServiceTest extends TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testValidateNewEmail() {
|
||||||
|
$email = 'aaaa@example.com';
|
||||||
|
|
||||||
|
$this->config->expects($this->at(0))
|
||||||
|
->method('getAppValue')
|
||||||
|
->with("registration", 'allowed_domains', '')
|
||||||
|
->willReturn('');
|
||||||
|
|
||||||
|
$ret = $this->service->validateEmail($email);
|
||||||
|
|
||||||
|
//$this->assertInstanceOf(Registration::class, $ret);
|
||||||
|
$this->assertTrue($ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testValidatePendingReg() {
|
||||||
|
$email = 'aaaa@example.com';
|
||||||
|
|
||||||
|
$this->service->createRegistration($email, 'alice');
|
||||||
|
$ret = $this->service->validateEmail($email);
|
||||||
|
|
||||||
|
$this->assertInstanceOf(Registration::class, $ret);
|
||||||
|
$this->assertEquals($email, $ret->getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateAccountWebForm() {
|
public function testCreateAccountWebForm() {
|
||||||
$reg = new Registration();
|
$reg = new Registration();
|
||||||
$reg->setEmail("asd@example.com");
|
$reg->setEmail("asd@example.com");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue