aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dbal/order_lower_test.php2
-rw-r--r--tests/dbal/select_test.php4
-rw-r--r--tests/dbal/sql_insert_buffer_test.php8
-rw-r--r--tests/extension/ext/barfoo/composer.json8
-rw-r--r--tests/extension/ext/vendor/moo/composer.json8
-rw-r--r--tests/extension/ext/vendor2/bar/composer.json8
-rw-r--r--tests/extension/ext/vendor2/foo/composer.json8
-rw-r--r--tests/extension/manager_test.php46
-rw-r--r--tests/extension/metadata_manager_test.php324
-rw-r--r--tests/functional/download_test.php6
-rw-r--r--tests/functional/feed_test.php6
-rw-r--r--tests/functional/fixtures/ext/foo/bar/composer.json8
-rw-r--r--tests/functional/jumpbox_test.php20
-rw-r--r--tests/functional/mcp_test.php6
-rw-r--r--tests/functional/visibility_softdelete_test.php40
-rw-r--r--tests/functions/obtain_online_test.php8
-rw-r--r--tests/functions_content/get_username_string_test.php14
-rw-r--r--tests/log/function_view_log_test.php26
-rw-r--r--tests/notification/user_list_trim_test.php8
-rw-r--r--tests/profilefields/type_bool_test.php56
-rw-r--r--tests/profilefields/type_date_test.php36
-rw-r--r--tests/profilefields/type_dropdown_test.php48
-rw-r--r--tests/profilefields/type_int_test.php60
-rw-r--r--tests/profilefields/type_string_test.php54
-rw-r--r--tests/profilefields/type_url_test.php30
-rw-r--r--tests/template/template_test.php7
-rw-r--r--tests/template/templates/if_nested_tags.html1
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php27
-rw-r--r--tests/viewonline/helper_test.php42
29 files changed, 583 insertions, 336 deletions
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php
index b7a69c7c5d..b101d28c7d 100644
--- a/tests/dbal/order_lower_test.php
+++ b/tests/dbal/order_lower_test.php
@@ -22,7 +22,7 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
- if (strpos($db->sql_layer, 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
+ if (strpos($db->get_sql_layer(), 'mysql') === 0 && version_compare($db->sql_server_info(true, false), '5.6', '>='))
{
$this->markTestSkipped('MySQL 5.6 fails to order things correctly. See also: http://tracker.phpbb.com/browse/PHPBB3-11571 http://bugs.mysql.com/bug.php?id=69005');
}
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index 7cac4d6a3b..e480716a49 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -219,8 +219,8 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
{
$db = $this->new_dbal();
- $like_expression = str_replace('*', $db->any_char, $like_expression);
- $like_expression = str_replace('#', $db->one_char, $like_expression);
+ $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
+ $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
$where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : '';
$result = $db->sql_query('SELECT username_clean
diff --git a/tests/dbal/sql_insert_buffer_test.php b/tests/dbal/sql_insert_buffer_test.php
index 2f9ed0008f..eae0abceba 100644
--- a/tests/dbal/sql_insert_buffer_test.php
+++ b/tests/dbal/sql_insert_buffer_test.php
@@ -32,7 +32,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_and_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3);
$this->assertFalse($this->buffer->flush());
@@ -50,7 +50,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_with_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert($this->get_row(1)));
$this->assert_config_count(3);
$this->assertTrue($this->buffer->insert($this->get_row(2)));
@@ -68,7 +68,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
public function test_multi_insert_disabled_insert_all_and_flush()
{
- $this->db->multi_insert = false;
+ $this->db->set_multi_insert(false);
$this->assertTrue($this->buffer->insert_all($this->get_rows(3)));
$this->assert_config_count(5);
}
@@ -93,7 +93,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case
protected function check_multi_insert_support()
{
- if (!$this->db->multi_insert)
+ if (!$this->db->get_multi_insert())
{
$this->markTestSkipped('Database does not support multi_insert');
}
diff --git a/tests/extension/ext/barfoo/composer.json b/tests/extension/ext/barfoo/composer.json
index d88fd413c9..05bb099707 100644
--- a/tests/extension/ext/barfoo/composer.json
+++ b/tests/extension/ext/barfoo/composer.json
@@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB BarFoo Extension"
+ "display-name": "phpBB BarFoo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json
index b8fc544c01..d49aab47cd 100644
--- a/tests/extension/ext/vendor/moo/composer.json
+++ b/tests/extension/ext/vendor/moo/composer.json
@@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Moo Extension"
+ "display-name": "phpBB Moo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor2/bar/composer.json b/tests/extension/ext/vendor2/bar/composer.json
index 215e7d59db..9d2ed86a0c 100644
--- a/tests/extension/ext/vendor2/bar/composer.json
+++ b/tests/extension/ext/vendor2/bar/composer.json
@@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Bar Extension"
+ "display-name": "phpBB Bar Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor2/foo/composer.json b/tests/extension/ext/vendor2/foo/composer.json
index 7b2a80f5d3..efcdfc338f 100644
--- a/tests/extension/ext/vendor2/foo/composer.json
+++ b/tests/extension/ext/vendor2/foo/composer.json
@@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Foo Extension"
+ "display-name": "phpBB Foo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index d9f8fbd1a4..230c90c7c7 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -32,22 +32,62 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$this->extension_manager = $this->create_extension_manager();
}
- public function test_available()
+ public function test_all_available()
{
// barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure.
$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_available()));
}
- public function test_enabled()
+ public function test_all_enabled()
{
$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));
}
- public function test_configured()
+ public function test_all_configured()
{
$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));
}
+ public function test_is_enabled()
+ {
+ $this->assertSame(true, $this->extension_manager->is_enabled('vendor2/foo'));
+ $this->assertSame(false, $this->extension_manager->is_enabled('vendor/moo'));
+ $this->assertSame(false, $this->extension_manager->is_enabled('vendor2/bar'));
+ $this->assertSame(false, $this->extension_manager->is_enabled('bertie/worlddominationplan'));
+ }
+
+ public function test_is_disabled()
+ {
+ $this->assertSame(false, $this->extension_manager->is_disabled('vendor2/foo'));
+ $this->assertSame(true, $this->extension_manager->is_disabled('vendor/moo'));
+ $this->assertSame(false, $this->extension_manager->is_disabled('vendor2/bar'));
+ $this->assertSame(false, $this->extension_manager->is_disabled('bertie/worlddominationplan'));
+ }
+
+ public function test_is_purged()
+ {
+ $this->assertSame(false, $this->extension_manager->is_purged('vendor2/foo'));
+ $this->assertSame(false, $this->extension_manager->is_purged('vendor/moo'));
+ $this->assertSame(true, $this->extension_manager->is_purged('vendor2/bar'));
+ $this->assertSame(false, $this->extension_manager->is_purged('bertie/worlddominationplan'));
+ }
+
+ public function test_is_configured()
+ {
+ $this->assertSame(true, $this->extension_manager->is_configured('vendor2/foo'));
+ $this->assertSame(true, $this->extension_manager->is_configured('vendor/moo'));
+ $this->assertSame(false, $this->extension_manager->is_configured('vendor2/bar'));
+ $this->assertSame(false, $this->extension_manager->is_configured('bertie/worlddominationplan'));
+ }
+
+ public function test_is_available()
+ {
+ $this->assertSame(true, $this->extension_manager->is_available('vendor2/foo'));
+ $this->assertSame(true, $this->extension_manager->is_available('vendor/moo'));
+ $this->assertSame(true, $this->extension_manager->is_available('vendor2/bar'));
+ $this->assertSame(false, $this->extension_manager->is_available('bertie/worlddominationplan'));
+ }
+
public function test_enable()
{
vendor2\bar\ext::$state = 0;
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 3678ac0a3f..6b6ea80d82 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -19,8 +19,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
protected $cache;
protected $config;
protected $db;
+ protected $db_tools;
+ protected $table_prefix;
protected $phpbb_root_path;
protected $phpEx;
+ protected $migrator;
protected $template;
protected $user;
@@ -70,7 +73,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
- $container->set('migrator', $migrator);
+ $container->set('migrator', $this->migrator);
$this->extension_manager = new \phpbb\extension\manager(
$container,
@@ -96,9 +99,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$manager->get_metadata();
}
- catch(\phpbb\extension\exception $e){}
-
- $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
+ catch (\phpbb\extension\exception $e)
+ {
+ $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
+ }
}
// Should be the same as a direct json_decode of the composer.json file
@@ -112,7 +116,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$metadata = $manager->get_metadata();
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->fail($e);
}
@@ -122,64 +126,42 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->assertEquals($metadata, $json);
}
- public function test_validator_non_existant()
+ public function validator_non_existing_data()
{
- $ext_name = 'validator';
-
- $manager = $this->get_metadata_manager($ext_name);
-
- // Non-existant data
- try
- {
- $manager->validate('name');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'name'));
- }
-
- try
- {
- $manager->validate('type');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'type'));
- }
-
- try
- {
- $manager->validate('license');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'license'));
- }
+ return array(
+ array('name'),
+ array('type'),
+ array('license'),
+ array('version'),
+ );
+ }
+ /**
+ * @dataProvider validator_non_existing_data
+ */
+ public function test_validator_non_existing($field_name)
+ {
+ $manager = $this->get_metadata_manager('validator');
try
{
- $manager->validate('version');
-
+ $manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'version'));
+ $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name));
}
+ }
+ public function test_validator_non_existing_authors()
+ {
+ $manager = $this->get_metadata_manager('validator');
try
{
$manager->validate_authors();
-
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors'));
}
@@ -193,72 +175,44 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
try
{
$manager->validate_authors();
-
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name'));
}
}
-
- public function test_validator_invalid()
+ public function validator_invalid_data()
{
- $ext_name = 'validator';
+ return array(
+ array('name', 'asdf'),
+ array('type', 'asdf'),
+ array('license', ''),
+ array('version', ''),
+ );
+ }
- $manager = $this->get_metadata_manager($ext_name);
+ /**
+ * @dataProvider validator_invalid_data
+ */
+ public function test_validator_invalid($field_name, $field_value)
+ {
+ $manager = $this->get_metadata_manager('validator');
// Invalid data
$manager->set_metadata(array(
- 'name' => 'asdf',
- 'type' => 'asdf',
- 'license' => '',
- 'version' => '',
+ $field_name => $field_value,
));
try
{
- $manager->validate('name');
-
+ $manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'name'));
- }
-
- try
- {
- $manager->validate('type');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'type'));
- }
-
- try
- {
- $manager->validate('license');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'license'));
- }
-
- try
- {
- $manager->validate('version');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'version'));
+ $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name));
}
}
@@ -286,143 +240,83 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
}
-
- public function test_validator_requirements()
+ public function validator_requirements_data()
{
- $ext_name = 'validator';
-
- $manager = $this->get_metadata_manager($ext_name);
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '10.0.0',
- 'phpbb/phpbb' => '3.2.0', // config is set to 3.1.0
+ return array(
+ array(
+ '10.0.0',
+ '100.2.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '5.3.0',
- 'phpbb/phpbb' => '3.1.0-beta', // config is set to 3.1.0
+ array(
+ '5.3.0',
+ '3.1.0-beta',
+ true,
+ true,
),
- ));
-
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '>' . phpversion(),
- 'phpbb/phpbb' => '>3.1.0', // config is set to 3.1.0
+ array(
+ '>' . phpversion(),
+ '>3.1.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of current install
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '<' . phpversion(),
- 'phpbb/phpbb' => '<3.1.0', // config is set to 3.1.0
+ array(
+ '<' . phpversion(),
+ '<3.1.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Matching requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => phpversion(),
- 'phpbb/phpbb' => '3.1.0', // config is set to 3.1.0
+ array(
+ phpversion(),
+ '3.1.0',
+ true,
+ true,
),
- ));
-
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Matching requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '>=' . phpversion(),
- 'phpbb/phpbb' => '>=3.1.0', // config is set to 3.1.0
+ array(
+ '>=' . phpversion(),
+ '>=3.1.0',
+ true,
+ true,
),
- ));
+ array(
+ '<=' . phpversion(),
+ '<=3.1.0',
+ true,
+ true,
+ ),
+ );
+ }
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
+ /**
+ * @dataProvider validator_requirements_data
+ */
+ public function test_validator_requirements($php_version, $phpbb_version, $expected_php, $expected_phpbb, $incomplete_reason = '')
+ {
+ if ($incomplete_reason)
{
- $this->fail($e);
+ $this->markTestIncomplete($incomplete_reason);
}
-
- // Matching requirements
+ $ext_name = 'validator';
+ $manager = $this->get_metadata_manager($ext_name);
+ // Too high of requirements
$manager->merge_metadata(array(
'require' => array(
- 'php' => '<=' . phpversion(),
- 'phpbb/phpbb' => '<=3.1.0', // config is set to 3.1.0
+ 'php' => $php_version,
+ ),
+ 'extra' => array(
+ 'soft-require' => array(
+ 'phpbb/phpbb' => $phpbb_version, // config is set to 3.1.0
+ ),
),
));
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
+ $this->assertEquals($expected_php, $manager->validate_require_php());
+ $this->assertEquals($expected_phpbb, $manager->validate_require_phpbb());
}
/**
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index dbf197fcfa..6a6df14c81 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -205,12 +205,8 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
),
));
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
-
$this->add_lang('posting');
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('delete_topic');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Download Topic #1'], 'DELETE_TOPIC');
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$this->add_lang('mcp');
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index a474ecf27f..7aa2d0da7d 100644
--- a/tests/functional/feed_test.php
+++ b/tests/functional/feed_test.php
@@ -619,12 +619,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
),
));
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}");
-
$this->add_lang('posting');
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('delete_topic');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Feeds #1 - Topic #2'], 'DELETE_TOPIC');
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$this->add_lang('mcp');
diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json
index 2f91426d2a..f0c7f0e6c1 100644
--- a/tests/functional/fixtures/ext/foo/bar/composer.json
+++ b/tests/functional/fixtures/ext/foo/bar/composer.json
@@ -13,10 +13,12 @@
"role": "Developer"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB 3.1 Extension Testing"
+ "display-name": "phpBB 3.1 Extension Testing",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/functional/jumpbox_test.php b/tests/functional/jumpbox_test.php
index 9eddcb6bf6..f5a671b1b9 100644
--- a/tests/functional/jumpbox_test.php
+++ b/tests/functional/jumpbox_test.php
@@ -20,18 +20,16 @@ class phpbb_functional_jumpbox_test extends phpbb_functional_test_case
{
$this->login();
- $crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
- $form = $crawler->filter('#quickmodform')->selectButton($this->lang('GO'))->form(array(
- 'action' => 'merge_topic',
- ));
+ $this->crawler = $this->get_quickmod_page(1, 'MERGE_TOPIC');
+ $this->check_valid_jump('Your first forum');
- $crawler = self::submit($form);
- $this->assertContains($this->lang('FORUM') . ': Your first forum', $crawler->filter('#cp-main h2')->text());
- $form = $crawler->filter('#jumpbox')->selectButton($this->lang('GO'))->form(array(
- 'f' => 1,
- ));
+ $link = $this->crawler->filter('#jumpbox')->selectLink('Your first category')->link()->getUri();
+ $this->crawler = self::request('GET', substr($link, strpos($link, 'mcp.')));
+ $this->check_valid_jump('Your first category');
+ }
- $crawler = self::submit($form);
- $this->assertContains($this->lang('FORUM') . ': Your first category', $crawler->filter('#cp-main h2')->text());
+ protected function check_valid_jump($forum)
+ {
+ $this->assertContains($this->lang('FORUM') . ": $forum", $this->crawler->filter('#cp-main h2')->text(), $this->crawler->text());
}
}
diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php
index e4d950ef34..31d835f4fa 100644
--- a/tests/functional/mcp_test.php
+++ b/tests/functional/mcp_test.php
@@ -35,11 +35,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case
public function test_handle_quickmod($crawler)
{
// Test moving a post
- $form = $crawler->selectButton('Go')->eq(1)->form();
- $form['action']->select('merge');
- $crawler = self::submit($form);
-
- return $crawler;
+ return $this->get_quickmod_page(0, 'MERGE_POSTS', $crawler);
}
/**
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index 5b5f09905c..794f0cde68 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -186,11 +186,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => 0,
), 'before moving #2');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
-
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('move');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #1'], 'MOVE_TOPIC');
$this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text());
$this->add_lang('mcp');
@@ -261,12 +257,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
), 'before softdeleting #2');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
-
$this->add_lang('posting');
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('delete_topic');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #1'], 'DELETE_TOPIC');
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$this->add_lang('mcp');
@@ -336,11 +328,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => 0,
), 'before moving #2');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
-
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('move');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #1'], 'MOVE_TOPIC');
$this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text());
$this->add_lang('mcp');
@@ -484,12 +472,9 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => 0,
), 'before splitting #2');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #1'], 'SPLIT_TOPIC');
$this->add_lang('mcp');
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('split');
- $crawler = self::submit($form);
$this->assertContainsLang('SPLIT_TOPIC_EXPLAIN', $crawler->text());
$form = $crawler->selectButton('Submit')->form(array(
@@ -546,12 +531,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
),
));
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}");
-
- $form = $crawler->selectButton('Go')->eq(1)->form();
- $form['action']->select('move');
- $crawler = self::submit($form);
-
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2'], 'MOVE_TOPIC');
$form = $crawler->selectButton('Yes')->form();
$form['to_forum_id']->select($this->data['forums']['Soft Delete #1']);
$crawler = self::submit($form);
@@ -605,9 +585,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
$this->assertContainsLang('BOOKMARK_ADDED', $crawler_bookmark->text());
$this->add_lang('mcp');
- $form = $crawler->selectButton('Go')->eq(1)->form();
- $form['action']->select('merge_topic');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #2'], 'MERGE_TOPIC', $crawler);
$this->assertContainsLang('SELECT_MERGE', $crawler->text());
$crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}");
@@ -670,12 +648,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
'forum_last_post_id' => 0,
), 'before forking #2');
- $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
-
$this->add_lang('mcp');
- $form = $crawler->selectButton('Go')->eq(2)->form();
- $form['action']->select('fork');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($this->data['topics']['Soft Delete Topic #1'], 'FORK_TOPIC');
$this->assertContainsLang('FORK_TOPIC', $crawler->text());
$form = $crawler->selectButton('Yes')->form();
diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php
index 830b52fb4c..e793a4eb82 100644
--- a/tests/functions/obtain_online_test.php
+++ b/tests/functions/obtain_online_test.php
@@ -128,19 +128,19 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
{
return array(
array(0, false, array(
- 'online_userlist' => 'REGISTERED_USERS 2, 3',
+ 'online_userlist' => 'REGISTERED_USERS <span class="username">2</span>, <span class="username">3</span>',
'l_online_users' => 'ONLINE_USERS_TOTAL 5 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 3',
)),
array(0, true, array(
- 'online_userlist' => 'REGISTERED_USERS 2, 3',
+ 'online_userlist' => 'REGISTERED_USERS <span class="username">2</span>, <span class="username">3</span>',
'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 7 REG_USERS_TOTAL 2 HIDDEN_USERS_TOTAL 3 GUEST_USERS_TOTAL 2',
)),
array(1, false, array(
- 'online_userlist' => 'BROWSING_FORUM 3',
+ 'online_userlist' => 'BROWSING_FORUM <span class="username">3</span>',
'l_online_users' => 'ONLINE_USERS_TOTAL 2 REG_USERS_TOTAL 1 HIDDEN_USERS_TOTAL 1',
)),
array(1, true, array(
- 'online_userlist' => 'BROWSING_FORUM_GUESTS 1 3',
+ 'online_userlist' => 'BROWSING_FORUM_GUESTS 1 <span class="username">3</span>',
'l_online_users' => 'ONLINE_USERS_TOTAL_GUESTS 3 REG_USERS_TOTAL 1 HIDDEN_USERS_TOTAL 1 GUEST_USERS_TOTAL 1',
)),
array(2, false, array(
diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php
index 502796d1df..01ec97f6a4 100644
--- a/tests/functions_content/get_username_string_test.php
+++ b/tests/functions_content/get_username_string_test.php
@@ -94,11 +94,11 @@ class phpbb_functions_content_get_username_string_test extends phpbb_test_case
global $phpbb_root_path, $phpEx;
return array(
- array(0, '', '', false, false, 'Guest'),
- array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'),
+ array(0, '', '', false, false, '<span class="username">Guest</span>'),
+ array(ANONYMOUS, 'Anonymous', '', false, false, '<span class="username">Anonymous</span>'),
array(2, 'Administrator', 'FF0000', false, false, '<a href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&amp;u=2" style="color: #FF0000;" class="username-coloured">Administrator</a>'),
- array(5, 'User5', '', false, 'http://www.example.org/user.php?mode=show', '<a href="http://www.example.org/user.php?mode=show&amp;u=5">User5</a>'),
- array(8, 'Eight', '', false, false, '<a href="' . $phpbb_root_path . 'memberlist.php?mode=viewprofile&amp;u=8">Eight</a>'),
+ array(5, 'User5', '', false, 'http://www.example.org/user.php?mode=show', '<a href="http://www.example.org/user.php?mode=show&amp;u=5" class="username">User5</a>'),
+ array(8, 'Eight', '', false, false, '<a href="' . $phpbb_root_path . 'memberlist.php?mode=viewprofile&amp;u=8" class="username">Eight</a>'),
);
}
@@ -113,10 +113,10 @@ class phpbb_functions_content_get_username_string_test extends phpbb_test_case
public function get_username_string_no_profile_data()
{
return array(
- array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'),
- array(ANONYMOUS, 'Anonymous', '', '', false, 'Guest'),
+ array(ANONYMOUS, 'Anonymous', '', false, false, '<span class="username">Anonymous</span>'),
+ array(ANONYMOUS, 'Anonymous', '', '', false, '<span class="username">Guest</span>'),
array(2, 'Administrator', 'FF0000', false, false, '<span style="color: #FF0000;" class="username-coloured">Administrator</span>'),
- array(8, 'Eight', '', false, false, 'Eight'),
+ array(8, 'Eight', '', false, false, '<span class="username">Eight</span>'),
);
}
diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php
index b7e60c7393..02e0b3912f 100644
--- a/tests/log/function_view_log_test.php
+++ b/tests/log/function_view_log_test.php
@@ -40,7 +40,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -59,7 +59,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -78,7 +78,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -97,7 +97,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -118,7 +118,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -139,7 +139,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -160,7 +160,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -177,11 +177,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'reportee_id' => 2,
'reportee_username' => 'admin',
- 'reportee_username_full'=> 'admin',
+ 'reportee_username_full'=> '<span class="username">admin</span>',
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -196,11 +196,11 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'reportee_id' => 1,
'reportee_username' => 'Anonymous',
- 'reportee_username_full'=> 'Anonymous',
+ 'reportee_username_full'=> '<span class="username">Anonymous</span>',
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -219,7 +219,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
@@ -238,7 +238,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user_id' => 1,
'username' => 'Anonymous',
- 'username_full' => 'Anonymous',
+ 'username_full' => '<span class="username">Anonymous</span>',
'ip' => '127.0.0.1',
'time' => 1,
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 85d8961e82..851c9ec221 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -86,7 +86,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 3),
),
),
- '<strong>Reply</strong> from A and B in topic:',
+ '<strong>Reply</strong> from A and <span class="username">B</span> in topic:',
),
array(
array(
@@ -98,7 +98,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 4),
),
),
- '<strong>Reply</strong> from A, B, and C in topic:',
+ '<strong>Reply</strong> from A, <span class="username">B</span>, and <span class="username">C</span> in topic:',
),
array(
array(
@@ -111,7 +111,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 5),
),
),
- '<strong>Reply</strong> from A, B, C, and D in topic:',
+ '<strong>Reply</strong> from A, <span class="username">B</span>, <span class="username">C</span>, and <span class="username">D</span> in topic:',
),
array(
array(
@@ -125,7 +125,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('username' => '', 'poster_id' => 6),
),
),
- '<strong>Reply</strong> from A, B, C, and 2 others in topic:',
+ '<strong>Reply</strong> from A, <span class="username">B</span>, <span class="username">C</span>, and 2 others in topic:',
),
);
}
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index 29c118d57d..bdab179c8c 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -74,10 +74,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
{
return array(
array(
- false,
- array('field_required' => true),
- 'FIELD_REQUIRED-field',
- 'Field should not accept empty values for required fields',
+ false,
+ array('field_required' => true),
+ 'FIELD_REQUIRED-field',
+ 'Field should not accept empty values for required fields',
),
);
}
@@ -130,6 +130,54 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '4',
+ array('field_show_novalue' => true),
+ '4',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ null,
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->options[$field_value]);
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index 39fe95b97f..0ad2cde9fe 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -179,6 +179,42 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ '',
+ 'Field should return correct raw value',
+ ),
+ array(
+ '12/06/2014',
+ array('field_show_novalue' => true),
+ '12/06/2014',
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index 0e92afd504..ebecbf97f0 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -170,6 +170,54 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '4',
+ array('field_show_novalue' => true),
+ '4',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should null for empty value without show_novalue',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty value with show_novalue',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty value with show_novalue',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->dropdown_options[$field_value]);
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index 611edd32b9..ac48c10a84 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -169,6 +169,66 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '10',
+ array('field_show_novalue' => true),
+ 10,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '0',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '10',
+ array('field_show_novalue' => false),
+ 10,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '0',
+ array('field_show_novalue' => false),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ 'string',
+ array('field_show_novalue' => false),
+ 0,
+ 'Field should return int cast of passed string'
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index cee8a1d863..f6c14ee38b 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -225,6 +225,60 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '[b]bbcode test[/b]',
+ array('field_show_novalue' => true),
+ '[b]bbcode test[/b]',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '[b]bbcode test[/b]',
+ array('field_show_novalue' => false),
+ '[b]bbcode test[/b]',
+ 'Field should return correct raw value',
+ ),
+ array(
+ 125,
+ array('field_show_novalue' => false),
+ 125,
+ 'Field should return value of integer as is',
+ ),
+ array(
+ 0,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return null for empty integer without show_novalue',
+ ),
+ array(
+ 0,
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty integer with show_novalue',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ null,
+ 'field should return null value as is',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index 9957510d90..a45a28e7c7 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -104,6 +104,36 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ 'http://example.com',
+ array('field_show_novalue' => true),
+ 'http://example.com',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ 'http://example.com',
+ array('field_show_novalue' => false),
+ 'http://example.com',
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 4f5b7629d5..0bbfe3848d 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -352,6 +352,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
"13FOOBAR|foobar",
),
+ array(
+ 'if_nested_tags.html',
+ array('S_VALUE' => true,),
+ array(),
+ array(),
+ 'inner_value',
+ ),
);
}
diff --git a/tests/template/templates/if_nested_tags.html b/tests/template/templates/if_nested_tags.html
new file mode 100644
index 0000000000..0348a31a8d
--- /dev/null
+++ b/tests/template/templates/if_nested_tags.html
@@ -0,0 +1 @@
+<!-- IF S_VALUE --><!-- DEFINE $INNER_VALUE = 'inner_value' --><!-- ENDIF -->{$INNER_VALUE}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index eef30fbcc7..07ef826abf 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -971,12 +971,8 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
*/
public function delete_topic($topic_id)
{
- $crawler = self::request('GET', "viewtopic.php?t={$topic_id}&sid={$this->sid}");
-
$this->add_lang('posting');
- $form = $crawler->selectButton('Go')->eq(1)->form();
- $form['action']->select('delete_topic');
- $crawler = self::submit($form);
+ $crawler = $this->get_quickmod_page($topic_id, 'DELETE_TOPIC');
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$this->add_lang('mcp');
@@ -1067,4 +1063,25 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
return $manager;
}
+
+ /**
+ * Get quickmod page
+ *
+ * @param int $topic_id
+ * @param string $action Language key for the quickmod action
+ * @param Symfony\Component\DomCrawler\Crawler Optional crawler object to use instead of creating new one.
+ * @return Symfony\Component\DomCrawler\Crawler
+ */
+ public function get_quickmod_page($topic_id, $action, $crawler = false)
+ {
+ $this->add_lang('viewtopic');
+
+ if ($crawler === false)
+ {
+ $crawler = self::request('GET', "viewtopic.php?t={$topic_id}&sid={$this->sid}");
+ }
+ $link = $crawler->filter('#quickmod')->selectLink($this->lang($action))->link()->getUri();
+
+ return self::request('GET', substr($link, strpos($link, 'mcp.')));
+ }
}
diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php
new file mode 100644
index 0000000000..e4950bb51a
--- /dev/null
+++ b/tests/viewonline/helper_test.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_viewonline_helper_test extends phpbb_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->viewonline_helper = new \phpbb\viewonline_helper();
+ }
+
+ public function session_pages_data()
+ {
+ return array(
+ array('index.php', 'index.php'),
+ array('foobar/test.php', 'foobar/test.php'),
+ array('', ''),
+ array('../index.php', '../index.php'),
+ );
+ }
+
+ /**
+ * @dataProvider session_pages_data
+ */
+ public function test_get_user_page($expected, $session_page)
+ {
+ $on_page = $this->viewonline_helper->get_user_page($session_page);
+ $this->assertArrayHasKey(1, $on_page);
+ $this->assertSame($expected, $on_page[1]);
+ }
+}