Exemplo n.º 1
0
 /**
  * @dataProvider getTemplateData
  */
 public function testHooksDeleteUser($constructorActive, $forceActive)
 {
     $l = \OCP\Util::getL10N('activity');
     $navigation = new Navigation($l, \OC::$server->getActivityManager(), \OC::$server->getURLGenerator(), $constructorActive);
     $output = $navigation->getTemplate($forceActive)->fetchPage();
     // Get only the template part with the navigation links
     $navigationLinks = substr($output, strpos($output, '<li>') + 4);
     $navigationLinks = substr($navigationLinks, 0, strrpos($navigationLinks, '</li>'));
     // Remove tabs and new lines
     $navigationLinks = str_replace(array("\t", "\n"), '', $navigationLinks);
     // Turn the list of links into an array
     $navigationEntries = explode('</li><li>', $navigationLinks);
     $links = $navigation->getLinkList();
     // Check whether all top links are available
     foreach ($links['top'] as $link) {
         $found = false;
         foreach ($navigationEntries as $navigationEntry) {
             if (strpos($navigationEntry, 'data-navigation="' . $link['id'] . '"') !== false) {
                 $found = true;
                 $this->assertContains('href="' . $link['url'] . '">' . $link['name'] . '</a>', $navigationEntry);
                 if ($forceActive == $link['id']) {
                     $this->assertContains('class="active"', $navigationEntry);
                 } else {
                     if ($forceActive == null && $constructorActive == $link['id']) {
                         $this->assertContains('class="active"', $navigationEntry);
                     }
                 }
             }
         }
         $this->assertTrue($found, 'Could not find navigation entry "' . $link['name'] . '"');
     }
     // Check size of app links
     $this->assertSame(1, sizeof($links['apps']));
     $this->assertNotContains('data-navigation="files"', $navigationLinks, 'Files app should not be included when there are no other apps.');
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getTemplateData
  */
 public function testHooksDeleteUser($constructorActive, $forceActive, $matchTags, $notMatchTags)
 {
     $l = \OCP\Util::getL10N('activity');
     $navigation = new Navigation($l, $constructorActive);
     $output = $navigation->getTemplate($forceActive)->fetchPage();
     foreach ($matchTags as $matcher) {
         $this->assertTag($matcher, $output);
     }
     foreach ($notMatchTags as $matcher) {
         $this->assertNotTag($matcher, $output);
     }
 }
Exemplo n.º 3
0
 public function testShowList()
 {
     $template = new Template('activity', 'stream.app.navigation', '');
     $template->assign('activeNavigation', 'all');
     $template->assign('navigations', []);
     $template->assign('rssLink', '');
     $this->navigation->expects($this->any())->method('getTemplate')->willReturn($template);
     $avatar = $this->getMockBuilder('OCP\\IAvatar')->disableOriginalConstructor()->getMock();
     $this->avatarManager->expects($this->once())->method('getAvatar')->willReturn($avatar);
     $avatar->expects($this->once())->method('exists')->willReturn(false);
     $templateResponse = $this->controller->showList();
     $this->assertInstanceOf('\\OCP\\AppFramework\\Http\\TemplateResponse', $templateResponse, 'Asserting type of return is \\OCP\\AppFramework\\Http\\TemplateResponse');
     $renderedResponse = $templateResponse->render();
     $this->assertNotEmpty($renderedResponse);
 }
 /**
  * @dataProvider getTemplateData
  */
 public function testGetTemplate($constructorActive, $forceActive = null, $rssToken = '')
 {
     $activityLanguage = \OCP\Util::getL10N('activity', 'en');
     $activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
     $activityManager->registerExtension(function () use($activityLanguage) {
         return new Extension($activityLanguage, $this->getMock('\\OCP\\IURLGenerator'));
     });
     $userSettings = $this->getMockBuilder('OCA\\Activity\\UserSettings')->disableOriginalConstructor()->getMock();
     $userSettings->expects($this->exactly(2))->method('getUserSetting')->with('test', 'setting', 'self')->willReturn(true);
     $navigation = new Navigation($activityLanguage, $activityManager, \OC::$server->getURLGenerator(), $userSettings, 'test', $rssToken, $constructorActive);
     $output = $navigation->getTemplate($forceActive)->fetchPage();
     // Get only the template part with the navigation links
     $navigationLinks = substr($output, strpos($output, '<ul>') + 4);
     $navigationLinks = substr($navigationLinks, 0, strrpos($navigationLinks, '</li>'));
     // Remove tabs and new lines
     $navigationLinks = str_replace(array("\t", "\n"), '', $navigationLinks);
     // Turn the list of links into an array
     $navigationEntries = explode('</li>', $navigationLinks);
     $links = $navigation->getLinkList();
     // Check whether all top links are available
     foreach ($links['top'] as $link) {
         $found = false;
         foreach ($navigationEntries as $navigationEntry) {
             if (strpos($navigationEntry, 'data-navigation="' . $link['id'] . '"') !== false) {
                 $found = true;
                 $this->assertContains('href="' . $link['url'] . '">' . $link['name'] . '</a>', $navigationEntry);
                 if ($forceActive == $link['id'] || $forceActive == null && $constructorActive == $link['id']) {
                     $this->assertStringStartsWith('<li class="active">', $navigationEntry);
                 } else {
                     $this->assertStringStartsWith('<li>', $navigationEntry);
                 }
             }
         }
         $this->assertTrue($found, 'Could not find navigation entry "' . $link['name'] . '"');
     }
     // Check size of app links
     $this->assertSame(1, sizeof($links['apps']));
     $this->assertNotContains('data-navigation="files"', $navigationLinks, 'Files app should not be included when there are no other apps.');
     if ($rssToken) {
         $rssInputField = strpos($output, 'input id="rssurl"');
         $this->assertGreaterThan(0, $rssInputField);
         $endOfInputField = strpos($output, ' />', $rssInputField);
         $this->assertNotSame(false, strpos(substr($output, $rssInputField, $endOfInputField - $rssInputField), $rssToken));
     }
 }
Exemplo n.º 5
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @param string $filter
  * @return TemplateResponse
  */
 public function showList($filter = 'all')
 {
     $filter = $this->data->validateFilter($filter);
     return new TemplateResponse('activity', 'list', ['appNavigation' => $this->navigation->getTemplate($filter), 'filter' => $filter]);
 }
Exemplo n.º 6
0
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  *
  * @param string $filter
  * @return TemplateResponse
  */
 public function showList($filter = 'all')
 {
     $filter = $this->data->validateFilter($filter);
     return new TemplateResponse('activity', 'stream.body', ['appNavigation' => $this->navigation->getTemplate($filter), 'avatars' => $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no', 'filter' => $filter]);
 }