aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/db_tools_test.php60
-rw-r--r--tests/session/append_sid_test.php51
2 files changed, 111 insertions, 0 deletions
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index ddea500f83..753cc08fc5 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -271,6 +271,66 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
'foo' => array('UINT', 42)))
);
+ $this->assertTrue($this->tools->sql_table_exists('prefix_test_table'));
+
$this->tools->sql_table_drop('prefix_test_table');
+
+ $this->assertFalse($this->tools->sql_table_exists('prefix_test_table'));
+ }
+
+ public function test_peform_schema_changes_drop_tables()
+ {
+ $db_tools = $this->getMock('phpbb_db_tools', array(
+ 'sql_table_exists',
+ 'sql_table_drop',
+ ), array(&$this->db));
+
+ // pretend all tables exist
+ $db_tools->expects($this->any())->method('sql_table_exists')
+ ->will($this->returnValue(true));
+
+ // drop tables
+ $db_tools->expects($this->exactly(2))->method('sql_table_drop');
+ $db_tools->expects($this->at(1))->method('sql_table_drop')
+ ->with($this->equalTo('dropped_table_1'));
+ $db_tools->expects($this->at(3))->method('sql_table_drop')
+ ->with($this->equalTo('dropped_table_2'));
+
+ $db_tools->perform_schema_changes(array(
+ 'drop_tables' => array(
+ 'dropped_table_1',
+ 'dropped_table_2',
+ ),
+ ));
+ }
+
+ public function test_peform_schema_changes_drop_columns()
+ {
+ $db_tools = $this->getMock('phpbb_db_tools', array(
+ 'sql_column_exists',
+ 'sql_column_remove',
+ ), array(&$this->db));
+
+ // pretend all columns exist
+ $db_tools->expects($this->any())->method('sql_column_exists')
+ ->will($this->returnValue(true));
+ $db_tools->expects($this->any())->method('sql_column_exists')
+ ->will($this->returnValue(true));
+
+ // drop columns
+ $db_tools->expects($this->exactly(2))->method('sql_column_remove');
+ $db_tools->expects($this->at(1))->method('sql_column_remove')
+ ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1'));
+ $db_tools->expects($this->at(3))->method('sql_column_remove')
+ ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2'));
+
+ $db_tools->perform_schema_changes(array(
+ 'drop_columns' => array(
+ 'existing_table' => array(
+ 'dropped_column_1',
+ 'dropped_column_2',
+ ),
+ ),
+ ));
}
}
diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php
new file mode 100644
index 0000000000..1a3ad633e3
--- /dev/null
+++ b/tests/session/append_sid_test.php
@@ -0,0 +1,51 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_session_append_sid_test extends phpbb_test_case
+{
+
+ public function append_sid_data()
+ {
+ return array(
+ array('viewtopic.php?t=1&amp;f=2', false, true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in url-argument'),
+ array('viewtopic.php', 't=1&amp;f=2', true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument using amp'),
+ array('viewtopic.php', 't=1&f=2', false, false, 'viewtopic.php?t=1&f=2', 'parameters in params-argument using &'),
+ array('viewtopic.php', array('t' => 1, 'f' => 2), true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument as array'),
+
+ // Custom sid parameter
+ array('viewtopic.php', 't=1&amp;f=2', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
+
+ // Testing anchors
+ array('viewtopic.php?t=1&amp;f=2#anchor', false, true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in url-argument'),
+ array('viewtopic.php', 't=1&amp;f=2#anchor', true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument'),
+ array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+
+ // Anchors and custom sid
+ array('viewtopic.php?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
+ array('viewtopic.php', 't=1&amp;f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
+ array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+
+ // Empty parameters should not append the ?
+ array('viewtopic.php', false, true, false, 'viewtopic.php', 'no params using bool false'),
+ array('viewtopic.php', '', true, false, 'viewtopic.php', 'no params using empty string'),
+ array('viewtopic.php', array(), true, false, 'viewtopic.php', 'no params using empty array'),
+ );
+ }
+
+ /**
+ * @dataProvider append_sid_data
+ */
+ public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
+ {
+ $this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
+ }
+}
+