From 280619eea9585924a44611f001f266d354036d0a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 1 Oct 2012 17:13:15 +0200 Subject: [feature/soft-delete] Add unit tests for get_visibility_sql() PHPBB3-9657 --- .../fixtures/get_visibility_sql.xml | 55 ++++++++ .../content_visibility/get_visibility_sql_test.php | 141 +++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 tests/content_visibility/fixtures/get_visibility_sql.xml create mode 100644 tests/content_visibility/get_visibility_sql_test.php (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/get_visibility_sql.xml b/tests/content_visibility/fixtures/get_visibility_sql.xml new file mode 100644 index 0000000000..146244263e --- /dev/null +++ b/tests/content_visibility/fixtures/get_visibility_sql.xml @@ -0,0 +1,55 @@ + + + + topic_id + forum_id + topic_visibility + topic_title + + 1 + 1 + 0 + Unapproved + + + 2 + 1 + 1 + Approved + + + 3 + 1 + 2 + Softdeleted + +
+ + post_id + topic_id + forum_id + post_visibility + post_text + + 1 + 1 + 1 + 0 + Unapproved + + + 2 + 2 + 1 + 1 + Approved + + + 3 + 3 + 1 + 2 + Softdeleted + +
+
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php new file mode 100644 index 0000000000..415a33d17f --- /dev/null +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -0,0 +1,141 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/get_visibility_sql.xml'); + } + + public function get_visibility_sql_data() + { + return array( + array( + 'phpbb_posts', + 'post', 1, '', + array( + array('m_approve', 1, true), + array('m_restore', 1, true), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + array('post_id' => 3), + ), + ), + array( + 'phpbb_posts', + 'post', 1, '', + array( + array('m_approve', 1, true), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + ), + ), + array( + 'phpbb_posts', + 'post', 1, '', + array( + array('m_restore', 1, true), + ), + array( + array('post_id' => 2), + array('post_id' => 3), + ), + ), + array( + 'phpbb_posts', + 'post', 1, '', + array( + ), + array( + array('post_id' => 2), + ), + ), + array( + 'phpbb_topics', + 'topic', 1, '', + array( + array('m_approve', 1, true), + array('m_restore', 1, true), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + array('topic_id' => 3), + ), + ), + array( + 'phpbb_topics', + 'topic', 1, '', + array( + array('m_approve', 1, true), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + ), + ), + array( + 'phpbb_topics', + 'topic', 1, '', + array( + array('m_restore', 1, true), + ), + array( + array('topic_id' => 2), + array('topic_id' => 3), + ), + ), + array( + 'phpbb_topics', + 'topic', 1, '', + array(), + array( + array('topic_id' => 2), + ), + ), + ); + } + + /** + * @dataProvider get_visibility_sql_data + */ + public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) + { + global $db, $auth; + + $db = $this->new_dbal(); + + // Create auth mock + $auth = $this->getMock('phpbb_auth'); + $acl_get_map = array( + array('f_read', 23, true), + array('m_', 23, true), + ); + + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap($permissions)); + + $result = $db->sql_query('SELECT ' . $mode . '_id + FROM ' . $table . ' + WHERE ' . phpbb_content_visibility::get_visibility_sql($mode, $forum_id, $table_alias) . ' + ORDER BY ' . $mode . '_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} -- cgit v1.2.1 From 4a65940e6206aef6b85a0aacfb5324ecabf76e12 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 1 Oct 2012 22:14:04 +0200 Subject: [feature/soft-delete] Add unit tests for get_forums_visibility_sql() PHPBB3-9657 --- .../fixtures/get_forums_visibility_sql.xml | 133 ++++++++++++++++++ .../get_forums_visibility_sql_test.php | 149 +++++++++++++++++++++ .../content_visibility/get_visibility_sql_test.php | 5 - 3 files changed, 282 insertions(+), 5 deletions(-) create mode 100644 tests/content_visibility/fixtures/get_forums_visibility_sql.xml create mode 100644 tests/content_visibility/get_forums_visibility_sql_test.php (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/get_forums_visibility_sql.xml b/tests/content_visibility/fixtures/get_forums_visibility_sql.xml new file mode 100644 index 0000000000..658d34398f --- /dev/null +++ b/tests/content_visibility/fixtures/get_forums_visibility_sql.xml @@ -0,0 +1,133 @@ + + + + topic_id + forum_id + topic_visibility + topic_title + + 1 + 1 + 0 + Unapproved + + + 2 + 1 + 1 + Approved + + + 3 + 1 + 2 + Softdeleted + + + 4 + 2 + 0 + Unapproved + + + 5 + 2 + 1 + Approved + + + 6 + 2 + 2 + Softdeleted + + + 7 + 3 + 0 + Unapproved + + + 8 + 3 + 1 + Approved + + + 9 + 3 + 2 + Softdeleted + +
+ + post_id + topic_id + forum_id + post_visibility + post_text + + 1 + 1 + 1 + 0 + Unapproved + + + 2 + 2 + 1 + 1 + Approved + + + 3 + 3 + 1 + 2 + Softdeleted + + + 4 + 4 + 2 + 0 + Unapproved + + + 5 + 5 + 2 + 1 + Approved + + + 6 + 6 + 2 + 2 + Softdeleted + + + 7 + 7 + 3 + 0 + Unapproved + + + 8 + 8 + 3 + 1 + Approved + + + 9 + 9 + 3 + 2 + Softdeleted + +
+
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php new file mode 100644 index 0000000000..62e1c8187d --- /dev/null +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -0,0 +1,149 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/get_forums_visibility_sql.xml'); + } + + public function get_forums_visibility_sql_data() + { + return array( + array( + 'phpbb_topics', + 'topic', array(1, 2, 3), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 6), + array('topic_id' => 7), + array('topic_id' => 8), + array('topic_id' => 9), + ), + ), + array( + 'phpbb_topics', + 'topic', array(1, 2), '', + array( + array('m_approve', true, array(1 => true, 2 => true)), + array('m_restore', true, array(1 => true, 2 => true)), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 6), + ), + ), + array( + 'phpbb_topics', + 'topic', array(1, 2, 3), '', + array( + array('m_approve', true, array(2 => true)), + array('m_restore', true, array(1 => true)), + ), + array( + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 8), + ), + ), + array( + 'phpbb_posts', + 'post', array(1, 2, 3), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 6), + array('post_id' => 7), + array('post_id' => 8), + array('post_id' => 9), + ), + ), + array( + 'phpbb_posts', + 'post', array(1, 2), '', + array( + array('m_approve', true, array(1 => true, 2 => true)), + array('m_restore', true, array(1 => true, 2 => true)), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 6), + ), + ), + array( + 'phpbb_posts', + 'post', array(1, 2, 3), '', + array( + array('m_approve', true, array(2 => true)), + array('m_restore', true, array(1 => true)), + ), + array( + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 8), + ), + ), + ); + } + + /** + * @dataProvider get_forums_visibility_sql_data + */ + public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) + { + global $db, $auth; + + $db = $this->new_dbal(); + + // Create auth mock + $auth = $this->getMock('phpbb_auth'); + $auth->expects($this->any()) + ->method('acl_getf') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap($permissions)); + + $result = $db->sql_query('SELECT ' . $mode . '_id + FROM ' . $table . ' + WHERE ' . phpbb_content_visibility::get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' + ORDER BY ' . $mode . '_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 415a33d17f..55396aaba5 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -121,11 +121,6 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te // Create auth mock $auth = $this->getMock('phpbb_auth'); - $acl_get_map = array( - array('f_read', 23, true), - array('m_', 23, true), - ); - $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) -- cgit v1.2.1 From b629b2cd95a9da67376f7a628c15199007e2ebd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 1 Oct 2012 22:44:39 +0200 Subject: [feature/soft-delete] Add unit tests for get_global_visibility_sql() PHPBB3-9657 --- .../get_forums_visibility_sql_test.php | 8 +- .../get_global_visibility_sql_test.php | 149 +++++++++++++++++++++ 2 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 tests/content_visibility/get_global_visibility_sql_test.php (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 62e1c8187d..fe5ba746e3 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -43,8 +43,8 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'phpbb_topics', 'topic', array(1, 2), '', array( - array('m_approve', true, array(1 => true, 2 => true)), - array('m_restore', true, array(1 => true, 2 => true)), + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('topic_id' => 1), @@ -93,8 +93,8 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'phpbb_posts', 'post', array(1, 2), '', array( - array('m_approve', true, array(1 => true, 2 => true)), - array('m_restore', true, array(1 => true, 2 => true)), + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('post_id' => 1), diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php new file mode 100644 index 0000000000..149ee9e330 --- /dev/null +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -0,0 +1,149 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/get_forums_visibility_sql.xml'); + } + + public function get_global_visibility_sql_data() + { + return array( + array( + 'phpbb_topics', + 'topic', array(), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 6), + array('topic_id' => 7), + array('topic_id' => 8), + array('topic_id' => 9), + ), + ), + array( + 'phpbb_topics', + 'topic', array(3), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('topic_id' => 1), + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 6), + ), + ), + array( + 'phpbb_topics', + 'topic', array(), '', + array( + array('m_approve', true, array(2 => true)), + array('m_restore', true, array(1 => true)), + ), + array( + array('topic_id' => 2), + array('topic_id' => 3), + array('topic_id' => 4), + array('topic_id' => 5), + array('topic_id' => 8), + ), + ), + array( + 'phpbb_posts', + 'post', array(), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 6), + array('post_id' => 7), + array('post_id' => 8), + array('post_id' => 9), + ), + ), + array( + 'phpbb_posts', + 'post', array(3), '', + array( + array('m_approve', true, array(1 => true, 2 => true, 3 => true)), + array('m_restore', true, array(1 => true, 2 => true, 3 => true)), + ), + array( + array('post_id' => 1), + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 6), + ), + ), + array( + 'phpbb_posts', + 'post', array(), '', + array( + array('m_approve', true, array(2 => true)), + array('m_restore', true, array(1 => true)), + ), + array( + array('post_id' => 2), + array('post_id' => 3), + array('post_id' => 4), + array('post_id' => 5), + array('post_id' => 8), + ), + ), + ); + } + + /** + * @dataProvider get_global_visibility_sql_data + */ + public function test_get_global_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) + { + global $db, $auth; + + $db = $this->new_dbal(); + + // Create auth mock + $auth = $this->getMock('phpbb_auth'); + $auth->expects($this->any()) + ->method('acl_getf') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap($permissions)); + + $result = $db->sql_query('SELECT ' . $mode . '_id + FROM ' . $table . ' + WHERE ' . phpbb_content_visibility::get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' + ORDER BY ' . $mode . '_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } +} -- cgit v1.2.1 From c36c69c1d4f14d36bdba488f91c75016c52b9922 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 2 Oct 2012 12:54:47 +0200 Subject: [feature/soft-delete] Remove unneeded require_once() PHPBB3-9657 --- tests/content_visibility/get_forums_visibility_sql_test.php | 3 --- tests/content_visibility/get_global_visibility_sql_test.php | 3 --- tests/content_visibility/get_visibility_sql_test.php | 3 --- 3 files changed, 9 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index fe5ba746e3..6960e43687 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -7,9 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 149ee9e330..ac8b4225cd 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -7,9 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_database_test_case { public function getDataSet() diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 55396aaba5..16a38e5f46 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -7,9 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; - class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_test_case { public function getDataSet() -- cgit v1.2.1 From 1f8f07b9988b6c4aa83b517cfba6ff73a30e3ea3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 2 Oct 2012 15:32:12 +0200 Subject: [feature/soft-delete] Add unit tests for simple cases of set_post_visibility These tests require at least one remaining post. PHPBB3-9657 --- .../fixtures/set_post_visibility.xml | 133 +++++++++++++++++++++ .../set_post_visibility_test.php | 113 +++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 tests/content_visibility/fixtures/set_post_visibility.xml create mode 100644 tests/content_visibility/set_post_visibility_test.php (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml new file mode 100644 index 0000000000..3859d17955 --- /dev/null +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -0,0 +1,133 @@ + + + + topic_id + forum_id + topic_visibility + topic_title + topic_first_post_id + topic_last_post_id + + 1 + 1 + 1 + Approved + 2 + 2 + + + + 2 + 1 + 1 + 2 Approved posts + 5 + 6 + +
+ + post_id + poster_id + topic_id + forum_id + post_visibility + post_text + + 1 + 1 + 1 + 1 + 0 + Unapproved + + + 2 + 2 + 1 + 1 + 1 + Approved + + + 3 + 3 + 1 + 1 + 2 + Softdeleted + + + + 4 + 1 + 2 + 1 + 0 + Unapproved + + + 5 + 2 + 2 + 1 + 1 + Approved + + + 6 + 2 + 2 + 1 + 1 + Approved 2 + + + 7 + 3 + 2 + 1 + 2 + Softdeleted + +
+ + user_id + user_posts + username + username_clean + user_permissions + user_sig + user_occ + user_interests + + 1 + 1 + user 1 + user 1 + + + + + + + 2 + 1 + user 2 + user 2 + + + + + + + 3 + 1 + user 3 + user 3 + + + + + +
+
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php new file mode 100644 index 0000000000..1f760859ee --- /dev/null +++ b/tests/content_visibility/set_post_visibility_test.php @@ -0,0 +1,113 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/set_post_visibility.xml'); + } + + public function set_post_visibility_data() + { + return array( + array( + ITEM_APPROVED, + 1, 1, 1, + 2, time(), 'approve', + true, false, + array( + array('post_id' => 1, 'post_visibility' => 1, 'post_delete_reason' => 'approve'), + array('post_id' => 2, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), + ), + array( + array('topic_first_post_id' => '1', 'topic_last_post_id' => '2'), + ), + ), + array( + ITEM_APPROVED, + 3, 1, 1, + 2, time(), 'approve', + false, true, + array( + array('post_id' => 1, 'post_visibility' => 0, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'), + ), + array( + array('topic_first_post_id' => '2', 'topic_last_post_id' => '3'), + ), + ), + array( + ITEM_DELETED, + 5, 2, 1, + 2, time(), 'deleted', + true, false, + array( + array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''), + array('post_id' => 5, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), + array('post_id' => 6, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), + ), + array( + array('topic_first_post_id' => '6', 'topic_last_post_id' => '6'), + ), + ), + array( + ITEM_DELETED, + 6, 2, 1, + 2, time(), 'deleted', + false, true, + array( + array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''), + array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), + array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), + ), + array( + array('topic_first_post_id' => '5', 'topic_last_post_id' => '5'), + ), + ), + ); + } + + /** + * @dataProvider set_post_visibility_data + */ + public function test_set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected, $expected_topic) + { + global $db; + + $db = $this->new_dbal(); + + phpbb_content_visibility::set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + + $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason + FROM phpbb_posts + WHERE topic_id = ' . $topic_id . ' + ORDER BY post_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + + $result = $db->sql_query('SELECT topic_first_post_id, topic_last_post_id + FROM phpbb_topics + WHERE topic_id = ' . $topic_id); + + $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + } +} -- cgit v1.2.1 From b8642d7c8ab7769b8b692409fb6627a4196c93b0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 11:04:56 +0200 Subject: [feature/soft-delete] Test topic visibility as well PHPBB3-9657 --- tests/content_visibility/set_post_visibility_test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 1f760859ee..c488c648bc 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -34,7 +34,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_first_post_id' => '1', 'topic_last_post_id' => '2'), + array('topic_visibility' => 1, 'topic_first_post_id' => '1', 'topic_last_post_id' => '2'), ), ), array( @@ -48,7 +48,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'), ), array( - array('topic_first_post_id' => '2', 'topic_last_post_id' => '3'), + array('topic_visibility' => 1, 'topic_first_post_id' => '2', 'topic_last_post_id' => '3'), ), ), array( @@ -63,7 +63,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_first_post_id' => '6', 'topic_last_post_id' => '6'), + array('topic_visibility' => 1, 'topic_first_post_id' => '6', 'topic_last_post_id' => '6'), ), ), array( @@ -73,12 +73,12 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t false, true, array( array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''), - array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => 'deleted'), array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_first_post_id' => '5', 'topic_last_post_id' => '5'), + array('topic_visibility' => 1, 'topic_first_post_id' => '5', 'topic_last_post_id' => '5'), ), ), ); @@ -103,7 +103,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $this->assertEquals($expected, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT topic_first_post_id, topic_last_post_id + $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id FROM phpbb_topics WHERE topic_id = ' . $topic_id); -- cgit v1.2.1 From 959525cebe5ea921268a9ab1b62ebc19df9dca9b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 12:05:22 +0200 Subject: [feature/soft-delete] Merge functionality of m_approve and m_restore The problems with having two different permissions are just too big and cause huge queries, if they are granted differently. Also it's quite hard to decide what should happen when a moderator has only one permission and the topic has only posts of the two hidden types. To avoid all this, we merge them so it's a simple switch: either the user is a moderator, then he can see all posts, or he is not, then he can only see approved ones. PHPBB3-9567 --- .../get_forums_visibility_sql_test.php | 10 +---- .../get_global_visibility_sql_test.php | 10 +---- .../content_visibility/get_visibility_sql_test.php | 46 ---------------------- 3 files changed, 4 insertions(+), 62 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 6960e43687..840f247b14 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -22,7 +22,6 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'topic', array(1, 2, 3), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('topic_id' => 1), @@ -41,7 +40,6 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'topic', array(1, 2), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('topic_id' => 1), @@ -57,13 +55,12 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'topic', array(1, 2, 3), '', array( array('m_approve', true, array(2 => true)), - array('m_restore', true, array(1 => true)), ), array( array('topic_id' => 2), - array('topic_id' => 3), array('topic_id' => 4), array('topic_id' => 5), + array('topic_id' => 6), array('topic_id' => 8), ), ), @@ -72,7 +69,6 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'post', array(1, 2, 3), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('post_id' => 1), @@ -91,7 +87,6 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'post', array(1, 2), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('post_id' => 1), @@ -107,13 +102,12 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data 'post', array(1, 2, 3), '', array( array('m_approve', true, array(2 => true)), - array('m_restore', true, array(1 => true)), ), array( array('post_id' => 2), - array('post_id' => 3), array('post_id' => 4), array('post_id' => 5), + array('post_id' => 6), array('post_id' => 8), ), ), diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index ac8b4225cd..8b96b3954d 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -22,7 +22,6 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'topic', array(), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('topic_id' => 1), @@ -41,7 +40,6 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'topic', array(3), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('topic_id' => 1), @@ -57,13 +55,12 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'topic', array(), '', array( array('m_approve', true, array(2 => true)), - array('m_restore', true, array(1 => true)), ), array( array('topic_id' => 2), - array('topic_id' => 3), array('topic_id' => 4), array('topic_id' => 5), + array('topic_id' => 6), array('topic_id' => 8), ), ), @@ -72,7 +69,6 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'post', array(), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('post_id' => 1), @@ -91,7 +87,6 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'post', array(3), '', array( array('m_approve', true, array(1 => true, 2 => true, 3 => true)), - array('m_restore', true, array(1 => true, 2 => true, 3 => true)), ), array( array('post_id' => 1), @@ -107,13 +102,12 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data 'post', array(), '', array( array('m_approve', true, array(2 => true)), - array('m_restore', true, array(1 => true)), ), array( array('post_id' => 2), - array('post_id' => 3), array('post_id' => 4), array('post_id' => 5), + array('post_id' => 6), array('post_id' => 8), ), ), diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 16a38e5f46..3c837b2837 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -22,7 +22,6 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te 'post', 1, '', array( array('m_approve', 1, true), - array('m_restore', 1, true), ), array( array('post_id' => 1), @@ -30,28 +29,6 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te array('post_id' => 3), ), ), - array( - 'phpbb_posts', - 'post', 1, '', - array( - array('m_approve', 1, true), - ), - array( - array('post_id' => 1), - array('post_id' => 2), - ), - ), - array( - 'phpbb_posts', - 'post', 1, '', - array( - array('m_restore', 1, true), - ), - array( - array('post_id' => 2), - array('post_id' => 3), - ), - ), array( 'phpbb_posts', 'post', 1, '', @@ -66,7 +43,6 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te 'topic', 1, '', array( array('m_approve', 1, true), - array('m_restore', 1, true), ), array( array('topic_id' => 1), @@ -74,28 +50,6 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te array('topic_id' => 3), ), ), - array( - 'phpbb_topics', - 'topic', 1, '', - array( - array('m_approve', 1, true), - ), - array( - array('topic_id' => 1), - array('topic_id' => 2), - ), - ), - array( - 'phpbb_topics', - 'topic', 1, '', - array( - array('m_restore', 1, true), - ), - array( - array('topic_id' => 2), - array('topic_id' => 3), - ), - ), array( 'phpbb_topics', 'topic', 1, '', -- cgit v1.2.1 From 63d11c976b0bcef68ce4809c8c76124451df88ea Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 12:37:01 +0200 Subject: [feature/soft-delete] Fix sync('topic') to match the new logic This also fixes set_post_visibility() PHPBB3-9567 --- .../fixtures/set_post_visibility.xml | 17 ++++++++ .../set_post_visibility_test.php | 48 +++++++++++++++++++--- 2 files changed, 60 insertions(+), 5 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 3859d17955..6fec5c5ad1 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -24,6 +24,15 @@ 5 6 + + + 3 + 1 + 1 + Only 1 Approved posts + 8 + 8 + post_id @@ -89,6 +98,14 @@ 2Softdeleted + + 8 + 1 + 3 + 1 + 1 + Approved +
user_id diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index c488c648bc..0fc2f349c0 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -34,7 +34,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_visibility' => 1, 'topic_first_post_id' => '1', 'topic_last_post_id' => '2'), + array('topic_visibility' => 1, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2), ), ), array( @@ -48,7 +48,21 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'), ), array( - array('topic_visibility' => 1, 'topic_first_post_id' => '2', 'topic_last_post_id' => '3'), + array('topic_visibility' => 1, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3), + ), + ), + array( + ITEM_DELETED, + 2, 1, 1, + 2, time(), 'deleted', + true, true, + array( + array('post_id' => 1, 'post_visibility' => 0, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), + array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), + ), + array( + array('topic_visibility' => 0, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3), ), ), array( @@ -63,7 +77,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_visibility' => 1, 'topic_first_post_id' => '6', 'topic_last_post_id' => '6'), + array('topic_visibility' => 1, 'topic_first_post_id' => 6, 'topic_last_post_id' => 6), ), ), array( @@ -73,12 +87,36 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t false, true, array( array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''), - array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => 'deleted'), + array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''), array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_visibility' => 1, 'topic_first_post_id' => '5', 'topic_last_post_id' => '5'), + array('topic_visibility' => 1, 'topic_first_post_id' => 5, 'topic_last_post_id' => 5), + ), + ), + array( + ITEM_DELETED, + 8, 3, 1, + 2, time(), 'deleted', + true, true, + array( + array('post_id' => 8, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'), + ), + array( + array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8), + ), + ), + array( + ITEM_UNAPPROVED, + 8, 3, 1, + 2, time(), 'unapproved', + true, true, + array( + array('post_id' => 8, 'post_visibility' => 0, 'post_delete_reason' => 'unapproved'), + ), + array( + array('topic_visibility' => 0, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8), ), ), ); -- cgit v1.2.1 From bfa6a50a4ff2caf1589a1039c1037d4153223d63 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 13:12:36 +0200 Subject: [feature/soft-delete] Extend functionality for updating a hole topic Limit the posts to a certain visibility and deletion time This allows us to only restore posts, that were approved when the topic got soft deleted. So previous soft deleted and unapproved posts are still soft deleted/unapproved PHPBB3-9567 --- tests/content_visibility/set_post_visibility_test.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 0fc2f349c0..42459c515a 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -107,18 +107,6 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8), ), ), - array( - ITEM_UNAPPROVED, - 8, 3, 1, - 2, time(), 'unapproved', - true, true, - array( - array('post_id' => 8, 'post_visibility' => 0, 'post_delete_reason' => 'unapproved'), - ), - array( - array('topic_visibility' => 0, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8), - ), - ), ); } -- cgit v1.2.1 From b9d363f6ccd53244b3dd47dd4f42b650797b5157 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 14:26:09 +0200 Subject: [feature/soft-delete] Add unit tests for set_topic_visibility() PHPBB3-9567 --- .../fixtures/set_topic_visibility.xml | 136 +++++++++++++++++++++ .../set_topic_visibility_test.php | 103 ++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 tests/content_visibility/fixtures/set_topic_visibility.xml create mode 100644 tests/content_visibility/set_topic_visibility_test.php (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml new file mode 100644 index 0000000000..e950977575 --- /dev/null +++ b/tests/content_visibility/fixtures/set_topic_visibility.xml @@ -0,0 +1,136 @@ + + +
+ topic_id + forum_id + topic_visibility + topic_title + topic_first_post_id + topic_last_post_id + topic_delete_user + topic_delete_time + topic_delete_reason + + + 1 + 1 + 1 + Approved + 1 + 1 + 0 + 0 + + + + + 2 + 1 + 2 + Soft deleted + 4 + 5 + 2 + 123 + + +
+ + post_id + poster_id + topic_id + forum_id + post_visibility + post_text + post_delete_user + post_delete_time + post_delete_reason + + 1 + 1 + 1 + 1 + 1 + Approved + 2 + + + + + 2 + 1 + 1 + 1 + 2 + Soft deleted + 2 + 123 + manually + + + 3 + 1 + 1 + 1 + 0 + Unapproved + 0 + 0 + + + + + 4 + 1 + 2 + 1 + 2 + Soft deleted by topic soft delete + 2 + 123 + + + + 5 + 1 + 2 + 1 + 2 + Soft deleted before the topic was soft deleted + 2 + 120 + manually + + + 6 + 1 + 2 + 1 + 0 + Unapproved before the topic was soft deleted + + + + +
+ + user_id + user_posts + username + username_clean + user_permissions + user_sig + user_occ + user_interests + + 1 + 1 + user 1 + user 1 + + + + + +
+ diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php new file mode 100644 index 0000000000..a1aedc6a5b --- /dev/null +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -0,0 +1,103 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/set_topic_visibility.xml'); + } + + public function set_topic_visibility_data() + { + return array( + array( + ITEM_DELETED, 1, 1, + 2, time(), 'delete', false, + array( + array('post_id' => 1, 'post_visibility' => 2, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => 'manually'), + array('post_id' => 3, 'post_visibility' => 0, 'post_delete_reason' => ''), + ), + array( + array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, 'topic_delete_reason' => 'delete'), + ), + ), + array( + ITEM_DELETED, 1, 1, + 2, time(), 'delete-forced', true, + array( + array('post_id' => 1, 'post_visibility' => 2, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), + ), + array( + array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, 'topic_delete_reason' => 'delete-forced'), + ), + ), + array( + ITEM_APPROVED, 2, 1, + 2, time(), 'approved', false, + array( + array('post_id' => 4, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 5, 'post_visibility' => 2, 'post_delete_reason' => 'manually'), + array('post_id' => 6, 'post_visibility' => 0, 'post_delete_reason' => ''), + ), + array( + array('topic_visibility' => 1, 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, 'topic_delete_reason' => 'approved'), + ), + ), + array( + ITEM_APPROVED, 2, 1, + 2, time(), 'approved-forced', true, + array( + array('post_id' => 4, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''), + array('post_id' => 6, 'post_visibility' => 1, 'post_delete_reason' => ''), + ), + array( + array('topic_visibility' => 1, 'topic_first_post_id' => 4, 'topic_last_post_id' => 6, 'topic_delete_reason' => 'approved-forced'), + ), + ), + ); + } + + /** + * @dataProvider set_topic_visibility_data + */ + public function test_set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all, $expected_posts, $expected_topic) + { + global $db; + + $db = $this->new_dbal(); + + phpbb_content_visibility::set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); + + $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason + FROM phpbb_posts + WHERE topic_id = ' . $topic_id . ' + ORDER BY post_id ASC'); + + $this->assertEquals($expected_posts, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + + $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_delete_reason + FROM phpbb_topics + WHERE topic_id = ' . $topic_id); + + $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + } +} -- cgit v1.2.1 From 7c09b5b89c43db86b08272b51d634f5b5264d332 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Oct 2012 16:31:05 +0200 Subject: [feature/soft-delete] Add some unit tests for delete_post() PHPBB3-9567 --- tests/content_visibility/delete_post_test.php | 236 ++++++++++++++++++++++ tests/content_visibility/fixtures/delete_post.xml | 117 +++++++++++ 2 files changed, 353 insertions(+) create mode 100644 tests/content_visibility/delete_post_test.php create mode 100644 tests/content_visibility/fixtures/delete_post.xml (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php new file mode 100644 index 0000000000..c1efdb5d49 --- /dev/null +++ b/tests/content_visibility/delete_post_test.php @@ -0,0 +1,236 @@ +createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_post.xml'); + } + + public function delete_post_data() + { + $info_data = array( + 'topic_first_post_id' => 1, + 'topic_last_post_id' => 3, + 'topic_replies_real' => 3, + 'topic_visibility' => ITEM_APPROVED, + 'post_time' => 2, + 'post_visibility' => ITEM_APPROVED, + 'post_postcount' => true, + 'poster_id' => 1, + 'post_reported' => false, + ); + + return array( + array( + 1, 1, 2, + array_merge($info_data, array( + 'post_time' => 2, + )), + false, 'harddelete', + array( + array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + //array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 1, + 'topic_last_post_id' => 3, + 'topic_replies' => 1, + 'topic_replies_real' => 1, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + ), + ), + array( + 1, 1, 1, + array_merge($info_data, array( + 'post_time' => 1, + )), + false, 'harddelete', + array( + //array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 2, + 'topic_last_post_id' => 3, + 'topic_replies' => 1, + 'topic_replies_real' => 1, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + ), + ), + array( + 1, 1, 3, + array_merge($info_data, array( + 'post_time' => 3, + )), + false, 'harddelete', + array( + array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + //array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 1, + 'topic_last_post_id' => 2, + 'topic_replies' => 1, + 'topic_replies_real' => 1, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2), + ), + ), + array( + 1, 1, 2, + array_merge($info_data, array( + 'post_time' => 2, + )), + true, 'soft delete', + array( + array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'), + array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 1, + 'topic_last_post_id' => 3, + 'topic_replies' => 1, + 'topic_replies_real' => 2, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + ), + ), + array( + 1, 1, 1, + array_merge($info_data, array( + 'post_time' => 1, + )), + true, 'soft delete', + array( + array('post_id' => 1, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'), + array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 2, + 'topic_last_post_id' => 3, + 'topic_replies' => 1, + 'topic_replies_real' => 2, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + ), + ), + array( + 1, 1, 3, + array_merge($info_data, array( + 'post_time' => 3, + )), + true, 'soft delete', + array( + array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''), + array('post_id' => 3, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'), + ), + array( + array( + 'topic_visibility' => ITEM_APPROVED, + 'topic_first_post_id' => 1, + 'topic_last_post_id' => 2, + 'topic_replies' => 1, + 'topic_replies_real' => 2, + 'topic_delete_reason' => '', + ), + ), + array( + array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2), + ), + ), + ); + } + + /** + * @dataProvider delete_post_data + */ + public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) + { + global $auth, $config, $db; + + $config['search_type'] = 'phpbb_mock_search'; + $db = $this->new_dbal(); + set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); + + // Create auth mock + $auth = $this->getMock('phpbb_auth'); + $auth->expects($this->any()) + ->method('acl_get') + ->with($this->stringContains('_'), $this->anything()) + ->will($this->returnValueMap(array( + array('m_approve', 1, true), + ))); + + delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); + + $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason + FROM phpbb_posts + WHERE topic_id = ' . $topic_id . ' + ORDER BY post_id ASC'); + + $this->assertEquals($expected_posts, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + + $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_replies, topic_replies_real, topic_delete_reason + FROM phpbb_topics + WHERE topic_id = ' . $topic_id); + + $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + + $result = $db->sql_query('SELECT forum_posts, forum_topics, forum_topics_real, forum_last_post_id + FROM phpbb_forums + WHERE forum_id = ' . $forum_id); + + $this->assertEquals($expected_forum, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + } +} diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml new file mode 100644 index 0000000000..1140555d67 --- /dev/null +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -0,0 +1,117 @@ + + + + forum_id + forum_posts + forum_topics + forum_topics_real + forum_last_post_id + forum_desc + forum_rules + + + 1 + 3 + 1 + 1 + 3 + + + +
+ + topic_id + forum_id + topic_visibility + topic_title + topic_first_post_id + topic_last_post_id + topic_delete_user + topic_delete_time + topic_delete_reason + topic_replies + topic_replies_real + + + 1 + 1 + 1 + Approved + 1 + 3 + 0 + 0 + + 2 + 2 + +
+ + post_id + poster_id + topic_id + forum_id + post_visibility + post_time + post_text + post_delete_user + post_delete_time + post_delete_reason + + 1 + 1 + 1 + 1 + 1 + 1 + Approved + 0 + + + + + 2 + 1 + 1 + 1 + 1 + 2 + Approved + 0 + + + + + 3 + 1 + 1 + 1 + 1 + 3 + Approved + 0 + + + +
+ + user_id + user_posts + username + username_clean + user_permissions + user_sig + user_occ + user_interests + + 1 + 1 + user 1 + user 1 + + + + + +
+
-- cgit v1.2.1 From 25804eb8e8b17196116e233b2c8ad3b444cfb5ae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 6 Oct 2012 19:56:52 +0200 Subject: [feature/soft-delete] Add test case for (soft)deleting the only post + fix PHPBB3-9567 --- tests/content_visibility/delete_post_test.php | 55 +++++++++++++++++++++++ tests/content_visibility/fixtures/delete_post.xml | 35 +++++++++++++++ 2 files changed, 90 insertions(+) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index c1efdb5d49..0bb7870521 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -186,6 +186,61 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2), ), ), + + array( + 2, 2, 4, + array( + 'topic_first_post_id' => 4, + 'topic_last_post_id' => 4, + 'topic_replies_real' => 0, + 'topic_visibility' => ITEM_APPROVED, + 'post_time' => 4, + 'post_visibility' => ITEM_APPROVED, + 'post_postcount' => true, + 'poster_id' => 1, + 'post_reported' => false, + ), + false, 'harddelete', + array( + ), + array( + ), + array( + array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 0, 'forum_last_post_id' => 0), + ), + ), + + array( + 2, 2, 4, + array( + 'topic_first_post_id' => 4, + 'topic_last_post_id' => 4, + 'topic_replies_real' => 0, + 'topic_visibility' => ITEM_APPROVED, + 'post_time' => 4, + 'post_visibility' => ITEM_APPROVED, + 'post_postcount' => true, + 'poster_id' => 1, + 'post_reported' => false, + ), + true, 'soft delete', + array( + array('post_id' => 4, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => ''), + ), + array( + array( + 'topic_visibility' => ITEM_DELETED, + 'topic_first_post_id' => 4, + 'topic_last_post_id' => 4, + 'topic_replies' => 0, + 'topic_replies_real' => 0, + 'topic_delete_reason' => 'soft delete', + ), + ), + array( + array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 1, 'forum_last_post_id' => 0), + ), + ), ); } diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index 1140555d67..4799b120b6 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -18,6 +18,15 @@ + + 2 + 1 + 1 + 1 + 4 + + + topic_id @@ -45,6 +54,19 @@ 22 + + 2 + 2 + 1 + Approved + 4 + 4 + 0 + 0 + + 0 + 0 +
post_id @@ -93,6 +115,19 @@ + + + 4 + 1 + 2 + 2 + 1 + 4 + Approved + 0 + + +
user_id -- cgit v1.2.1 From fbf85b76c15c27e478f24947098d56c8c4bb3435 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 15:38:50 +0200 Subject: [feature/soft-delete] Correctly synchronize the topic_visibility in sync() This also makes sync('topic_visibility') obsolete, but we keep it for now. Also fix a unit test, because ITEM_DELETED overpowers ITEM_UNAPPROVED PHPBB3-9567 --- tests/content_visibility/set_post_visibility_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 42459c515a..d3b237e3e9 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -62,7 +62,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''), ), array( - array('topic_visibility' => 0, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3), + array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3), ), ), array( -- cgit v1.2.1 From 3236229188d9b36105633223f4b2df6c6b3eb0ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Oct 2012 23:35:50 +0200 Subject: [feature/soft-delete] Update unit tests to new table structure PHPBB3-9567 --- tests/content_visibility/delete_post_test.php | 67 ++++++++++++++--------- tests/content_visibility/fixtures/delete_post.xml | 26 ++++++--- 2 files changed, 59 insertions(+), 34 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 0bb7870521..b76e27e58e 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -26,7 +26,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $info_data = array( 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_replies_real' => 3, + 'topic_posts' => 3, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, 'post_time' => 2, 'post_visibility' => ITEM_APPROVED, @@ -52,13 +54,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_replies' => 1, - 'topic_replies_real' => 1, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -77,13 +80,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3, - 'topic_replies' => 1, - 'topic_replies_real' => 1, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -102,13 +106,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2, - 'topic_replies' => 1, - 'topic_replies_real' => 1, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), ), array( @@ -127,13 +132,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_replies' => 1, - 'topic_replies_real' => 2, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -152,13 +158,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3, - 'topic_replies' => 1, - 'topic_replies_real' => 2, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 3), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -177,13 +184,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2, - 'topic_replies' => 1, - 'topic_replies_real' => 2, + 'topic_posts' => 2, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_topics' => 1, 'forum_topics_real' => 1, 'forum_last_post_id' => 2), + array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), ), @@ -192,7 +200,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_replies_real' => 0, + 'topic_posts' => 1, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, 'post_time' => 4, 'post_visibility' => ITEM_APPROVED, @@ -206,7 +216,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( ), array( - array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 0, 'forum_last_post_id' => 0), + array('forum_posts' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0), ), ), @@ -215,7 +225,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_replies_real' => 0, + 'topic_posts' => 1, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, 'post_time' => 4, 'post_visibility' => ITEM_APPROVED, @@ -232,13 +244,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_DELETED, 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_replies' => 0, - 'topic_replies_real' => 0, + 'topic_posts' => 0, + 'topic_posts_unapproved' => 0, + 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => 'soft delete', ), ), array( - array('forum_posts' => 0, 'forum_topics' => 0, 'forum_topics_real' => 1, 'forum_last_post_id' => 0), + array('forum_posts' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), ), ), ); @@ -274,14 +287,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $this->assertEquals($expected_posts, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_replies, topic_replies_real, topic_delete_reason + $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_posts, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason FROM phpbb_topics WHERE topic_id = ' . $topic_id); $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT forum_posts, forum_topics, forum_topics_real, forum_last_post_id + $result = $db->sql_query('SELECT forum_posts, forum_posts_unapproved, forum_posts_softdeleted, forum_topics, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id FROM phpbb_forums WHERE forum_id = ' . $forum_id); diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index 4799b120b6..d12bf89644 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -3,8 +3,11 @@
forum_idforum_posts + forum_posts_unapproved + forum_posts_softdeletedforum_topics - forum_topics_real + forum_topics_unapproved + forum_topics_softdeletedforum_last_post_idforum_descforum_rules @@ -12,8 +15,11 @@ 1 3 + 0 + 0 1 - 1 + 0 + 0 3 @@ -21,8 +27,11 @@ 2 1 + 0 + 0 1 - 1 + 0 + 0 4 @@ -38,8 +47,9 @@ topic_delete_user topic_delete_time topic_delete_reason - topic_replies - topic_replies_real + topic_posts + topic_posts_unapproved + topic_posts_softdeleted 1 @@ -51,8 +61,9 @@ 0 0 - 2 - 2 + 3 + 0 + 0 2 @@ -64,6 +75,7 @@ 0 0 + 1 0 0 -- cgit v1.2.1 From b2b5dbed26762d8c434f50ef2d7972c77b593cb3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Oct 2012 00:00:15 +0200 Subject: [feature/soft-delete] Field 'forum_parents' doesn't have a default value PHPBB3-9567 --- tests/content_visibility/fixtures/delete_post.xml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index d12bf89644..8b2e34b3b9 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -9,6 +9,7 @@ forum_topics_unapproved forum_topics_softdeleted forum_last_post_id + forum_parents forum_desc forum_rules @@ -23,6 +24,7 @@ 3 + 2 @@ -35,6 +37,7 @@ 4 +
-- cgit v1.2.1 From 3d56261621acdf8cde9685f69fb14745bb940090 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Oct 2012 18:03:57 +0200 Subject: [feature/soft-delete] Incorrect integer value: '' for column 'post_delete_time' PHPBB3-9567 --- tests/content_visibility/fixtures/delete_post.xml | 8 ++++---- tests/content_visibility/fixtures/set_topic_visibility.xml | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index 8b2e34b3b9..fd18b27ae1 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -103,7 +103,7 @@ 1 Approved 0 - + 0 @@ -115,7 +115,7 @@ 2 Approved 0 - + 0 @@ -127,7 +127,7 @@ 3 Approved 0 - + 0 @@ -140,7 +140,7 @@ 4 Approved 0 - + 0
diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml index e950977575..9959433287 100644 --- a/tests/content_visibility/fixtures/set_topic_visibility.xml +++ b/tests/content_visibility/fixtures/set_topic_visibility.xml @@ -53,7 +53,7 @@ 1 Approved 2 - + 0 @@ -108,8 +108,8 @@ 1 0 Unapproved before the topic was soft deleted - - + 0 + 0 -- cgit v1.2.1 From f77a6eaab5485329a3b13922649fb8902e6e397f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 11:24:52 +0100 Subject: [feature/soft-delete] Fix the rest of *_approved and the delete_post unit test PHPBB3-9567 --- tests/content_visibility/delete_post_test.php | 40 +++++++++++----------- tests/content_visibility/fixtures/delete_post.xml | 8 ++--- .../fixtures/set_topic_visibility.xml | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index b76e27e58e..8b5a26a6fb 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -26,7 +26,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $info_data = array( 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_posts' => 3, + 'topic_posts_approved' => 3, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, @@ -54,14 +54,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -80,14 +80,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -106,14 +106,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), ), array( @@ -132,14 +132,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -158,14 +158,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), ), array( @@ -184,14 +184,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_APPROVED, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2, - 'topic_posts' => 2, + 'topic_posts_approved' => 2, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => '', ), ), array( - array('forum_posts' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), + array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), ), @@ -200,7 +200,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_posts' => 1, + 'topic_posts_approved' => 1, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, @@ -216,7 +216,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( ), array( - array('forum_posts' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0), + array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0), ), ), @@ -225,7 +225,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_posts' => 1, + 'topic_posts_approved' => 1, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 0, 'topic_visibility' => ITEM_APPROVED, @@ -244,14 +244,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case 'topic_visibility' => ITEM_DELETED, 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, - 'topic_posts' => 0, + 'topic_posts_approved' => 0, 'topic_posts_unapproved' => 0, 'topic_posts_softdeleted' => 1, 'topic_delete_reason' => 'soft delete', ), ), array( - array('forum_posts' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), + array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), ), ), ); @@ -287,14 +287,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $this->assertEquals($expected_posts, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_posts, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason + $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason FROM phpbb_topics WHERE topic_id = ' . $topic_id); $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT forum_posts, forum_posts_unapproved, forum_posts_softdeleted, forum_topics, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id + $result = $db->sql_query('SELECT forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id FROM phpbb_forums WHERE forum_id = ' . $forum_id); diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index fd18b27ae1..deca9c74b6 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -2,10 +2,10 @@ forum_id - forum_posts + forum_posts_approvedforum_posts_unapprovedforum_posts_softdeleted - forum_topics + forum_topics_approvedforum_topics_unapprovedforum_topics_softdeletedforum_last_post_id @@ -50,7 +50,7 @@ topic_delete_usertopic_delete_timetopic_delete_reason - topic_posts + topic_posts_approvedtopic_posts_unapprovedtopic_posts_softdeleted @@ -155,7 +155,7 @@ user_interests 1 - 1 + 4 user 1 user 1 diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml index 9959433287..a875012d4f 100644 --- a/tests/content_visibility/fixtures/set_topic_visibility.xml +++ b/tests/content_visibility/fixtures/set_topic_visibility.xml @@ -124,7 +124,7 @@ user_interests 1 - 1 + 6 user 1 user 1 -- cgit v1.2.1 From 51966bd497e567bb9154c4fff4ccda918cff95a4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 16:41:43 +0100 Subject: [feature/soft-delete]Fix the rest of unit tests failures PHPBB3-9567 --- tests/content_visibility/delete_post_test.php | 3 ++- tests/content_visibility/fixtures/set_post_visibility.xml | 12 ++++++++++++ tests/content_visibility/get_forums_visibility_sql_test.php | 3 ++- tests/content_visibility/get_global_visibility_sql_test.php | 3 ++- tests/content_visibility/get_visibility_sql_test.php | 3 ++- tests/content_visibility/set_post_visibility_test.php | 3 ++- tests/content_visibility/set_topic_visibility_test.php | 3 ++- 7 files changed, 24 insertions(+), 6 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 8b5a26a6fb..3f15d5a158 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,9 +262,10 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $config, $db; + global $auth, $cache, $config, $db; $config['search_type'] = 'phpbb_mock_search'; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 6fec5c5ad1..722525deaa 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -7,6 +7,9 @@ topic_title topic_first_post_id topic_last_post_id + topic_posts_approved + topic_posts_softdeleted + topic_posts_unapproved 1 1 @@ -14,6 +17,9 @@ Approved 2 2 + 1 + 1 + 1 @@ -23,6 +29,9 @@ 2 Approved posts 5 6 + 1 + 1 + 1 @@ -32,6 +41,9 @@ Only 1 Approved posts 8 8 + 1 + 0 + 0
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 840f247b14..236b08f74c 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -119,8 +119,9 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data */ public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $db, $auth; + global $cache, $db, $auth; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); // Create auth mock diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 8b96b3954d..9d320a4ee7 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -119,8 +119,9 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data */ public function test_get_global_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $db, $auth; + global $cache, $db, $auth; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); // Create auth mock diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 3c837b2837..4af8c062e7 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -66,8 +66,9 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te */ public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) { - global $db, $auth; + global $cache, $db, $auth; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); // Create auth mock diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index d3b237e3e9..8f83457cae 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -115,8 +115,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t */ public function test_set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected, $expected_topic) { - global $db; + global $cache, $db; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); phpbb_content_visibility::set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index a1aedc6a5b..31a6b37caa 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -79,8 +79,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ */ public function test_set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all, $expected_posts, $expected_topic) { - global $db; + global $cache, $db; + $cache = new phpbb_mock_cache; $db = $this->new_dbal(); phpbb_content_visibility::set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From 1a17a3854fa62e0fcdb018e1dcb53253b67ea8f1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 6 Mar 2013 16:13:34 +0100 Subject: [ticket/9657] Fix unit tests missing global container. PHPBB3-9657 --- tests/content_visibility/delete_post_test.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 3f15d5a158..e7ab3e3879 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,13 +262,16 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db; + global $auth, $cache, $config, $db, $phpbb_container; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + // Create auth mock $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) -- cgit v1.2.1 From 753dc62267118e44b16653113521fe6d0a360720 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 15:02:07 +0200 Subject: [ticket/9657] Fix unit tests PHPBB3-9657 --- tests/content_visibility/delete_post_test.php | 10 ++++++---- tests/content_visibility/get_forums_visibility_sql_test.php | 6 ++++-- tests/content_visibility/get_global_visibility_sql_test.php | 5 +++-- tests/content_visibility/get_visibility_sql_test.php | 5 +++-- tests/content_visibility/set_post_visibility_test.php | 6 ++++-- tests/content_visibility/set_topic_visibility_test.php | 6 ++++-- 6 files changed, 24 insertions(+), 14 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e7ab3e3879..6234aac9ad 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,16 +262,13 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db, $phpbb_container; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_root_path, $phpEx; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - // Create auth mock $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) @@ -280,6 +277,11 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); + $user = $this->getMock('phpbb_user'); + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 236b08f74c..7580a53fa4 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data */ public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -131,9 +131,11 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 9d320a4ee7..bdb0a96954 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data */ public function test_get_global_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -130,10 +130,11 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 4af8c062e7..f75c98f899 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -66,7 +66,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te */ public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -77,10 +77,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_visibility_sql($mode, $forum_id, $table_alias) . ' + WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 8f83457cae..845430b21b 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -115,12 +115,14 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t */ public function test_set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 31a6b37caa..3061ba44db 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -79,12 +79,14 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ */ public function test_set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all, $expected_posts, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); + $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts -- cgit v1.2.1 From 167ca1f33f8265e5dea6481cc69de16ccfdd0dce Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 11:25:38 -0400 Subject: [ticket/9657] Define user before injecting PHPBB3-9657 --- tests/content_visibility/get_forums_visibility_sql_test.php | 2 +- tests/content_visibility/get_global_visibility_sql_test.php | 1 + tests/content_visibility/get_visibility_sql_test.php | 1 + tests/content_visibility/set_post_visibility_test.php | 1 + tests/content_visibility/set_topic_visibility_test.php | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 7580a53fa4..aa44fa4013 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -130,7 +130,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index bdb0a96954..0f019ffa50 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -130,6 +130,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index f75c98f899..cc6c10c649 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -77,6 +77,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 845430b21b..81abf56c75 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -120,6 +120,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 3061ba44db..6b5d884a2b 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -84,6 +84,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('phpbb_user'); $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- tests/content_visibility/delete_post_test.php | 8 ++++---- tests/content_visibility/get_forums_visibility_sql_test.php | 6 +++--- tests/content_visibility/get_global_visibility_sql_test.php | 6 +++--- tests/content_visibility/get_visibility_sql_test.php | 6 +++--- tests/content_visibility/set_post_visibility_test.php | 6 +++--- tests/content_visibility/set_topic_visibility_test.php | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 6234aac9ad..b2bdcb3b49 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -267,21 +267,21 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); + set_config_count(null, null, null, new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1))); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); - $user = $this->getMock('phpbb_user'); + $user = $this->getMock('\phpbb\user'); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index aa44fa4013..22f210c406 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -125,13 +125,13 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 0f019ffa50..9488a8c0b3 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -125,13 +125,13 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index cc6c10c649..111e735650 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -72,13 +72,13 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 81abf56c75..f81b83ff86 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -119,9 +119,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $auth = $this->getMock('phpbb_auth'); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 6b5d884a2b..92b1253a15 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -83,9 +83,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $auth = $this->getMock('phpbb_auth'); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From bbada27ee9e797c7f6ce997152bc1efb8c8f125d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 2 Feb 2014 21:45:59 +0100 Subject: [ticket/12115] Also port user interests to profile fields PHPBB3-12115 --- tests/content_visibility/fixtures/delete_post.xml | 4 ---- tests/content_visibility/fixtures/set_post_visibility.xml | 8 -------- tests/content_visibility/fixtures/set_topic_visibility.xml | 4 ---- 3 files changed, 16 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml index deca9c74b6..c29ad23019 100644 --- a/tests/content_visibility/fixtures/delete_post.xml +++ b/tests/content_visibility/fixtures/delete_post.xml @@ -151,8 +151,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 4 @@ -160,8 +158,6 @@ user 1 - -
diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 722525deaa..5f792d0f05 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -126,8 +126,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 1 @@ -135,8 +133,6 @@ user 1 - - 2 @@ -145,8 +141,6 @@ user 2 - - 3 @@ -155,8 +149,6 @@ user 3 - - diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml index a875012d4f..02ab5f16fe 100644 --- a/tests/content_visibility/fixtures/set_topic_visibility.xml +++ b/tests/content_visibility/fixtures/set_topic_visibility.xml @@ -120,8 +120,6 @@ username_clean user_permissions user_sig - user_occ - user_interests 1 6 @@ -129,8 +127,6 @@ user 1 - - -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- tests/content_visibility/delete_post_test.php | 10 +++++++--- tests/content_visibility/get_forums_visibility_sql_test.php | 10 +++++++--- tests/content_visibility/get_global_visibility_sql_test.php | 10 +++++++--- tests/content_visibility/get_visibility_sql_test.php | 10 +++++++--- tests/content_visibility/set_post_visibility_test.php | 10 +++++++--- tests/content_visibility/set_topic_visibility_test.php | 10 +++++++--- 6 files changed, 42 insertions(+), 18 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index b2bdcb3b49..e0a2a3d402 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 22f210c406..9fd84d7c04 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 9488a8c0b3..6397cd6e45 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 111e735650..daad901b67 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index f81b83ff86..bdff1c0a85 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 92b1253a15..6437c61436 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From ad4a373557adc93c0490471b472312483ac0b1a0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 28 May 2014 14:55:55 +0200 Subject: [ticket/12174] Add tests PHPBB3-12174 --- .../fixtures/set_post_visibility.xml | 84 ++++++++++++++++++++++ .../set_post_visibility_test.php | 41 +++++++++++ 2 files changed, 125 insertions(+) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml index 5f792d0f05..1b8dac2670 100644 --- a/tests/content_visibility/fixtures/set_post_visibility.xml +++ b/tests/content_visibility/fixtures/set_post_visibility.xml @@ -10,6 +10,7 @@ topic_posts_approved topic_posts_softdeleted topic_posts_unapproved + topic_attachment 1 1 @@ -20,6 +21,7 @@ 1 1 1 + 0 @@ -32,6 +34,7 @@ 1 1 1 + 0 @@ -44,6 +47,33 @@ 1 0 0 + 0 + + + + 10 + 10 + 1 + Only 3 posts (2 with attachments) + 10 + 12 + 3 + 0 + 0 + 1 + + + + 11 + 10 + 1 + Only 2 posts (1 with attachments) + 13 + 14 + 3 + 0 + 0 + 1 @@ -53,6 +83,7 @@ forum_idpost_visibilitypost_text + post_attachment 1 1 @@ -60,6 +91,7 @@ 1 0 Unapproved + 0 2 @@ -68,6 +100,7 @@ 1 1 Approved + 0 3 @@ -76,6 +109,7 @@ 1 2 Softdeleted + 0 @@ -85,6 +119,7 @@ 1 0 Unapproved + 0 5 @@ -93,6 +128,7 @@ 1 1 Approved + 0 6 @@ -101,6 +137,7 @@ 1 1 Approved 2 + 0 7 @@ -109,6 +146,7 @@ 1 2 Softdeleted + 0 8 @@ -117,6 +155,52 @@ 1 1 Approved + 0 + + + 10 + 1 + 10 + 10 + 1 + Softdeleted + 1 + + + 11 + 1 + 10 + 10 + 1 + Softdeleted + 1 + + + 12 + 1 + 10 + 10 + 1 + Approved + 0 + + + 13 + 1 + 11 + 10 + 1 + Approved + 1 + + + 14 + 1 + 11 + 10 + 1 + Approved + 0
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index f81b83ff86..be4571bdfe 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -140,4 +140,45 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $this->assertEquals($expected_topic, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); } + + public function set_post_soft_deleted_data() + { + return array( + array( + 10, 10, 10, + 1, time(), 'soft-deleted', + true, false, + array(array('topic_attachment' => 1)), + ), + array( + 13, 11, 10, + 1, time(), 'soft-deleted', + true, false, + array(array('topic_attachment' => 0)), + ), + ); + } + + /** + * @dataProvider set_post_soft_deleted_data + */ + public function test_set_post_soft_deleted($post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected) + { + global $cache, $db, $auth, $phpbb_root_path, $phpEx; + + $cache = new phpbb_mock_cache; + $db = $this->new_dbal(); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + + $content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + + $result = $db->sql_query('SELECT topic_attachment + FROM phpbb_topics + WHERE topic_id = ' . $topic_id); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); + } } -- cgit v1.2.1 From 752b5b6628a27a1220268f3929402b3699eed0c7 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 20 Jun 2014 15:30:04 +0530 Subject: [ticket/12746] Init phpbb_dispatcher being used by delete_post() PHPBB3-12746 --- tests/content_visibility/delete_post_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e0a2a3d402..99068729df 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -266,7 +266,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db, $phpbb_container, $phpbb_root_path, $phpEx; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; @@ -283,6 +283,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ))); $user = $this->getMock('\phpbb\user'); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); -- cgit v1.2.1 From eeb2c128f56d6661f236afe2eecae0d832877d53 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 20 Jun 2014 15:40:23 +0530 Subject: [ticket/12738] Fix tests with new config object injection PHPBB3-12738 --- tests/content_visibility/delete_post_test.php | 5 +++-- tests/content_visibility/get_forums_visibility_sql_test.php | 3 ++- tests/content_visibility/get_global_visibility_sql_test.php | 3 ++- tests/content_visibility/get_visibility_sql_test.php | 3 ++- tests/content_visibility/set_post_visibility_test.php | 6 ++++-- tests/content_visibility/set_topic_visibility_test.php | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e0a2a3d402..e2b1477e10 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -271,7 +271,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - set_config_count(null, null, null, new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1))); + $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1)); + set_config_count(null, null, null, $phpbb_config); // Create auth mock $auth = $this->getMock('\phpbb\auth\auth'); @@ -285,7 +286,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 9fd84d7c04..7e4ce6577d 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -135,7 +135,8 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 6397cd6e45..082e0d76ab 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -135,7 +135,8 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index daad901b67..2d4f24f1c6 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -82,7 +82,8 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index abfefaddfa..a596b45714 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -125,7 +125,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); @@ -174,7 +175,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 6437c61436..230474428c 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -89,7 +89,8 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); $user = $this->getMock('\phpbb\user'); - $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $config = new phpbb\config\config(array()); + $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From 4c2b4b4145d88627c48ddcd88a71a76e58f4dfe2 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 7 Aug 2014 18:36:50 +0200 Subject: [ticket/12718] Add tests to check user_posts on post deletion PHPBB3-12718 --- tests/content_visibility/delete_post_test.php | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index aa705c52a5..e85fbd3fc7 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -67,6 +67,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), + array( + array('user_posts' => 3), + ), ), array( 1, 1, 1, @@ -93,6 +96,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), + array( + array('user_posts' => 3), + ), ), array( 1, 1, 3, @@ -119,6 +125,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), + array( + array('user_posts' => 3), + ), ), array( 1, 1, 2, @@ -145,6 +154,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), + array( + array('user_posts' => 3), + ), ), array( 1, 1, 1, @@ -171,6 +183,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3), ), + array( + array('user_posts' => 3), + ), ), array( 1, 1, 3, @@ -197,6 +212,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2), ), + array( + array('user_posts' => 3), + ), ), array( @@ -222,6 +240,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case array( array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0), ), + array( + array('user_posts' => 3), + ), ), array( @@ -255,7 +276,10 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ), ), array( - array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), + array('forum_posts_approved'=> 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), + ), + array( + array('user_posts' => 3), ), ), ); @@ -264,7 +288,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case /** * @dataProvider delete_post_data */ - public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) + public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user) { global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; @@ -313,5 +337,12 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $this->assertEquals($expected_forum, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); + + $result = $db->sql_query('SELECT user_posts + FROM phpbb_users + WHERE user_id = ' . $data['poster_id']); + + $this->assertEquals($expected_user, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); } } -- cgit v1.2.1 From 6d399c7d6a8519ad3e6f7b3154ee42ee08eb435f Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 7 Aug 2014 23:47:32 +0200 Subject: [ticket/12718] Fix spacing and type casting PHPBB3-12718 --- tests/content_visibility/delete_post_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e85fbd3fc7..a913b4b578 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -276,7 +276,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ), ), array( - array('forum_posts_approved'=> 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), + array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0), ), array( array('user_posts' => 3), @@ -340,7 +340,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $result = $db->sql_query('SELECT user_posts FROM phpbb_users - WHERE user_id = ' . $data['poster_id']); + WHERE user_id = ' . (int) $data['poster_id']); $this->assertEquals($expected_user, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); -- cgit v1.2.1 From 15afaafcb67298ff7fabf3b1b4326bbc2a5975ba Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 8 Aug 2014 00:18:50 +0200 Subject: [ticket/12718] Use a separate variable for sql query PHPBB3-12718 --- tests/content_visibility/delete_post_test.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index a913b4b578..7f31dd9b28 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -338,9 +338,10 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $this->assertEquals($expected_forum, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); - $result = $db->sql_query('SELECT user_posts - FROM phpbb_users - WHERE user_id = ' . (int) $data['poster_id']); + $sql = 'SELECT user_posts + FROM ' . USERS_TABLE . ' + WHERE user_id = ' . (int) $data['poster_id']; + $result = $db->sql_query($sql); $this->assertEquals($expected_user, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); -- cgit v1.2.1 From 8d99b4afe1557a6ec0e760c4876bb06a3b9991d3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 10 Aug 2014 13:40:27 +0200 Subject: [ticket/12932] Fix tests and calls to create_datetime PHPBB3-12932 --- tests/content_visibility/delete_post_test.php | 2 +- tests/content_visibility/get_forums_visibility_sql_test.php | 2 +- tests/content_visibility/get_global_visibility_sql_test.php | 2 +- tests/content_visibility/get_visibility_sql_test.php | 2 +- tests/content_visibility/set_post_visibility_test.php | 4 ++-- tests/content_visibility/set_topic_visibility_test.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 7f31dd9b28..65dda3ce48 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -306,7 +306,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 7e4ce6577d..fe7ab36436 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -134,7 +134,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 082e0d76ab..43a80c792b 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -134,7 +134,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 2d4f24f1c6..f718e6c29a 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -81,7 +81,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index a596b45714..ab79fbc2ee 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -124,7 +124,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); @@ -174,7 +174,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 230474428c..4d02a55490 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -88,7 +88,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $auth = $this->getMock('\phpbb\auth\auth'); - $user = $this->getMock('\phpbb\user'); + $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); -- cgit v1.2.1 From 1c02f7e032cf2d28b70739d02edaea7354fcf887 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 15:10:32 +0000 Subject: [ticket/13146] Adding required tests modifications for the new constructor PHPBB3-13146 --- tests/content_visibility/get_forums_visibility_sql_test.php | 3 ++- tests/content_visibility/get_global_visibility_sql_test.php | 3 ++- tests/content_visibility/get_visibility_sql_test.php | 3 ++- tests/content_visibility/set_post_visibility_test.php | 3 ++- tests/content_visibility/set_topic_visibility_test.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index fe7ab36436..6be26a4072 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -136,7 +136,8 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 43a80c792b..441c13cfc6 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -136,7 +136,8 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index f718e6c29a..5e3e345543 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -83,7 +83,8 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index ab79fbc2ee..8cb14312ef 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -126,7 +126,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 4d02a55490..f679b03b82 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -90,7 +90,8 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From bfecae1d601b1dc841c22c7eee49efa10a07972b Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 15:43:27 +0000 Subject: [ticket/13146] Forgot delete_post_test.php PHPBB3-13146 --- tests/content_visibility/delete_post_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 65dda3ce48..f02769469a 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -296,6 +296,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1)); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); set_config_count(null, null, null, $phpbb_config); // Create auth mock @@ -312,7 +313,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); -- cgit v1.2.1 From 8376a027a122af99782fa2d9f87185b448e2cf77 Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 2 Jan 2015 11:46:03 +0000 Subject: [ticket/13146] Setup mocks for tests with dispatcher PHPBB3-13146 --- tests/content_visibility/delete_post_test.php | 5 ++++- tests/content_visibility/get_forums_visibility_sql_test.php | 4 +++- tests/content_visibility/get_global_visibility_sql_test.php | 4 +++- tests/content_visibility/get_visibility_sql_test.php | 4 +++- tests/content_visibility/set_post_visibility_test.php | 4 +++- tests/content_visibility/set_topic_visibility_test.php | 4 +++- 6 files changed, 19 insertions(+), 6 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index f02769469a..df5acedd1e 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -309,7 +309,10 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ))); $user = new \phpbb\user('\phpbb\datetime'); - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + + $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 6be26a4072..805d543730 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -136,7 +136,9 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 441c13cfc6..3b95797b77 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -136,7 +136,9 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 5e3e345543..a29bd2332d 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -83,7 +83,9 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 8cb14312ef..149530e122 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -126,7 +126,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index f679b03b82..bdc403f451 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -90,7 +90,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From b3bcc1b501a81e7f26d237cd427185ddce4d4bcc Mon Sep 17 00:00:00 2001 From: brunoais Date: Fri, 2 Jan 2015 19:26:05 +0000 Subject: [ticket/13146] Missing delete post test mock PHPBB3-13146 --- tests/content_visibility/delete_post_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index df5acedd1e..42e9504214 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -296,7 +296,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1)); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher'); + $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') + ->disableOriginalConstructor() + ->getMock(); set_config_count(null, null, null, $phpbb_config); // Create auth mock -- cgit v1.2.1 From 346f654b2e933ce57413d3f811aeb86732d8c602 Mon Sep 17 00:00:00 2001 From: brunoais Date: Tue, 6 Jan 2015 12:57:47 +0000 Subject: [ticket/13146] Use the correct phpbb_mock_event_dispatcher, instead of builder PHPBB3-13146 --- tests/content_visibility/delete_post_test.php | 4 +--- tests/content_visibility/get_forums_visibility_sql_test.php | 4 +--- tests/content_visibility/get_global_visibility_sql_test.php | 4 +--- tests/content_visibility/get_visibility_sql_test.php | 4 +--- tests/content_visibility/set_post_visibility_test.php | 4 +--- tests/content_visibility/set_topic_visibility_test.php | 4 +--- 6 files changed, 6 insertions(+), 18 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 42e9504214..581c132893 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -296,9 +296,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1)); - $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); set_config_count(null, null, null, $phpbb_config); // Create auth mock diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 805d543730..28e463ecb5 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -136,9 +136,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 3b95797b77..586bae8668 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -136,9 +136,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index a29bd2332d..9ae2d2fdc4 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -83,9 +83,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->will($this->returnValueMap($permissions)); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 149530e122..d62e7ed60b 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -126,9 +126,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index bdc403f451..6c34f42167 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -90,9 +90,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); -- cgit v1.2.1 From da9ac2da7240def3c929aecdf98ec284be994da1 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 08:11:51 +0000 Subject: [ticket/13146] Last missing phpbb_mock_event_dispatcher() Thank you nickvergessen PHPBB3-13146 --- tests/content_visibility/delete_post_test.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 581c132893..6ad6351a0c 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -309,10 +309,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ))); $user = new \phpbb\user('\phpbb\datetime'); - - $phpbb_dispatcher = $this->getMockBuilder('\phpbb\event\dispatcher') - ->disableOriginalConstructor() - ->getMock(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); -- cgit v1.2.1 From 349aaab6acd1188298cc06e12d389e90871aafd9 Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 10 Jan 2015 08:32:22 +0000 Subject: [ticket/13146] Even more missing phpbb_mock_event_dispatcher() PHPBB3-13146 --- tests/content_visibility/set_post_visibility_test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/content_visibility') diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index d62e7ed60b..36ebf58374 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -177,7 +177,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $auth = $this->getMock('\phpbb\auth\auth'); $user = new \phpbb\user('\phpbb\datetime'); $config = new phpbb\config\config(array()); - $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); -- cgit v1.2.1