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

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-09-28 18:43:37 +0300
committerJoas Schilling <nickvergessen@owncloud.com>2015-09-28 18:43:37 +0300
commit68b3aa229c3c6ae85a02127312b054ce899bdc49 (patch)
tree4108c3b045cbd4f2e2ea8d21f964f0433b7f73c7 /tests
parentcad20cb1f63a0f730a1745f7bd867ec4b7dddae3 (diff)
Only add the JS and CSS when not on public pages
Diffstat (limited to 'tests')
-rw-r--r--tests/appinfo/AppTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/appinfo/AppTest.php b/tests/appinfo/AppTest.php
index a4ebe38..afae011 100644
--- a/tests/appinfo/AppTest.php
+++ b/tests/appinfo/AppTest.php
@@ -26,6 +26,8 @@ use OCA\Notifications\Tests\TestCase;
class AppTest extends TestCase {
/** @var \OC\Notification\IManager|\PHPUnit_Framework_MockObject_MockObject */
protected $manager;
+ /** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
+ protected $request;
protected function setUp() {
parent::setUp();
@@ -34,11 +36,17 @@ class AppTest extends TestCase {
->disableOriginalConstructor()
->getMock();
+ $this->request = $this->getMockBuilder('OCP\IRequest')
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->overwriteService('NotificationManager', $this->manager);
+ $this->overwriteService('Request', $this->request);
}
protected function tearDown() {
$this->restoreService('NotificationManager');
+ $this->restoreService('Request');
parent::tearDown();
}
@@ -54,4 +62,40 @@ class AppTest extends TestCase {
include(__DIR__ . '/../../appinfo/app.php');
}
+
+ public function dataLoadingJSAndCSS() {
+ return [
+ ['/index.php', '/apps/files', true],
+ ['/remote.php', '/webdav', false],
+ ['/index.php', '/s/1234567890123', false],
+ ];
+ }
+
+ /**
+ * @dataProvider dataLoadingJSAndCSS
+ * @param string $scriptName
+ * @param string $pathInfo
+ * @param bool $scriptsAdded
+ */
+ public function testLoadingJSAndCSS($scriptName, $pathInfo, $scriptsAdded) {
+ $this->request->expects($this->any())
+ ->method('getScriptName')
+ ->willReturn($scriptName);
+ $this->request->expects($this->any())
+ ->method('getPathInfo')
+ ->willReturn($pathInfo);
+
+ \OC_Util::$scripts = [];
+ \OC_Util::$styles = [];
+
+ include(__DIR__ . '/../../appinfo/app.php');
+
+ if ($scriptsAdded) {
+ $this->assertNotEmpty(\OC_Util::$scripts);
+ $this->assertNotEmpty(\OC_Util::$styles);
+ } else {
+ $this->assertEmpty(\OC_Util::$scripts);
+ $this->assertEmpty(\OC_Util::$styles);
+ }
+ }
}