diff --git a/event/listener.php b/event/listener.php index c7ef1bbb..e31415e8 100644 --- a/event/listener.php +++ b/event/listener.php @@ -134,6 +134,6 @@ class listener implements EventSubscriberInterface */ protected function has_portal_access() { - return $this->auth->acl_get('u_view_portal') && $this->config['board3_portal_enable']; + return $this->auth->acl_get('u_view_portal') && $this->config['board3_enable']; } } diff --git a/tests/functional/portal_link_test.php b/tests/functional/portal_link_test.php new file mode 100644 index 00000000..d4c99509 --- /dev/null +++ b/tests/functional/portal_link_test.php @@ -0,0 +1,70 @@ +login(); + $this->admin_login(); + } + + public function test_portal_link() + { + $crawler = self::request('GET', 'index.php?sid=' . $this->sid); + $this->assertContains('Portal', $crawler->text()); + } + + public function test_disabled_portal_link() + { + // Disable portal + $crawler = self::request('GET', 'adm/index.php?i=-board3-portal-acp-portal_module&mode=config&sid=' . $this->sid); + $form = $crawler->selectButton('Submit')->form(); + $form->setValues(array( + 'config[board3_enable]' => 0, + )); + $crawler = self::submit($form); + + // Should be updated + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); + + // Look for portal link on index + $crawler = self::request('GET', 'index.php?sid=' . $this->sid); + $vals = $crawler->filter('#nav-breadcrumbs')->each(function (\Symfony\Component\DomCrawler\Crawler $node, $i) { + return $node->text(); + }); + foreach ($vals as $val) + { + $this->assertNotContains('Portal', $val); + } + + // Try to access portal directly + $crawler = self::request('GET', 'app.php/portal?sid=' . $this->sid); + $vals = $crawler->filter('#nav-breadcrumbs')->each(function (\Symfony\Component\DomCrawler\Crawler $node, $i) { + return $node->text(); + }); + foreach ($vals as $val) + { + $this->assertNotContains('Portal', $val); + } + + // Enable portal again + $crawler = self::request('GET', 'adm/index.php?i=-board3-portal-acp-portal_module&mode=config&sid=' . $this->sid); + $form = $crawler->selectButton('Submit')->form(); + $form->setValues(array( + 'config[board3_enable]' => 1, + )); + self::submit($form); + } +}