aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-03-07 16:09:55 +0100
committerJoas Schilling <nickvergessen@gmx.de>2013-03-07 16:09:55 +0100
commit20f84c3795b55b20a5338de4e09455de651a7007 (patch)
tree0635feae5b40b20efcfeb519a90fc3c66e2c6f54 /tests
parent1a498524138a7a3192ad14ad10f714b34488321f (diff)
parentd658d6640ba35ef162c7d1d3f696f28d1387bf3d (diff)
downloadforums-20f84c3795b55b20a5338de4e09455de651a7007.tar
forums-20f84c3795b55b20a5338de4e09455de651a7007.tar.gz
forums-20f84c3795b55b20a5338de4e09455de651a7007.tar.bz2
forums-20f84c3795b55b20a5338de4e09455de651a7007.tar.xz
forums-20f84c3795b55b20a5338de4e09455de651a7007.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/softdelete-1-permission
* 'develop' of https://github.com/phpbb/phpbb3: [ticket/11408] user_jabber instead of jabber [ticket/10202] Rename method names _all() to _array(). [ticket/10202] Add migration file for config_db_text. [ticket/10202] Upgrade TEXT to the bigger MTEXT. [ticket/10202] Improve method documentation. [ticket/10202] SQL escape the table name. [ticket/10202] Add $this->db->sql_freeresult($result) to SELECT queries. [ticket/10202] Define phpbb_config_db_text as a service. [ticket/10202] Add tests for phpbb_config_db_text. [ticket/10202] Adjust method names to guidelines. [ticket/10202] Add database schema for phpbb_config_db_text. [ticket/10202] Implementation of config options with arbitrary length values. [ticket/11166] Add ajaxify support to normal ACP confirm_box() [ticket/11166] Fix several custom confirm templates in prosilver [ticket/11166] Add caption to AJAX confirm box default template [ticket/11166] Fix typo in comment [ticket/11166] Use provided custom templates on AJAX confirm box
Diffstat (limited to 'tests')
-rw-r--r--tests/config/db_text_test.php115
-rw-r--r--tests/config/fixtures/config_text.xml19
2 files changed, 134 insertions, 0 deletions
diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php
new file mode 100644
index 0000000000..4818bba8c9
--- /dev/null
+++ b/tests/config/db_text_test.php
@@ -0,0 +1,115 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_config_db_text_test extends phpbb_database_test_case
+{
+ private $db;
+ private $config_text;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml');
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->db = $this->new_dbal();
+ $this->config_text = new phpbb_config_db_text($this->db, 'phpbb_config_text');
+ }
+
+ public function test_get()
+ {
+ $this->assertSame('23', $this->config_text->get('foo'));
+ $this->assertSame('string-de-ding', $this->config_text->get('meh'));
+ }
+
+ public function test_get_nonexisting()
+ {
+ $this->assertNull($this->config_text->get('noooooo'));
+ }
+
+ public function test_set_new_get()
+ {
+ $this->config_text->set('barz', 'phpbb');
+ $this->assertSame('phpbb', $this->config_text->get('barz'));
+ }
+
+ public function test_set_replace_get()
+ {
+ $this->config_text->set('foo', '24');
+ $this->assertSame('24', $this->config_text->get('foo'));
+ }
+
+ public function test_set_get_long_string()
+ {
+ $expected = str_repeat('ABC', 10000);
+ $this->config_text->set('long', $expected);
+ $this->assertSame($expected, $this->config_text->get('long'));
+ }
+
+ public function test_delete_get()
+ {
+ $this->config_text->delete('foo');
+ $this->assertNull($this->config_text->get('foo'));
+
+ $this->assertSame('42', $this->config_text->get('bar'));
+ $this->assertSame('string-de-ding', $this->config_text->get('meh'));
+ }
+
+ public function test_get_array_empty()
+ {
+ $this->assertEmpty($this->config_text->get_array(array('key1', 'key2')));
+ }
+
+ public function test_get_array_subset()
+ {
+ $expected = array(
+ 'bar' => '42',
+ 'foo' => '23',
+ );
+
+ $actual = $this->config_text->get_array(array_keys($expected));
+ ksort($actual);
+
+ $this->assertSame($expected, $actual);
+ }
+
+ public function test_set_array_get_array_subset()
+ {
+ $set_array_param = array(
+ // New entry
+ 'baby' => 'phpBB',
+ // Entry update
+ 'bar' => '64',
+ );
+
+ $this->config_text->set_array($set_array_param);
+
+ $expected = array_merge($set_array_param, array(
+ 'foo' => '23',
+ ));
+
+ $actual = $this->config_text->get_array(array_keys($expected));
+ ksort($actual);
+
+ $this->assertSame($expected, $actual);
+ }
+
+ public function test_delete_array_get_remaining()
+ {
+ $this->config_text->delete_array(array('foo', 'bar'));
+
+ $this->assertNull($this->config_text->get('bar'));
+ $this->assertNull($this->config_text->get('foo'));
+
+ $this->assertSame('string-de-ding', $this->config_text->get('meh'));
+ }
+}
diff --git a/tests/config/fixtures/config_text.xml b/tests/config/fixtures/config_text.xml
new file mode 100644
index 0000000000..5acac13ea3
--- /dev/null
+++ b/tests/config/fixtures/config_text.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_config_text">
+ <column>config_name</column>
+ <column>config_value</column>
+ <row>
+ <value>foo</value>
+ <value>23</value>
+ </row>
+ <row>
+ <value>bar</value>
+ <value>42</value>
+ </row>
+ <row>
+ <value>meh</value>
+ <value>string-de-ding</value>
+ </row>
+ </table>
+</dataset>