aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-12-07 13:32:19 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-12-07 13:32:19 +0100
commit47ea6bc9e61c71f6d54df848b6c61ace052d9e2a (patch)
tree9a4181d1c3c2d045abc1575634480d2ab5b1a634 /tests
parentf32a30eecacba212850a11b7b4740d0a69bd49de (diff)
parent71169de8230812f2d05b87bfba42331e04663b81 (diff)
downloadforums-47ea6bc9e61c71f6d54df848b6c61ace052d9e2a.tar
forums-47ea6bc9e61c71f6d54df848b6c61ace052d9e2a.tar.gz
forums-47ea6bc9e61c71f6d54df848b6c61ace052d9e2a.tar.bz2
forums-47ea6bc9e61c71f6d54df848b6c61ace052d9e2a.tar.xz
forums-47ea6bc9e61c71f6d54df848b6c61ace052d9e2a.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb into ticket/11997
Conflicts: tests/functional/fixtures/ext/foo/bar/config/services.yml
Diffstat (limited to 'tests')
-rw-r--r--tests/auth/provider_apache_test.php3
-rw-r--r--tests/auth/provider_db_test.php3
-rw-r--r--tests/avatar/manager_test.php68
-rw-r--r--tests/functional/avatar_acp_groups_test.php9
-rw-r--r--tests/functional/extension_acp_test.php21
-rw-r--r--tests/functional/extension_controller_test.php2
-rw-r--r--tests/functional/extension_global_lang_test.php3
-rw-r--r--tests/functional/extension_module_test.php45
-rw-r--r--tests/functional/extension_permission_lang_test.php3
-rw-r--r--tests/functional/fixtures/ext/foo/bar/composer.json2
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/services.yml9
-rw-r--r--tests/functional/fixtures/ext/foo/bar/event/permission.php9
-rw-r--r--tests/functional/fixtures/ext/foo/bar/event/user_setup.php9
-rw-r--r--tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html3
-rw-r--r--tests/functional/fixtures/ext/foo/bar/ucp/main_info.php26
-rw-r--r--tests/functional/fixtures/ext/foo/bar/ucp/main_module.php22
-rw-r--r--tests/functional/group_create_test.php31
-rw-r--r--tests/functional/notification_test.php33
-rw-r--r--tests/functions/obtain_online_test.php3
-rw-r--r--tests/functions/validate_password_test.php1
-rw-r--r--tests/functions_acp/build_cfg_template_test.php50
-rw-r--r--tests/functions_acp/build_select_test.php14
-rw-r--r--tests/functions_acp/h_radio_test.php14
-rw-r--r--tests/functions_acp/validate_config_vars_test.php19
-rw-r--r--tests/functions_acp/validate_range_test.php26
-rw-r--r--tests/functions_install/ignore_new_file_on_update_test.php41
-rw-r--r--tests/functions_user/group_user_attributes_test.php13
-rw-r--r--tests/lint_test.php6
-rw-r--r--tests/mimetype/fixtures/jpgbin0 -> 519 bytes
-rw-r--r--tests/mimetype/guesser_test.php166
-rw-r--r--tests/mimetype/incorrect_guesser.php18
-rw-r--r--tests/mimetype/null_guesser.php30
-rw-r--r--tests/notification/base.php1
-rw-r--r--tests/notification/submit_post_base.php4
-rw-r--r--tests/regex/password_complexity_test.php1
-rw-r--r--tests/template/template_test.php10
-rw-r--r--tests/template/templates/define.html6
-rw-r--r--tests/template/templates/define_error.html2
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php26
-rw-r--r--tests/text_processing/generate_text_for_display_test.php4
-rw-r--r--tests/user/lang_test.php2
41 files changed, 650 insertions, 108 deletions
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index e135a1f002..d7509a72bf 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -7,7 +7,8 @@
*
*/
-require_once dirname(__FILE__).'/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_auth_provider_apache_test extends phpbb_database_test_case
{
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index 140a28cd3d..45a893220b 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -7,7 +7,8 @@
*
*/
-require_once dirname(__FILE__).'/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_auth_provider_db_test extends phpbb_database_test_case
{
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 0db3f13617..527bb223d5 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -152,12 +152,24 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
return array(
array(
array(
- 'user_avatar' => '',
- 'user_avatar_type' => '',
- 'user_avatar_width' => '',
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
'user_avatar_height' => '',
+ 'group_avatar' => '',
),
array(
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
+ 'user_avatar_height' => '',
+ 'group_avatar' => '',
+ ),
+ 'foobar',
+ ),
+ array(
+ array(),
+ array(
'avatar' => '',
'avatar_type' => '',
'avatar_width' => '',
@@ -166,40 +178,41 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
),
array(
array(
- 'group_avatar' => '',
- 'group_avatar_type' => '',
- 'group_avatar_width' => '',
- 'group_avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
),
array(
- array(),
array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
+ ),
+ array(
+ 'avatar' => '',
+ 'id' => 5,
+ 'group_id' => 4,
),
+ 'user',
),
array(
array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
+ 'group_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
+ 'avatar' => '',
+ 'id' => 'g4',
+ 'user_id' => 5,
),
+ 'group',
),
);
}
@@ -207,14 +220,15 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
/**
* @dataProvider database_row_data
*/
- public function test_clean_row(array $input, array $output)
+ public function test_clean_row(array $input, array $output, $prefix = '')
{
$cleaned_row = array();
- $cleaned_row = \phpbb\avatar\manager::clean_row($input);
- foreach ($output as $key => $null)
+ $cleaned_row = \phpbb\avatar\manager::clean_row($input, $prefix);
+ foreach ($output as $key => $value)
{
$this->assertArrayHasKey($key, $cleaned_row);
+ $this->assertEquals($cleaned_row[$key], $value);
}
}
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php
index 5e908bc6da..5f767b44f2 100644
--- a/tests/functional/avatar_acp_groups_test.php
+++ b/tests/functional/avatar_acp_groups_test.php
@@ -69,4 +69,13 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
{
$this->assert_avatar_submit($expected, $avatar_type, $data);
}
+
+ // Test if avatar was really deleted
+ public function test_no_avatar_acp_groups()
+ {
+ $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $form_data = $form->getValues();
+ $this->assertEmpty($form_data['avatar_type']);
+ }
}
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 44bb895f67..5d391e42f7 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -182,13 +182,34 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_actions()
{
+ // Access enable page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
+
+ // Correctly submit the enable form
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $form = $crawler->selectButton('enable')->form();
+ $crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text());
+ // Access disable page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
+
+ // Correctly submit the disable form
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $form = $crawler->selectButton('disable')->form();
+ $crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text());
+ // Access delete_data page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
+
+ // Correctly submit the delete data form
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $form = $crawler->selectButton('delete_data')->form();
+ $crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text());
}
}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index fe21ec5bd8..ab90223c48 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -19,6 +19,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
static protected $fixtures = array(
'foo/bar/config/',
'foo/bar/controller/',
+ 'foo/bar/event/',
+ 'foo/bar/language/en/',
'foo/bar/styles/prosilver/template/',
);
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index fb8f87e6de..094eda8257 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -17,8 +17,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
static private $helper;
static protected $fixtures = array(
- 'foo/bar/language/en/',
+ 'foo/bar/config/',
'foo/bar/event/',
+ 'foo/bar/language/en/',
);
static public function setUpBeforeClass()
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index 090cd38daf..ba025d582e 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -80,18 +80,53 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
);
$modules->update_module_data($module_data, true);
+ $parent_data = array(
+ 'module_basename' => '',
+ 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'parent_id' => 0,
+ 'module_class' => 'ucp',
+ 'module_langname' => 'UCP_FOOBAR_TITLE',
+ 'module_mode' => '',
+ 'module_auth' => '',
+ );
+ $modules->update_module_data($parent_data, true);
+
+ $module_data = array(
+ 'module_basename' => 'foo\\bar\\ucp\\main_module',
+ 'module_enabled' => 1,
+ 'module_display' => 1,
+ 'parent_id' => $parent_data['module_id'],
+ 'module_class' => 'ucp',
+ 'module_langname' => 'UCP_FOOBAR_TITLE',
+ 'module_mode' => 'mode',
+ 'module_auth' => '',
+ );
+ $modules->update_module_data($module_data, true);
+
$this->purge_cache();
}
- /**
- * Check a controller for extension foo/bar.
- */
- public function test_foo_bar()
+ public function test_acp()
{
$this->login();
$this->admin_login();
+
$crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid);
- $this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
+ $this->assertContains('Bertie rulez!', $crawler->filter('#main')->text());
+ }
+
+ public function test_ucp()
+ {
+ $this->login();
+
+ $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid);
+ $this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text());
+
+ $link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri();
+ $crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
+ $this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text());
+
$this->phpbb_extension_manager->purge('foo/bar');
}
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 19adb89819..e922abdaf1 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -17,8 +17,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
static private $helper;
static protected $fixtures = array(
- 'foo/bar/language/en/',
+ 'foo/bar/config/',
'foo/bar/event/',
+ 'foo/bar/language/en/',
);
static public function setUpBeforeClass()
diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json
index cb9dbc9514..e3e5fc21cd 100644
--- a/tests/functional/fixtures/ext/foo/bar/composer.json
+++ b/tests/functional/fixtures/ext/foo/bar/composer.json
@@ -14,7 +14,7 @@
}],
"require": {
"php": ">=5.3",
- "phpbb": "3.1.*@dev"
+ "phpbb/phpbb": "3.1.*@dev"
},
"extra": {
"display-name": "phpBB 3.1 Extension Testing"
diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml
index d7012dee1c..13aadf9768 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/services.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -6,3 +6,12 @@ services:
- @template
- %core.root_path%
- %core.php_ext%
+
+ foo_bar.listener.permission:
+ class: foo\bar\event\permission
+ tags:
+ - { name: event.listener }
+ foo_bar.listener.user_setup:
+ class: foo\bar\event\user_setup
+ tags:
+ - { name: event.listener }
diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php
index 92e24074ad..9b319dd35f 100644
--- a/tests/functional/fixtures/ext/foo/bar/event/permission.php
+++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php
@@ -11,15 +11,6 @@
namespace foo\bar\event;
/**
-* @ignore
-*/
-
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Event listener
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
index 1409f97470..8fa7ac97da 100644
--- a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
+++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
@@ -11,15 +11,6 @@
namespace foo\bar\event;
/**
-* @ignore
-*/
-
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Event listener
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html
new file mode 100644
index 0000000000..cbded623f4
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html
@@ -0,0 +1,3 @@
+<!-- INCLUDE overall_header.html -->
+<div id="content">UCP Extension Template Test Passed!</div>
+<!-- INCLUDE overall_footer.html -->
diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
new file mode 100644
index 0000000000..2ba37f3050
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace foo\bar\ucp;
+
+class main_info
+{
+ function module()
+ {
+ return array(
+ 'filename' => '\foo\bar\ucp\main_module',
+ 'title' => 'ACP_FOOBAR_TITLE',
+ 'version' => '1.0.0',
+ 'modes' => array(
+ 'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
+ ),
+ );
+ }
+}
diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php
new file mode 100644
index 0000000000..cd3dacc9db
--- /dev/null
+++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace foo\bar\ucp;
+
+class main_module
+{
+ var $u_action;
+
+ function main($id, $mode)
+ {
+ $this->tpl_name = 'foobar';
+ $this->page_title = 'Bertie';
+ }
+}
diff --git a/tests/functional/group_create_test.php b/tests/functional/group_create_test.php
new file mode 100644
index 0000000000..96780069f7
--- /dev/null
+++ b/tests/functional/group_create_test.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_group_create_test extends phpbb_functional_test_case
+{
+
+ public function test_create_group()
+ {
+ $this->login();
+ $this->admin_login();
+ $this->add_lang('acp/groups');
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid);
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, array('group_name' => 'testtest'));
+
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, array('group_name' => 'testtest'));
+
+ $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text());
+ }
+}
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index 7f33ad1859..dd1b8ec981 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -52,4 +52,37 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
$this->assert_checkbox_is_unchecked($cplist, $checkbox_name);
}
}
+
+ public function test_mark_notifications_read()
+ {
+ // Create a new standard user
+ $this->create_user('notificationtestuser');
+ $this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
+ $this->login('notificationtestuser');
+ $crawler = self::request('GET', 'index.php');
+ $this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text());
+
+ // Post a new post that needs approval
+ $this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
+ $crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
+ $this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
+
+ // logout
+ $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
+
+ // admin login
+ $this->login();
+ $this->add_lang('ucp');
+ $crawler = self::request('GET', 'ucp.php?i=ucp_notifications');
+
+ // At least one notification should exist
+ $this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text());
+
+ // Get form token
+ $link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri();
+ $crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
+ $form = $crawler->selectButton($this->lang('YES'))->form();
+ $crawler = self::submit($form);
+ $this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
+ }
}
diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php
index 624e05f77f..cf42fd5b58 100644
--- a/tests/functions/obtain_online_test.php
+++ b/tests/functions/obtain_online_test.php
@@ -21,8 +21,9 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
{
parent::setUp();
- global $config, $db;
+ global $config, $db, $user;
+ $user = new StdClass;
$db = $this->db = $this->new_dbal();
$config = array(
'load_online_time' => 5,
diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php
index 4639f6cc89..82c5fa03c1 100644
--- a/tests/functions/validate_password_test.php
+++ b/tests/functions/validate_password_test.php
@@ -7,6 +7,7 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
require_once dirname(__FILE__) . '/validate_data_helper.php';
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
index acf4da1bd6..7f8db799c5 100644
--- a/tests/functions_acp/build_cfg_template_test.php
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -234,4 +234,54 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
}
+
+ public function build_cfg_template_select_data()
+ {
+ return array(
+ array(
+ array('select'),
+ 'key_name',
+ array('config_key_name' => '0'),
+ 'config_key_name',
+ array('method' => 'select_helper'),
+ '<select id="key_name" name="config[config_key_name]"><option value="1">First_Option</option><option value="2" selected="selected">Second_Option</option><option value="3">Third_Option</option></select>',
+ ),
+ array(
+ array('select', 8),
+ 'key_name',
+ array('config_key_name' => '1'),
+ 'config_key_name',
+ array('method' => 'select_helper'),
+ '<select id="key_name" name="config[config_key_name]" size="8"><option value="1">First_Option</option><option value="2" selected="selected">Second_Option</option><option value="3">Third_Option</option></select>',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider build_cfg_template_select_data
+ */
+ public function test_build_cfg_template_select($tpl_type, $key, $new, $config_key, $vars, $expected)
+ {
+ global $module, $user, $phpbb_dispatcher;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ $user->module = $this;
+ $module = $user;
+
+ $this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
+ }
+
+ public function select_helper()
+ {
+ return build_select(
+ array(
+ '1' => 'First_Option',
+ '2' => 'Second_Option',
+ '3' => 'Third_Option',
+ ),
+ '2'
+ );
+ }
}
diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php
index aca49b7655..c44fd97ec3 100644
--- a/tests/functions_acp/build_select_test.php
+++ b/tests/functions_acp/build_select_test.php
@@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_built_select_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
public function build_select_data()
{
return array(
@@ -46,10 +56,6 @@ class phpbb_functions_acp_built_select_test extends phpbb_test_case
*/
public function test_build_select($option_ary, $option_default, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$this->assertEquals($expected, build_select($option_ary, $option_default));
}
}
diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php
index a61f2e8975..4c1872d341 100644
--- a/tests/functions_acp/h_radio_test.php
+++ b/tests/functions_acp/h_radio_test.php
@@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_h_radio_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
public function h_radio_data()
{
return array(
@@ -111,10 +121,6 @@ class phpbb_functions_acp_h_radio_test extends phpbb_test_case
*/
public function test_h_radio($name, $input_ary, $input_default, $id, $key, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$this->assertEquals($expected, h_radio($name, $input_ary, $input_default, $id, $key));
}
}
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 7cd7fa3892..acc98fbf0d 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -8,9 +8,20 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
/**
* Data sets that don't throw an error.
*/
@@ -60,10 +71,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
*/
public function test_validate_config_vars_fit($test_data, $cfg_array)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_config_vars($test_data, $cfg_array, $phpbb_error);
@@ -146,10 +153,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
*/
public function test_validate_config_vars_error($test_data, $cfg_array, $expected)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_config_vars($test_data, $cfg_array, $phpbb_error);
diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php
index 8606158251..cb028d4d07 100644
--- a/tests/functions_acp/validate_range_test.php
+++ b/tests/functions_acp/validate_range_test.php
@@ -12,6 +12,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_validate_range_test extends phpbb_test_case
{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $user;
+
+ $user = new phpbb_mock_user();
+ $user->lang = new phpbb_mock_lang();
+ }
+
/**
* Data sets that don't throw an error.
*/
@@ -52,10 +62,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_fit($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -91,10 +97,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_low($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -130,10 +132,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_big($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
@@ -158,10 +156,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case
*/
public function test_validate_range_too_long($test_data)
{
- global $user;
-
- $user->lang = new phpbb_mock_lang();
-
$phpbb_error = array();
validate_range($test_data, $phpbb_error);
diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php
new file mode 100644
index 0000000000..703da4e435
--- /dev/null
+++ b/tests/functions_install/ignore_new_file_on_update_test.php
@@ -0,0 +1,41 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php';
+
+class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_case
+{
+ static public function ignore_new_file_on_update_data()
+ {
+ return array(
+ array('willneverexist.php', false),
+ array('includes/dirwillneverexist/newfile.php', false),
+
+ array('language/en/email/short/bookmark.txt', false),
+ array('language/languagewillneverexist/email/short/bookmark.txt', true),
+
+ array('styles/prosilver/template/bbcode.html', false),
+ array('styles/stylewillneverexist/template/bbcode.html', true),
+
+ array('styles/prosilver/theme/en/icon_user_online.gif', false),
+ array('styles/prosilver/theme/languagewillneverexist/icon_user_online.gif', true),
+
+ array('styles/prosilver/theme/imageset.css', false),
+ );
+ }
+
+ /**
+ * @dataProvider ignore_new_file_on_update_data
+ */
+ public function test_ignore_new_file_on_update($file, $expected)
+ {
+ global $phpbb_root_path;
+ $this->assertEquals($expected, phpbb_ignore_new_file_on_update($phpbb_root_path, $file));
+ }
+}
diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php
index f8d52a9a6a..86e4767970 100644
--- a/tests/functions_user/group_user_attributes_test.php
+++ b/tests/functions_user/group_user_attributes_test.php
@@ -27,7 +27,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
2,
array(
'group_avatar' => '',
- 'group_avatar_type' => 0,
+ 'group_avatar_type' => '',
'group_avatar_height' => 0,
'group_avatar_width' => 0,
'group_rank' => 0,
@@ -43,7 +43,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
2,
array(
'group_avatar' => '',
- 'group_avatar_type' => 0,
+ 'group_avatar_type' => '',
'group_avatar_height' => 0,
'group_avatar_width' => 0,
'group_rank' => 0,
@@ -59,7 +59,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
2,
array(
'group_avatar' => '',
- 'group_avatar_type' => 0,
+ 'group_avatar_type' => '',
'group_avatar_height' => 0,
'group_avatar_width' => 0,
'group_rank' => 0,
@@ -75,7 +75,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
3,
array(
'group_avatar' => 'default2',
- 'group_avatar_type' => 1,
+ 'group_avatar_type' => 'avatar.driver.upload',
'group_avatar_height' => 1,
'group_avatar_width' => 1,
'group_rank' => 3,
@@ -91,7 +91,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
3,
array(
'group_avatar' => 'default2',
- 'group_avatar_type' => 1,
+ 'group_avatar_type' => 'avatar.driver.upload',
'group_avatar_height' => 1,
'group_avatar_width' => 1,
'group_rank' => 3,
@@ -107,7 +107,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
3,
array(
'group_avatar' => 'default2',
- 'group_avatar_type' => 1,
+ 'group_avatar_type' => 'avatar.driver.upload',
'group_avatar_height' => 1,
'group_avatar_width' => 1,
'group_rank' => 3,
@@ -127,6 +127,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
{
global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container, $phpbb_log, $phpbb_root_path, $phpEx;
+ $user = new phpbb_mock_user;
$user->ip = '';
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
diff --git a/tests/lint_test.php b/tests/lint_test.php
index 905067072d..eba117839b 100644
--- a/tests/lint_test.php
+++ b/tests/lint_test.php
@@ -23,6 +23,10 @@ class phpbb_lint_test extends phpbb_test_case
}
self::$exclude = array(
+ dirname(__FILE__) . '/../.git',
+ dirname(__FILE__) . '/../build/new_version',
+ dirname(__FILE__) . '/../build/old_versions',
+ dirname(__FILE__) . '/../phpBB/cache',
// PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20
// https://gist.github.com/e003913ffd493da63cbc
dirname(__FILE__) . '/../phpBB/vendor',
@@ -45,7 +49,7 @@ class phpbb_lint_test extends phpbb_test_case
$dh = opendir($root);
while (($filename = readdir($dh)) !== false)
{
- if ($filename == '.' || $filename == '..' || $filename == 'git')
+ if ($filename == '.' || $filename == '..')
{
continue;
}
diff --git a/tests/mimetype/fixtures/jpg b/tests/mimetype/fixtures/jpg
new file mode 100644
index 0000000000..3cd5038e38
--- /dev/null
+++ b/tests/mimetype/fixtures/jpg
Binary files differ
diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php
new file mode 100644
index 0000000000..9f0371262b
--- /dev/null
+++ b/tests/mimetype/guesser_test.php
@@ -0,0 +1,166 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\mimetype;
+
+require_once dirname(__FILE__) . '/null_guesser.php';
+require_once dirname(__FILE__) . '/incorrect_guesser.php';
+
+function function_exists($name)
+{
+ return guesser_test::$function_exists;
+}
+
+class guesser_test extends \phpbb_test_case
+{
+ public static $function_exists = true;
+
+ public function setUp()
+ {
+ global $phpbb_root_path;
+
+ $guessers = array(
+ new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser(),
+ new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser(),
+ );
+ $this->guesser = new \phpbb\mimetype\guesser($guessers);
+ $this->path = dirname(__FILE__);
+ $this->jpg_file = $this->path . '/fixtures/jpg';
+ $this->phpbb_root_path = $phpbb_root_path;
+ }
+
+ public function data_guess_files()
+ {
+ return array(
+ array('image/gif', 'gif'),
+ array('image/png', 'png'),
+ array('image/jpeg', 'jpg'),
+ array('image/tiff', 'tif'),
+ array('text/html', 'txt'),
+ array(false, 'foobar'),
+ );
+ }
+
+ /**
+ * @dataProvider data_guess_files
+ */
+ public function test_guess_files($expected, $file)
+ {
+ $this->assertEquals($expected, $this->guesser->guess($this->path . '/../upload/fixture/' . $file));
+ }
+
+ public function test_file_not_readable()
+ {
+ @chmod($this->jpg_file, 0000);
+ if (is_readable($this->jpg_file))
+ {
+ @chmod($this->jpg_file, 0644);
+ $this->markTestSkipped('is_readable always returns true if user is superuser or chmod does not work');
+ }
+ $this->assertEquals(false, $this->guesser->guess($this->jpg_file));
+ @chmod($this->jpg_file, 0644);
+ $this->assertEquals('image/jpeg', $this->guesser->guess($this->jpg_file));
+ }
+
+ public function test_null_guess()
+ {
+ $guesser = new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\null_guesser));
+ $this->assertEquals('application/octet-stream', $guesser->guess($this->jpg_file));
+ }
+
+ public function data_incorrect_guessers()
+ {
+ return array(
+ array(array(new \phpbb\mimetype\incorrect_guesser)),
+ array(array(new \phpbb\mimetype\null_guesser(false))),
+ array(array()),
+ );
+ }
+
+ /**
+ * @dataProvider data_incorrect_guessers
+ *
+ * @expectedException \LogicException
+ */
+ public function test_incorrect_guesser($guessers)
+ {
+ $guesser = new \phpbb\mimetype\guesser($guessers);
+ }
+
+ public function data_content_guesser()
+ {
+ return array(
+ array(
+ array(
+ 'image/jpeg',
+ 'image/jpeg',
+ ),
+ array(new \phpbb\mimetype\content_guesser),
+ false,
+ ),
+ array(
+ array(
+ 'application/octet-stream',
+ 'application/octet-stream',
+ ),
+ array(new \phpbb\mimetype\content_guesser),
+ true,
+ ),
+ array(
+ array(
+ 'application/octet-stream',
+ 'image/jpeg',
+ ),
+ array(new \phpbb\mimetype\extension_guesser),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider data_content_guesser
+ */
+ public function test_content_guesser($expected, $guessers, $overload = false)
+ {
+ $supported = false;
+ self::$function_exists = !$overload;
+
+ // Cover possible LogicExceptions
+ foreach ($guessers as $cur_guesser)
+ {
+ $supported += $cur_guesser->is_supported();
+ }
+
+ if (!$supported)
+ {
+ $this->setExpectedException('\LogicException');
+ }
+
+ $guesser = new \phpbb\mimetype\guesser($guessers);
+ $this->assertEquals($expected[0], $guesser->guess($this->jpg_file));
+ $this->assertEquals($expected[1], $guesser->guess($this->jpg_file, $this->jpg_file . '.jpg'));
+ @copy($this->jpg_file, $this->jpg_file . '.jpg');
+ $this->assertEquals($expected[1], $guesser->guess($this->jpg_file . '.jpg'));
+ @unlink($this->jpg_file . '.jpg');
+ }
+
+ public function test_sort_priority()
+ {
+ $guessers = array(
+ 'FileinfoMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileinfoMimeTypeGuesser,
+ 'extension_guesser' => new \phpbb\mimetype\extension_guesser,
+ 'FileBinaryMimeTypeGuesser' => new \Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser,
+ 'content_guesser' => new \phpbb\mimetype\content_guesser,
+ );
+ $guessers['content_guesser']->set_priority(5);
+ $guessers['extension_guesser']->set_priority(-5);
+ usort($guessers, array($this->guesser, 'sort_priority'));
+ $this->assertInstanceOf('\phpbb\mimetype\content_guesser', $guessers[0]);
+ $this->assertInstanceOf('\phpbb\mimetype\extension_guesser', $guessers[3]);
+ }
+}
diff --git a/tests/mimetype/incorrect_guesser.php b/tests/mimetype/incorrect_guesser.php
new file mode 100644
index 0000000000..3939826faa
--- /dev/null
+++ b/tests/mimetype/incorrect_guesser.php
@@ -0,0 +1,18 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\mimetype;
+
+class incorrect_guesser
+{
+ public function guess($file)
+ {
+ return 'image/jpeg';
+ }
+}
diff --git a/tests/mimetype/null_guesser.php b/tests/mimetype/null_guesser.php
new file mode 100644
index 0000000000..5316d3726f
--- /dev/null
+++ b/tests/mimetype/null_guesser.php
@@ -0,0 +1,30 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+namespace phpbb\mimetype;
+
+class null_guesser
+{
+ protected $is_supported;
+
+ public function __construct($is_supported = true)
+ {
+ $this->is_supported = $is_supported;
+ }
+
+ public function is_supported()
+ {
+ return $this->is_supported;
+ }
+
+ public function guess($file)
+ {
+ return null;
+ }
+}
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 549545f01b..f6333866c3 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -70,6 +70,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
array(),
$this->container,
$this->user_loader,
+ $this->config,
$this->db,
$this->cache,
$this->user,
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 8597c626a4..fb8e2ac807 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
-class phpbb_notification_submit_post_base extends phpbb_database_test_case
+abstract class phpbb_notification_submit_post_base extends phpbb_database_test_case
{
protected $notifications, $db, $container, $user, $config, $auth, $cache;
@@ -118,7 +118,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
- $phpbb_container, $user_loader, $db, $cache, $user,
+ $phpbb_container, $user_loader, $config, $db, $cache, $user,
$phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php
index 07453555ee..e2aefdaac8 100644
--- a/tests/regex/password_complexity_test.php
+++ b/tests/regex/password_complexity_test.php
@@ -7,6 +7,7 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
class phpbb_password_complexity_test extends phpbb_test_case
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 39eb08ab79..6e9b7d3ee9 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -158,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
array(),
- "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|",
+ "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|false",
),
array(
'define_advanced.html',
@@ -561,4 +561,12 @@ EOT
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
}
+
+ /**
+ * @expectedException Twig_Error_Syntax
+ */
+ public function test_define_error()
+ {
+ $this->run_template('define_error.html', array(), array(), array(), '');
+ }
}
diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html
index e7ce7f7def..276d2ebb99 100644
--- a/tests/template/templates/define.html
+++ b/tests/template/templates/define.html
@@ -29,3 +29,9 @@ $VALUE == 'abc'
<!-- DEFINE $VALUE = '' -->
[{$VALUE}]
<!-- DEFINE $TEST -->foobar<!-- ENDDEFINE -->|{$TEST}|
+<!-- DEFINE $VAR = false -->
+<!-- IF $VAR -->
+true
+<!-- ELSE -->
+false
+<!-- ENDIF -->
diff --git a/tests/template/templates/define_error.html b/tests/template/templates/define_error.html
new file mode 100644
index 0000000000..72ab1ba033
--- /dev/null
+++ b/tests/template/templates/define_error.html
@@ -0,0 +1,2 @@
+<!-- DEFINE $VAR = foo -->
+{$VAR}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index a0d186e0f2..eba5a2dfdf 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $subject
* @param string $message
* @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
+ public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
{
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
@@ -880,7 +881,7 @@ class phpbb_functional_test_case extends phpbb_test_case
'post' => true,
), $additional_form_data);
- return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
+ return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected);
}
/**
@@ -893,9 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $subject
* @param string $message
* @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
+ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
{
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
@@ -905,7 +907,7 @@ class phpbb_functional_test_case extends phpbb_test_case
'post' => true,
), $additional_form_data);
- return self::submit_post($posting_url, 'POST_REPLY', $form_data);
+ return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected);
}
/**
@@ -914,9 +916,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $posting_url
* @param string $posting_contains
* @param array $form_data
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- protected function submit_post($posting_url, $posting_contains, $form_data)
+ protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED')
{
$this->add_lang('posting');
@@ -945,7 +948,12 @@ class phpbb_functional_test_case extends phpbb_test_case
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
// Instead, I send it as a request with the submit button "post" set to true.
$crawler = self::request('POST', $posting_url, $form_data);
- $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
+ $this->assertContainsLang($expected, $crawler->filter('html')->text());
+
+ if ($expected !== 'POST_STORED')
+ {
+ return;
+ }
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
return array(
diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php
index a157fe7d9a..15905535ac 100644
--- a/tests/text_processing/generate_text_for_display_test.php
+++ b/tests/text_processing/generate_text_for_display_test.php
@@ -16,7 +16,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
{
public function setUp()
{
- global $cache, $user;
+ global $cache, $user, $phpbb_dispatcher;
parent::setUp();
@@ -24,6 +24,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$user = new phpbb_mock_user;
$user->optionset('viewcensors', false);
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
}
public function test_empty_string()
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
index c7c858c59d..9cb9e320b3 100644
--- a/tests/user/lang_test.php
+++ b/tests/user/lang_test.php
@@ -7,6 +7,8 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
class phpbb_user_lang_test extends phpbb_test_case
{
public function test_user_lang_sprintf()