diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bootstrap.php | 20 | ||||
-rw-r--r-- | tests/dbal/select_test.php | 25 | ||||
-rw-r--r-- | tests/extension/ext/foo/type/dummy/empty.txt | 0 | ||||
-rw-r--r-- | tests/extension/fixtures/extensions.xml | 3 | ||||
-rw-r--r-- | tests/group_positions/fixtures/group_positions.xml | 4 | ||||
-rw-r--r-- | tests/template/template_inheritance_test.php | 9 | ||||
-rw-r--r-- | tests/template/template_test.php | 36 | ||||
-rw-r--r-- | tests/template/template_test_case.php | 11 | ||||
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 3 |
9 files changed, 85 insertions, 26 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 63e6f4b280..3544c66c3d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -10,27 +10,11 @@ define('IN_PHPBB', true); $phpbb_root_path = 'phpBB/'; $phpEx = 'php'; -$table_prefix = 'phpbb_'; - -if (!defined('E_DEPRECATED')) -{ - define('E_DEPRECATED', 8192); -} -error_reporting(E_ALL & ~E_DEPRECATED); - -// If we are on PHP >= 6.0.0 we do not need some code -if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) -{ - define('STRIP', false); -} -else -{ - @set_magic_quotes_runtime(0); - define('STRIP', (get_magic_quotes_gpc()) ? true : false); -} +require_once $phpbb_root_path . 'includes/startup.php'; require_once $phpbb_root_path . 'vendor/.composer/autoload.php'; +$table_prefix = 'phpbb_'; require_once $phpbb_root_path . 'includes/constants.php'; require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx; diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php index 05b0e68e29..21b12777dc 100644 --- a/tests/dbal/select_test.php +++ b/tests/dbal/select_test.php @@ -357,4 +357,29 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $this->assertSame(false, $row); } + + public function test_get_row_count() + { + $this->assertSame( + 3, + (int) $this->new_dbal()->get_row_count('phpbb_users'), + "Failed asserting that user table has exactly 3 rows." + ); + } + + public function test_get_estimated_row_count() + { + $actual = $this->new_dbal()->get_estimated_row_count('phpbb_users'); + + if (is_string($actual) && isset($actual[0]) && $actual[0] === '~') + { + $actual = substr($actual, 1); + } + + $this->assertGreaterThan( + 1, + $actual, + "Failed asserting that estimated row count of user table is greater than 1." + ); + } } diff --git a/tests/extension/ext/foo/type/dummy/empty.txt b/tests/extension/ext/foo/type/dummy/empty.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/extension/ext/foo/type/dummy/empty.txt diff --git a/tests/extension/fixtures/extensions.xml b/tests/extension/fixtures/extensions.xml index 65cb71c7a4..6eb6fd11a5 100644 --- a/tests/extension/fixtures/extensions.xml +++ b/tests/extension/fixtures/extensions.xml @@ -3,13 +3,16 @@ <table name="phpbb_ext"> <column>ext_name</column> <column>ext_active</column> + <column>ext_state</column> <row> <value>foo</value> <value>1</value> + <value></value> </row> <row> <value>vendor/moo</value> <value>0</value> + <value></value> </row> </table> </dataset> diff --git a/tests/group_positions/fixtures/group_positions.xml b/tests/group_positions/fixtures/group_positions.xml index 55b1c2e08d..00ea18fe4f 100644 --- a/tests/group_positions/fixtures/group_positions.xml +++ b/tests/group_positions/fixtures/group_positions.xml @@ -4,20 +4,24 @@ <column>group_id</column> <column>group_teampage</column> <column>group_legend</column> + <column>group_desc</column> <row> <value>1</value> <value>0</value> <value>0</value> + <value></value> </row> <row> <value>2</value> <value>1</value> <value>0</value> + <value></value> </row> <row> <value>3</value> <value>2</value> <value>1</value> + <value></value> </row> </table> </dataset> diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index 3a03de6427..6987ae6c73 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -62,15 +62,18 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file); } - protected function setup_engine() + protected function setup_engine(array $new_config = array()) { - global $phpbb_root_path, $phpEx, $config, $user; + global $phpbb_root_path, $phpEx, $user; + + $defaults = $this->config_defaults(); + $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . '/templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->template_locator = new phpbb_template_locator(); $this->template_provider = new phpbb_template_path_provider(); $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider); - $this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path); + $this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent'); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 419c90bd2a..76b1af68d8 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -347,6 +347,42 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)"); } + public function test_append_var_without_assign_var() + { + $this->template->set_filenames(array( + 'append_var' => 'variable.html' + )); + + $items = array('This ', 'is ', 'a ', 'test'); + $expecting = implode('', $items); + + foreach ($items as $word) + { + $this->template->append_var('VARIABLE', $word); + } + + $this->assertEquals($expecting, $this->display('append_var')); + } + + public function test_append_var_with_assign_var() + { + $this->template->set_filenames(array( + 'append_var' => 'variable.html' + )); + + $start = 'This '; + $items = array('is ', 'a ', 'test'); + $expecting = $start . implode('', $items); + + $this->template->assign_var('VARIABLE', $start); + foreach ($items as $word) + { + $this->template->append_var('VARIABLE', $word); + } + + $this->assertEquals($expecting, $this->display('append_var')); + } + public function test_php() { $this->setup_engine(array('tpl_allow_php' => true)); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index a78837516b..5b60785fee 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -46,15 +46,20 @@ class phpbb_template_template_test_case extends phpbb_test_case return str_replace("\n\n", "\n", implode("\n", array_map('trim', explode("\n", trim($result))))); } - protected function setup_engine(array $new_config = array()) + protected function config_defaults() { - global $phpbb_root_path, $phpEx, $user; - $defaults = array( 'load_tplcompile' => true, 'tpl_allow_php' => false, ); + return $defaults; + } + + protected function setup_engine(array $new_config = array()) + { + global $phpbb_root_path, $phpEx, $user; + $defaults = $this->config_defaults(); $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . '/templates'; diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ca52d24b7e..b5e6f7e377 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -102,8 +102,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'admin_name' => 'admin', 'admin_pass1' => 'admin', 'admin_pass2' => 'admin', - 'board_email1' => 'nobody@example.com', - 'board_email2' => 'nobody@example.com', + 'board_email' => 'nobody@example.com', )); $parseURL = parse_url(self::$config['phpbb_functional_url']); |