Fix tests
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
0560e69913
commit
1be75e8db8
|
@ -444,19 +444,17 @@ class UsersController extends Controller {
|
||||||
$link = $this->urlGenerator->getAbsoluteURL('/');
|
$link = $this->urlGenerator->getAbsoluteURL('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$emailTemplate = new EMailTemplate($this->defaults);
|
$emailTemplate = new EMailTemplate($this->defaults);
|
||||||
|
|
||||||
$emailTemplate->addHeader($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('', 'logo-mail-header.png')));
|
$emailTemplate->addHeader($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('', 'logo-mail-header.png')));
|
||||||
|
|
||||||
$displayname = $user->getDisplayName();
|
$displayName = $user->getDisplayName();
|
||||||
if ($displayname === $username) {
|
if ($displayName === $username) {
|
||||||
$emailTemplate->addHeading($this->l10n->t('Welcome aboard'));
|
$emailTemplate->addHeading($this->l10n->t('Welcome aboard'));
|
||||||
} else {
|
} else {
|
||||||
$emailTemplate->addHeading($this->l10n->t('Welcome aboard %s', $displayname));
|
$emailTemplate->addHeading($this->l10n->t('Welcome aboard %s', [$displayName]));
|
||||||
}
|
}
|
||||||
$emailTemplate->addBodyText($this->l10n->t('You have now an Nextcloud account, you can add, protect, and share your data.'));
|
$emailTemplate->addBodyText($this->l10n->t('You have now an %s account, you can add, protect, and share your data.', [$this->defaults->getName()]));
|
||||||
$emailTemplate->addBodyText($this->l10n->t('Your username is: %s', [$username]));
|
$emailTemplate->addBodyText($this->l10n->t('Your username is: %s', [$username]));
|
||||||
|
|
||||||
if ($generatedPassword) {
|
if ($generatedPassword) {
|
||||||
|
@ -466,8 +464,10 @@ class UsersController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$emailTemplate->addBodyButtonGroup(
|
$emailTemplate->addBodyButtonGroup(
|
||||||
$leftButtonText, $link,
|
$leftButtonText,
|
||||||
$this->l10n->t('Install Client'), 'https://nextcloud.com/install/#install-clients'
|
$link,
|
||||||
|
$this->l10n->t('Install Client'),
|
||||||
|
'https://nextcloud.com/install/#install-clients'
|
||||||
);
|
);
|
||||||
|
|
||||||
$emailTemplate->addFooter(
|
$emailTemplate->addFooter(
|
||||||
|
|
|
@ -129,7 +129,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->defaults,
|
$this->defaults,
|
||||||
$this->mailer,
|
$this->mailer,
|
||||||
'no-reply@owncloud.com',
|
'no-reply@nextcloud.com',
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->appManager,
|
$this->appManager,
|
||||||
$this->avatarManager,
|
$this->avatarManager,
|
||||||
|
@ -153,7 +153,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->defaults,
|
$this->defaults,
|
||||||
$this->mailer,
|
$this->mailer,
|
||||||
'no-reply@owncloud.com',
|
'no-reply@nextcloud.com',
|
||||||
$this->urlGenerator,
|
$this->urlGenerator,
|
||||||
$this->appManager,
|
$this->appManager,
|
||||||
$this->avatarManager,
|
$this->avatarManager,
|
||||||
|
@ -1427,26 +1427,56 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$message
|
$message
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('setSubject')
|
->method('setSubject')
|
||||||
->with('Your account was created');
|
->with('Your Nextcloud account was created');
|
||||||
|
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(0))
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('/')
|
||||||
|
->willReturn('https://example.org/');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(1))
|
||||||
|
->method('imagePath')
|
||||||
|
->with('', 'logo-mail-header.png')
|
||||||
|
->willReturn('/img/logo-mail-header.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(2))
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('/img/logo-mail-header.png')
|
||||||
|
->willReturn('https://example.org/img/logo-mail-header.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(3))
|
||||||
|
->method('imagePath')
|
||||||
|
->with('', 'logo-mail-footer.png')
|
||||||
|
->willReturn('/img/logo-mail-footer.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(4))
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('/img/logo-mail-footer.png')
|
||||||
|
->willReturn('https://example.org/img/logo-mail-footer.png');
|
||||||
|
$this->defaults
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getName')
|
||||||
|
->willReturn('Nextcloud');
|
||||||
|
$this->defaults
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getSlogan')
|
||||||
|
->willReturn('A safe home for your data');
|
||||||
|
|
||||||
$emailTemplate = new EMailTemplate($this->defaults);
|
$emailTemplate = new EMailTemplate($this->defaults);
|
||||||
|
|
||||||
$emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
|
$emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
|
||||||
|
|
||||||
$emailTemplate->addHeading('Welcome aboard');
|
$emailTemplate->addHeading('Welcome aboard');
|
||||||
$emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
|
$emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
|
||||||
$emailTemplate->addBodyText('Your username is: foo');
|
$emailTemplate->addBodyText('Your username is: foo');
|
||||||
|
|
||||||
|
|
||||||
$emailTemplate->addBodyButtonGroup(
|
$emailTemplate->addBodyButtonGroup(
|
||||||
'Go to Nextcloud', 'https://example.org/resetPassword/123',
|
'Go to Nextcloud', 'https://example.org/',
|
||||||
'Install Client', 'https://nextcloud.com/install/#install-clients'
|
'Install Client', 'https://nextcloud.com/install/#install-clients'
|
||||||
);
|
);
|
||||||
|
|
||||||
$emailTemplate->addFooter(
|
$emailTemplate->addFooter(
|
||||||
'https://example.org/img/logo-mail-footer.png',
|
'https://example.org/img/logo-mail-footer.png',
|
||||||
'TestCloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
|
'Nextcloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$message
|
$message
|
||||||
->expects($this->at(2))
|
->expects($this->at(2))
|
||||||
->method('setHtmlBody')
|
->method('setHtmlBody')
|
||||||
|
@ -1458,7 +1488,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$message
|
$message
|
||||||
->expects($this->at(4))
|
->expects($this->at(4))
|
||||||
->method('setFrom')
|
->method('setFrom')
|
||||||
->with(['no-reply@owncloud.com' => null]);
|
->with(['no-reply@nextcloud.com' => 'Nextcloud']);
|
||||||
|
|
||||||
$this->mailer
|
$this->mailer
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -1485,6 +1515,9 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$user
|
$user
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
|
$user
|
||||||
|
->method('getDisplayName')
|
||||||
|
->will($this->returnValue('foo'));
|
||||||
$user
|
$user
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBackendClassName')
|
->method('getBackendClassName')
|
||||||
|
@ -2264,20 +2297,24 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
|
|
||||||
|
|
||||||
public function testCreateSuccessfulWithoutPasswordAndWithEmail() {
|
public function testCreateSuccessfulWithoutPasswordAndWithEmail() {
|
||||||
$controller = $this->getController(true);
|
|
||||||
|
|
||||||
$user = $this->getMockBuilder('\OC\User\User')
|
$user = $this->getMockBuilder('\OC\User\User')
|
||||||
->disableOriginalConstructor()->getMock();
|
->disableOriginalConstructor()->getMock();
|
||||||
$user
|
$user
|
||||||
->method('getHome')
|
->method('getHome')
|
||||||
->will($this->returnValue('/home/user'));
|
->willReturn('/home/user');
|
||||||
$user
|
$user
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('foo'));
|
->willReturn('foo');
|
||||||
|
$user
|
||||||
|
->method('getDisplayName')
|
||||||
|
->willReturn('John Doe');
|
||||||
|
$user
|
||||||
|
->method('getEmailAddress')
|
||||||
|
->willReturn('abc@example.org');
|
||||||
$user
|
$user
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
->method('getBackendClassName')
|
->method('getBackendClassName')
|
||||||
->will($this->returnValue('bar'));
|
->willReturn('bar');
|
||||||
|
|
||||||
$this->userManager
|
$this->userManager
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
|
@ -2310,11 +2347,6 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
ISecureRandom::CHAR_LOWER .
|
ISecureRandom::CHAR_LOWER .
|
||||||
ISecureRandom::CHAR_UPPER)
|
ISecureRandom::CHAR_UPPER)
|
||||||
->will($this->returnValue('mytoken'));
|
->will($this->returnValue('mytoken'));
|
||||||
$this->urlGenerator
|
|
||||||
->expects($this->once())
|
|
||||||
->method('linkToRouteAbsolute')
|
|
||||||
->with('core.lost.resetform', ['userId' => 'foo', 'token' => 'mytoken'])
|
|
||||||
->will($this->returnValue('link-with-my-token'));
|
|
||||||
|
|
||||||
$controller = $this->getController(true);
|
$controller = $this->getController(true);
|
||||||
$message = $this->getMockBuilder('\OC\Mail\Message')
|
$message = $this->getMockBuilder('\OC\Mail\Message')
|
||||||
|
@ -2326,26 +2358,56 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$message
|
$message
|
||||||
->expects($this->at(1))
|
->expects($this->at(1))
|
||||||
->method('setSubject')
|
->method('setSubject')
|
||||||
->with('Your account was created');
|
->with('Your Nextcloud account was created');
|
||||||
|
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(0))
|
||||||
|
->method('linkToRouteAbsolute')
|
||||||
|
->with('core.lost.resetform', ['userId' => 'foo', 'token' => 'mytoken'])
|
||||||
|
->will($this->returnValue('https://example.org/resetPassword/123'));
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(1))
|
||||||
|
->method('imagePath')
|
||||||
|
->with('', 'logo-mail-header.png')
|
||||||
|
->willReturn('/img/logo-mail-header.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(2))
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('/img/logo-mail-header.png')
|
||||||
|
->willReturn('https://example.org/img/logo-mail-header.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(3))
|
||||||
|
->method('imagePath')
|
||||||
|
->with('', 'logo-mail-footer.png')
|
||||||
|
->willReturn('/img/logo-mail-footer.png');
|
||||||
|
$this->urlGenerator
|
||||||
|
->expects($this->at(4))
|
||||||
|
->method('getAbsoluteURL')
|
||||||
|
->with('/img/logo-mail-footer.png')
|
||||||
|
->willReturn('https://example.org/img/logo-mail-footer.png');
|
||||||
|
$this->defaults
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getName')
|
||||||
|
->willReturn('Nextcloud');
|
||||||
|
$this->defaults
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getSlogan')
|
||||||
|
->willReturn('A safe home for your data');
|
||||||
|
|
||||||
$emailTemplate = new EMailTemplate($this->defaults);
|
$emailTemplate = new EMailTemplate($this->defaults);
|
||||||
|
|
||||||
$emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
|
$emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
|
||||||
|
$emailTemplate->addHeading('Welcome aboard John Doe');
|
||||||
$emailTemplate->addHeading('Welcome aboard');
|
|
||||||
$emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
|
$emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
|
||||||
$emailTemplate->addBodyText('Your username is: foo');
|
$emailTemplate->addBodyText('Your username is: foo');
|
||||||
|
|
||||||
|
|
||||||
$emailTemplate->addBodyButtonGroup(
|
$emailTemplate->addBodyButtonGroup(
|
||||||
'Go to Nextcloud', 'https://example.org/resetPassword/123',
|
'Set your password', 'https://example.org/resetPassword/123',
|
||||||
'Install Client', 'https://nextcloud.com/install/#install-clients'
|
'Install Client', 'https://nextcloud.com/install/#install-clients'
|
||||||
);
|
);
|
||||||
|
|
||||||
$emailTemplate->addFooter(
|
$emailTemplate->addFooter(
|
||||||
'https://example.org/img/logo-mail-footer.png',
|
'https://example.org/img/logo-mail-footer.png',
|
||||||
'TestCloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
|
'Nextcloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$message
|
$message
|
||||||
->expects($this->at(2))
|
->expects($this->at(2))
|
||||||
->method('setHtmlBody')
|
->method('setHtmlBody')
|
||||||
|
@ -2357,7 +2419,7 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
$message
|
$message
|
||||||
->expects($this->at(4))
|
->expects($this->at(4))
|
||||||
->method('setFrom')
|
->method('setFrom')
|
||||||
->with(['no-reply@owncloud.com' => null]);
|
->with(['no-reply@nextcloud.com' => 'Nextcloud']);
|
||||||
|
|
||||||
$this->mailer
|
$this->mailer
|
||||||
->expects($this->at(0))
|
->expects($this->at(0))
|
||||||
|
@ -2374,19 +2436,19 @@ class UsersControllerTest extends \Test\TestCase {
|
||||||
->with($message);
|
->with($message);
|
||||||
|
|
||||||
$expectedResponse = new DataResponse(
|
$expectedResponse = new DataResponse(
|
||||||
array(
|
[
|
||||||
'name' => 'foo',
|
'name' => 'foo',
|
||||||
'groups' => null,
|
'groups' => null,
|
||||||
'storageLocation' => '/home/user',
|
'storageLocation' => '/home/user',
|
||||||
'backend' => 'bar',
|
'backend' => 'bar',
|
||||||
'lastLogin' => null,
|
'lastLogin' => 0,
|
||||||
'displayname' => null,
|
'displayname' => 'John Doe',
|
||||||
'quota' => null,
|
'quota' => null,
|
||||||
'subadmin' => array(),
|
'subadmin' => array(),
|
||||||
'email' => null,
|
'email' => 'abc@example.org',
|
||||||
'isRestoreDisabled' => false,
|
'isRestoreDisabled' => false,
|
||||||
'isAvatarAvailable' => true,
|
'isAvatarAvailable' => true,
|
||||||
),
|
],
|
||||||
Http::STATUS_CREATED
|
Http::STATUS_CREATED
|
||||||
);
|
);
|
||||||
$response = $controller->create('foo', '', array(), 'abc@example.org');
|
$response = $controller->create('foo', '', array(), 'abc@example.org');
|
||||||
|
|
Loading…
Reference in New Issue