diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/ClientFlowLoginControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Settings/Mailer/NewUserMailHelperTest.php | 8 | ||||
-rw-r--r-- | tests/data/emails/new-account-email-custom-text-alternative.txt | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email-custom.html | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email-custom.txt | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email-single-button.html | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email-single-button.txt | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email.html | 2 | ||||
-rw-r--r-- | tests/data/emails/new-account-email.txt | 2 | ||||
-rw-r--r-- | tests/lib/Files/Config/UserMountCacheTest.php | 4 | ||||
-rw-r--r-- | tests/lib/L10N/L10nTest.php | 5 | ||||
-rw-r--r-- | tests/lib/LoggerTest.php | 47 | ||||
-rw-r--r-- | tests/lib/Mail/EMailTemplateTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Support/CrashReport/RegistryTest.php | 68 |
14 files changed, 128 insertions, 28 deletions
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index 89253f13038..99388e2c441 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -295,7 +295,7 @@ class ClientFlowLoginControllerTest extends TestCase { 'clientIdentifier' => 'Identifier', 'oauthState' => 'MyOauthStateToken', ], - 'empty' + 'guest' ); $this->assertEquals($expected, $this->clientFlowLoginController->redirectPage('MyStateToken', 'Identifier')); } diff --git a/tests/Settings/Mailer/NewUserMailHelperTest.php b/tests/Settings/Mailer/NewUserMailHelperTest.php index 9fd90561127..f05a963e537 100644 --- a/tests/Settings/Mailer/NewUserMailHelperTest.php +++ b/tests/Settings/Mailer/NewUserMailHelperTest.php @@ -237,7 +237,7 @@ class NewUserMailHelperTest extends TestCase { <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"> <tr style="padding:0;text-align:left;vertical-align:top"> <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> - <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You now have an TestCloud account, you can add, protect, and share your data.</p> + <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Welcome to your TestCloud account, you can add, protect, and share your data.</p> </th> <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th> </tr> @@ -350,7 +350,7 @@ EOF; $expectedTextBody = <<<EOF Welcome aboard -You now have an TestCloud account, you can add, protect, and share your data. +Welcome to your TestCloud account, you can add, protect, and share your data. Your username is: john @@ -470,7 +470,7 @@ EOF; <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"> <tr style="padding:0;text-align:left;vertical-align:top"> <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> - <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You now have an TestCloud account, you can add, protect, and share your data.</p> + <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Welcome to your TestCloud account, you can add, protect, and share your data.</p> </th> <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th> </tr> @@ -583,7 +583,7 @@ EOF; $expectedTextBody = <<<EOF Welcome aboard John Doe -You now have an TestCloud account, you can add, protect, and share your data. +Welcome to your TestCloud account, you can add, protect, and share your data. Your username is: john diff --git a/tests/data/emails/new-account-email-custom-text-alternative.txt b/tests/data/emails/new-account-email-custom-text-alternative.txt index 52da8957ab3..f65744b20d9 100644 --- a/tests/data/emails/new-account-email-custom-text-alternative.txt +++ b/tests/data/emails/new-account-email-custom-text-alternative.txt @@ -1,6 +1,6 @@ Welcome aboard - text -You now have an Nextcloud account, you can add, protect, and share your data. - text +Welcome to your Nextcloud account, you can add, protect, and share your data. - text Your username is: abc diff --git a/tests/data/emails/new-account-email-custom.html b/tests/data/emails/new-account-email-custom.html index f5f3fbda21b..9d35a7f3515 100644 --- a/tests/data/emails/new-account-email-custom.html +++ b/tests/data/emails/new-account-email-custom.html @@ -76,7 +76,7 @@ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"> <tr style="padding:0;text-align:left;vertical-align:top"> <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> - <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You now have an Nextcloud account, you can add, protect, and share your data.</p> + <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Welcome to your Nextcloud account, you can add, protect, and share your data.</p> </th> <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th> </tr> diff --git a/tests/data/emails/new-account-email-custom.txt b/tests/data/emails/new-account-email-custom.txt index 41ac8de8f49..57c5202a744 100644 --- a/tests/data/emails/new-account-email-custom.txt +++ b/tests/data/emails/new-account-email-custom.txt @@ -1,6 +1,6 @@ Welcome aboard -You now have an Nextcloud account, you can add, protect, and share your data. +Welcome to your Nextcloud account, you can add, protect, and share your data. Your username is: abc diff --git a/tests/data/emails/new-account-email-single-button.html b/tests/data/emails/new-account-email-single-button.html index f3874144109..3746d5d2cbb 100644 --- a/tests/data/emails/new-account-email-single-button.html +++ b/tests/data/emails/new-account-email-single-button.html @@ -76,7 +76,7 @@ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"> <tr style="padding:0;text-align:left;vertical-align:top"> <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> - <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You now have an Nextcloud account, you can add, protect, and share your data.</p> + <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Welcome to your Nextcloud account, you can add, protect, and share your data.</p> </th> <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th> </tr> diff --git a/tests/data/emails/new-account-email-single-button.txt b/tests/data/emails/new-account-email-single-button.txt index f05f6136d16..0c9210f086a 100644 --- a/tests/data/emails/new-account-email-single-button.txt +++ b/tests/data/emails/new-account-email-single-button.txt @@ -1,6 +1,6 @@ Welcome aboard -You now have an Nextcloud account, you can add, protect, and share your data. +Welcome to your Nextcloud account, you can add, protect, and share your data. Your username is: abc diff --git a/tests/data/emails/new-account-email.html b/tests/data/emails/new-account-email.html index 72daf3ec5c8..d33cb540c38 100644 --- a/tests/data/emails/new-account-email.html +++ b/tests/data/emails/new-account-email.html @@ -76,7 +76,7 @@ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%"> <tr style="padding:0;text-align:left;vertical-align:top"> <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left"> - <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You now have an Nextcloud account, you can add, protect, and share your data.</p> + <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Welcome to your Nextcloud account, you can add, protect, and share your data.</p> </th> <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th> </tr> diff --git a/tests/data/emails/new-account-email.txt b/tests/data/emails/new-account-email.txt index 66d7dbc906a..89524134183 100644 --- a/tests/data/emails/new-account-email.txt +++ b/tests/data/emails/new-account-email.txt @@ -1,6 +1,6 @@ Welcome aboard -You now have an Nextcloud account, you can add, protect, and share your data. +Welcome to your Nextcloud account, you can add, protect, and share your data. Your username is: abc diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index a96b385fcbf..ddf40a2b5e5 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -380,6 +380,8 @@ class UserMountCacheTest extends TestCase { $this->assertEquals($user1, $cachedMounts[0]->getUser()); $this->assertEquals($rootId, $cachedMounts[0]->getRootId()); $this->assertEquals(2, $cachedMounts[0]->getStorageId()); + $this->assertEquals('foo/bar', $cachedMounts[0]->getInternalPath()); + $this->assertEquals('/foo/foo/bar', $cachedMounts[0]->getPath()); } public function testGetMountsForFileIdSubFolderMount() { @@ -412,6 +414,8 @@ class UserMountCacheTest extends TestCase { $this->assertEquals($folderId, $cachedMounts[0]->getRootId()); $this->assertEquals(2, $cachedMounts[0]->getStorageId()); $this->assertEquals('foo', $cachedMounts[0]->getRootInternalPath()); + $this->assertEquals('bar', $cachedMounts[0]->getInternalPath()); + $this->assertEquals('/bar', $cachedMounts[0]->getPath()); } public function testGetMountsForFileIdSubFolderMountOutside() { diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index 6d662efee23..703aa9e227c 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/tests/lib/L10N/L10nTest.php @@ -164,4 +164,9 @@ class L10nTest extends TestCase { $l = \OC::$server->getL10N('lib', 'de'); $this->assertEquals('de', $l->getLanguageCode()); } + + public function testWeekdayName() { + $l = \OC::$server->getL10N('lib', 'de'); + $this->assertEquals('Mo.', $l->l('weekdayName', new \DateTime('2017-11-6'), ['width' => 'abbreviated'])); + } } diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php index 3a30bbd1d3b..76f33849deb 100644 --- a/tests/lib/LoggerTest.php +++ b/tests/lib/LoggerTest.php @@ -11,21 +11,26 @@ namespace Test; use OC\Log; class LoggerTest extends TestCase { - /** - * @var \OCP\ILogger - */ + + /** @var \OC\SystemConfig|\PHPUnit_Framework_MockObject_MockObject */ + private $config; + + /** @var \OCP\Support\CrashReport\IRegistry|\PHPUnit_Framework_MockObject_MockObject */ + private $registry; + + /** @var \OCP\ILogger */ private $logger; + + /** @var array */ static private $logs = array(); protected function setUp() { parent::setUp(); self::$logs = array(); - $this->config = $this->getMockBuilder( - '\OC\SystemConfig') - ->disableOriginalConstructor() - ->getMock(); - $this->logger = new Log('Test\LoggerTest', $this->config); + $this->config = $this->createMock(\OC\SystemConfig::class); + $this->registry = $this->createMock(\OCP\Support\CrashReport\IRegistry::class); + $this->logger = new Log('Test\LoggerTest', $this->config, null, $this->registry); } public function testInterpolation() { @@ -83,6 +88,10 @@ class LoggerTest extends TestCase { */ public function testDetectlogin($user, $password) { $e = new \Exception('test'); + $this->registry->expects($this->once()) + ->method('delegateReport') + ->with($e); + $this->logger->logException($e); $logLines = $this->getLogs(); @@ -98,9 +107,13 @@ class LoggerTest extends TestCase { */ public function testDetectcheckPassword($user, $password) { $e = new \Exception('test'); + $this->registry->expects($this->once()) + ->method('delegateReport') + ->with($e); + $this->logger->logException($e); - $logLines = $this->getLogs(); + $logLines = $this->getLogs(); foreach($logLines as $logLine) { $this->assertNotContains($user, $logLine); $this->assertNotContains($password, $logLine); @@ -113,9 +126,13 @@ class LoggerTest extends TestCase { */ public function testDetectvalidateUserPass($user, $password) { $e = new \Exception('test'); + $this->registry->expects($this->once()) + ->method('delegateReport') + ->with($e); + $this->logger->logException($e); - $logLines = $this->getLogs(); + $logLines = $this->getLogs(); foreach($logLines as $logLine) { $this->assertNotContains($user, $logLine); $this->assertNotContains($password, $logLine); @@ -128,9 +145,13 @@ class LoggerTest extends TestCase { */ public function testDetecttryLogin($user, $password) { $e = new \Exception('test'); + $this->registry->expects($this->once()) + ->method('delegateReport') + ->with($e); + $this->logger->logException($e); - $logLines = $this->getLogs(); + $logLines = $this->getLogs(); foreach($logLines as $logLine) { $this->assertNotContains($user, $logLine); $this->assertNotContains($password, $logLine); @@ -145,14 +166,16 @@ class LoggerTest extends TestCase { $a = function($user, $password) { throw new \Exception('test'); }; + $this->registry->expects($this->once()) + ->method('delegateReport'); try { $a($user, $password); } catch (\Exception $e) { $this->logger->logException($e); } - $logLines = $this->getLogs(); + $logLines = $this->getLogs(); foreach($logLines as $logLine) { $log = explode('\n', $logLine); unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0 diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index fce214a82aa..339cd95defc 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -76,7 +76,7 @@ class EMailTemplateTest extends TestCase { $this->emailTemplate->addHeader(); $this->emailTemplate->addHeading('Welcome aboard'); - $this->emailTemplate->addBodyText('You now have an Nextcloud account, you can add, protect, and share your data.'); + $this->emailTemplate->addBodyText('Welcome to your Nextcloud account, you can add, protect, and share your data.'); $this->emailTemplate->addBodyText('Your username is: abc'); $this->emailTemplate->addBodyButtonGroup( 'Set your password', 'https://example.org/resetPassword/123', @@ -117,7 +117,7 @@ class EMailTemplateTest extends TestCase { $this->emailTemplate->addHeader(); $this->emailTemplate->addHeading('Welcome aboard'); - $this->emailTemplate->addBodyText('You now have an Nextcloud account, you can add, protect, and share your data.'); + $this->emailTemplate->addBodyText('Welcome to your Nextcloud account, you can add, protect, and share your data.'); $this->emailTemplate->addBodyText('Your username is: abc'); $this->emailTemplate->addBodyButtonGroup( 'Set your password', 'https://example.org/resetPassword/123', @@ -156,7 +156,7 @@ class EMailTemplateTest extends TestCase { $this->emailTemplate->addHeader(); $this->emailTemplate->addHeading('Welcome aboard'); - $this->emailTemplate->addBodyText('You now have an Nextcloud account, you can add, protect, and share your data.'); + $this->emailTemplate->addBodyText('Welcome to your Nextcloud account, you can add, protect, and share your data.'); $this->emailTemplate->addBodyText('Your username is: abc'); $this->emailTemplate->addBodyButton( 'Set your password', 'https://example.org/resetPassword/123', @@ -197,7 +197,7 @@ class EMailTemplateTest extends TestCase { $this->emailTemplate->addHeader(); $this->emailTemplate->addHeading('Welcome aboard', 'Welcome aboard - text'); - $this->emailTemplate->addBodyText('You now have an Nextcloud account, you can add, protect, and share your data.', 'You now have an Nextcloud account, you can add, protect, and share your data. - text'); + $this->emailTemplate->addBodyText('Welcome to your Nextcloud account, you can add, protect, and share your data.', 'Welcome to your Nextcloud account, you can add, protect, and share your data. - text'); $this->emailTemplate->addBodyText('Your username is: abc'); $this->emailTemplate->addBodyButtonGroup( 'Set your password', 'https://example.org/resetPassword/123', diff --git a/tests/lib/Support/CrashReport/RegistryTest.php b/tests/lib/Support/CrashReport/RegistryTest.php new file mode 100644 index 00000000000..b73bf2737ee --- /dev/null +++ b/tests/lib/Support/CrashReport/RegistryTest.php @@ -0,0 +1,68 @@ +<?php + +/** + * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace Test\Support\CrashReport; + +use Exception; +use OC\Support\CrashReport\Registry; +use OCP\Support\CrashReport\IReporter; +use Test\TestCase; + +class RegistryTest extends TestCase { + + /** @var Registry */ + private $registry; + + protected function setUp() { + parent::setUp(); + + $this->registry = new Registry(); + } + + /** + * Doesn't assert anything, just checks whether anything "explodes" + */ + public function testDelegateToNone() { + $exception = new Exception('test'); + + $this->registry->delegateReport($exception); + } + + public function testDelegateToAll() { + $reporter1 = $this->createMock(IReporter::class); + $reporter2 = $this->createMock(IReporter::class); + $exception = new Exception('test'); + $reporter1->expects($this->once()) + ->method('report') + ->with($exception); + $reporter2->expects($this->once()) + ->method('report') + ->with($exception); + + $this->registry->register($reporter1); + $this->registry->register($reporter2); + $this->registry->delegateReport($exception); + } + +} |