diff options
Diffstat (limited to 'tests/content_visibility')
3 files changed, 282 insertions, 5 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_topics"> + <column>topic_id</column> + <column>forum_id</column> + <column>topic_visibility</column> + <column>topic_title</column> + <row> + <value>1</value> + <value>1</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>2</value> + <value>1</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>3</value> + <value>1</value> + <value>2</value> + <value>Softdeleted</value> + </row> + <row> + <value>4</value> + <value>2</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>5</value> + <value>2</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>6</value> + <value>2</value> + <value>2</value> + <value>Softdeleted</value> + </row> + <row> + <value>7</value> + <value>3</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>8</value> + <value>3</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>9</value> + <value>3</value> + <value>2</value> + <value>Softdeleted</value> + </row> + </table> + <table name="phpbb_posts"> + <column>post_id</column> + <column>topic_id</column> + <column>forum_id</column> + <column>post_visibility</column> + <column>post_text</column> + <row> + <value>1</value> + <value>1</value> + <value>1</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>2</value> + <value>2</value> + <value>1</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>3</value> + <value>3</value> + <value>1</value> + <value>2</value> + <value>Softdeleted</value> + </row> + <row> + <value>4</value> + <value>4</value> + <value>2</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>5</value> + <value>5</value> + <value>2</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>6</value> + <value>6</value> + <value>2</value> + <value>2</value> + <value>Softdeleted</value> + </row> + <row> + <value>7</value> + <value>7</value> + <value>3</value> + <value>0</value> + <value>Unapproved</value> + </row> + <row> + <value>8</value> + <value>8</value> + <value>3</value> + <value>1</value> + <value>Approved</value> + </row> + <row> + <value>9</value> + <value>9</value> + <value>3</value> + <value>2</value> + <value>Softdeleted</value> + </row> + </table> +</dataset> 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 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +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() + { + return $this->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()) |