From 7df08fe12ef25bf3e5feba9aeb0cdface6411227 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 1 Nov 2019 18:12:38 +0100 Subject: [ticket/12559] Add functional test for limiting subforums in legend PHPBB3-12559 --- tests/functional/subforum_test.php | 113 +++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 tests/functional/subforum_test.php (limited to 'tests') diff --git a/tests/functional/subforum_test.php b/tests/functional/subforum_test.php new file mode 100644 index 0000000000..6686e347c5 --- /dev/null +++ b/tests/functional/subforum_test.php @@ -0,0 +1,113 @@ + + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +/** + * @group functional + */ +class phpbb_functional_subforum_test extends phpbb_functional_test_case +{ + public function test_setup_forums() + { + $this->login(); + $this->admin_login(); + + $forum_name = 'Subforum Test #1'; + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => $forum_name, + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + self::submit($form); + $forum_id = self::get_forum_id($forum_name); + + // 'Feeds #1.1' is a sub-forum of 'Feeds #1' + $forum_name = 'Subforum Test #1.1'; + $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => $forum_name, + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + self::submit($form); + $forum_id = self::get_forum_id('Subforum Test #1.1'); + + // 'Feeds #news' will be used for feed.php?mode=news + $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Subforum Test #1.1.1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + self::submit($form); + } + + /** + * @depends test_setup_forums + */ + public function test_display_subforums() + { + $crawler = self::request('GET', "index.php?sid={$this->sid}"); + $this->assertContains('Subforum Test #1.1', $crawler->html()); + $this->assertContains('Subforum Test #1.1.1', $crawler->html()); + } + + /** + * @depends test_display_subforums + */ + public function test_display_subforums_limit() + { + $this->login(); + $this->admin_login(); + + // Disable listing subforums + $forum_id = $this->get_forum_id('Subforum Test #1'); + $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=7&mode=manage&parent_id=0&f={$forum_id}&action=edit"); + $form = $crawler->selectButton('submit')->form([ + 'display_subforum_limit' => 1, + ]); + self::submit($form); + + $crawler = self::request('GET', "index.php?sid={$this->sid}"); + $this->assertContains('Subforum Test #1.1', $crawler->html()); + $this->assertNotContains('Subforum Test #1.1.1', $crawler->html()); + } + + protected function get_forum_id($forum_name) + { + $this->db = $this->get_db(); + $forum_id = 0; + + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . ' + WHERE ' . $this->db->sql_in_set('forum_name', $forum_name); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if ($row['forum_name'] == $forum_name) + { + $forum_id = (int) $row['forum_id']; + break; + } + } + $this->db->sql_freeresult($result); + + return $forum_id; + } +} -- cgit v1.2.1 From 85837d48b20c63f86050d0125942b25928deb1a5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 4 Nov 2019 17:31:18 +0100 Subject: [ticket/12559] Use short array syntax PHPBB3-12559 --- tests/functional/subforum_test.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/functional/subforum_test.php b/tests/functional/subforum_test.php index 6686e347c5..6ce4f53c20 100644 --- a/tests/functional/subforum_test.php +++ b/tests/functional/subforum_test.php @@ -23,38 +23,38 @@ class phpbb_functional_subforum_test extends phpbb_functional_test_case $forum_name = 'Subforum Test #1'; $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); - $form = $crawler->selectButton('addforum')->form(array( + $form = $crawler->selectButton('addforum')->form([ 'forum_name' => $forum_name, - )); + ]); $crawler = self::submit($form); - $form = $crawler->selectButton('update')->form(array( + $form = $crawler->selectButton('update')->form([ 'forum_perm_from' => 2, - )); + ]); self::submit($form); $forum_id = self::get_forum_id($forum_name); // 'Feeds #1.1' is a sub-forum of 'Feeds #1' $forum_name = 'Subforum Test #1.1'; $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}"); - $form = $crawler->selectButton('addforum')->form(array( + $form = $crawler->selectButton('addforum')->form([ 'forum_name' => $forum_name, - )); + ]); $crawler = self::submit($form); - $form = $crawler->selectButton('update')->form(array( + $form = $crawler->selectButton('update')->form([ 'forum_perm_from' => 2, - )); + ]); self::submit($form); $forum_id = self::get_forum_id('Subforum Test #1.1'); // 'Feeds #news' will be used for feed.php?mode=news $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}"); - $form = $crawler->selectButton('addforum')->form(array( + $form = $crawler->selectButton('addforum')->form([ 'forum_name' => 'Subforum Test #1.1.1', - )); + ]); $crawler = self::submit($form); - $form = $crawler->selectButton('update')->form(array( + $form = $crawler->selectButton('update')->form([ 'forum_perm_from' => 2, - )); + ]); self::submit($form); } -- cgit v1.2.1