aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/acp_attachments_test.php78
-rw-r--r--tests/functional/acp_bbcodes_test.php46
-rw-r--r--tests/functional/acp_profile_field_test.php15
-rw-r--r--tests/functional/acp_smilies_test.php43
-rw-r--r--tests/functional/browse_test.php14
-rw-r--r--tests/functional/controllers_compatibility_test.php56
-rw-r--r--tests/functional/download_test.php5
-rw-r--r--tests/functional/extension_acp_test.php4
-rw-r--r--tests/functional/extension_controller_test.php2
-rw-r--r--tests/functional/extension_global_lang_test.php2
-rw-r--r--tests/functional/extension_module_test.php13
-rw-r--r--tests/functional/extension_permission_lang_test.php2
-rw-r--r--tests/functional/feed_test.php137
-rw-r--r--tests/functional/fileupload_form_test.php10
-rw-r--r--tests/functional/fileupload_remote_test.php78
-rw-r--r--tests/functional/fixtures/ext/foo/bar/acp/main_info.php1
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/services.yml14
-rw-r--r--tests/functional/fixtures/ext/foo/bar/ucp/main_info.php1
-rw-r--r--tests/functional/forum_style_test.php24
-rw-r--r--tests/functional/metadata_manager_test.php2
-rw-r--r--tests/functional/notification_test.php8
-rw-r--r--tests/functional/permission_roles_test.php84
-rw-r--r--tests/functional/plupload_test.php26
-rw-r--r--tests/functional/posting_test.php188
-rw-r--r--tests/functional/private_messages_test.php41
-rw-r--r--tests/functional/prune_shadow_topic_test.php2
-rw-r--r--tests/functional/registration_test.php54
-rw-r--r--tests/functional/report_post_captcha_test.php7
-rw-r--r--tests/functional/search/base.php7
-rw-r--r--tests/functional/ucp_groups_test.php68
-rw-r--r--tests/functional/user_password_reset_test.php57
-rw-r--r--tests/functional/visibility_softdelete_test.php4
-rw-r--r--tests/functional/visit_installer_test.php30
33 files changed, 864 insertions, 259 deletions
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php
deleted file mode 100644
index 8e810a508a..0000000000
--- a/tests/functional/acp_attachments_test.php
+++ /dev/null
@@ -1,78 +0,0 @@
-<?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.
- *
- */
-
-/**
- * @group functional
- */
-class phpbb_functional_acp_attachments_test extends phpbb_functional_test_case
-{
- public function data_imagick_path_linux()
- {
- return array(
- array('/usr/bin', 'Configuration updated successfully'),
- array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'),
- array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'),
- );
- }
-
- /**
- * @dataProvider data_imagick_path_linux
- */
- public function test_imagick_path_linux($imagick_path, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux')
- {
- $this->markTestSkipped('Unable to test linux specific paths on other OS.');
- }
-
- $this->login();
- $this->admin_login();
-
- $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
-
- $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
-
- $crawler = self::submit($form);
- $this->assertContains($expected, $crawler->filter('#main')->text());
- }
-
- public function data_imagick_path_windows()
- {
- return array(
- array('C:\Windows', 'Configuration updated successfully'),
- array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'),
- array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'),
- );
- }
-
- /**
- * @dataProvider data_imagick_path_windows
- */
- public function test_imagick_path_windows($imagick_path, $expected)
- {
- if (strtolower(substr(PHP_OS, 0, 3)) !== 'win')
- {
- $this->markTestSkipped('Unable to test windows specific paths on other OS.');
- }
-
- $this->login();
- $this->admin_login();
-
- $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
-
- $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
-
- $crawler = self::submit($form);
- $this->assertContains($expected, $crawler->filter('#main')->text());
- }
-}
diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php
new file mode 100644
index 0000000000..58681dfa07
--- /dev/null
+++ b/tests/functional/acp_bbcodes_test.php
@@ -0,0 +1,46 @@
+<?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.
+ *
+ */
+
+/**
+ * @group functional
+ */
+class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case
+{
+ public function test_htmlspecialchars()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Create the BBCode
+ $crawler = self::request('GET', 'adm/index.php?i=acp_bbcodes&sid=' . $this->sid . '&mode=bbcodes&action=add');
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'bbcode_match' => '[mod="{TEXT1}"]{TEXT2}[/mod]',
+ 'bbcode_tpl' => '<div>{TEXT1}</div><div>{TEXT2}</div>'
+ ));
+ self::submit($form);
+
+ // Test it in the "new topic" preview
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'subject',
+ 'message' => '[mod=a]b[/mod][mod="c"]d[/mod]'
+ ));
+ $crawler = self::submit($form);
+
+ $html = $crawler->filter('#preview')->html();
+ $this->assertContains('<div>a</div>', $html);
+ $this->assertContains('<div>b</div>', $html);
+ $this->assertContains('<div>c</div>', $html);
+ $this->assertContains('<div>d</div>', $html);
+ }
+}
diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php
index 88df782faa..7a0a6ca941 100644
--- a/tests/functional/acp_profile_field_test.php
+++ b/tests/functional/acp_profile_field_test.php
@@ -28,18 +28,20 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
public function data_add_profile_field()
{
return array(
- array('bool', 'profilefields.type.bool',
+ array('profilefields.type.bool',
array(
+ 'field_ident' => 'bool',
+ 'lang_name' => 'bool',
'lang_options[0]' => 'foo',
'lang_options[1]' => 'bar',
),
- array(),
),
- array('dropdown', 'profilefields.type.dropdown',
+ array('profilefields.type.dropdown',
array(
+ 'field_ident' => 'dropdown',
+ 'lang_name' => 'dropdown',
'lang_options' => "foo\nbar\nbar\nfoo",
),
- array(),
),
);
}
@@ -47,13 +49,12 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
/**
* @dataProvider data_add_profile_field
*/
- public function test_add_profile_field($name, $type, $page1_settings, $page2_settings)
+ public function test_add_profile_field($type, $page1_settings)
{
// Custom profile fields page
$crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
// these language strings are html
$form = $crawler->selectButton('Create new field')->form(array(
- 'field_ident' => $name,
'field_type' => $type,
));
$crawler = self::submit($form);
@@ -63,7 +64,7 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
$crawler = self::submit($form);
// Fill form for profile field specific options
- $form = $crawler->selectButton('Save')->form($page2_settings);
+ $form = $crawler->selectButton('Save')->form();
$crawler= self::submit($form);
$this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
diff --git a/tests/functional/acp_smilies_test.php b/tests/functional/acp_smilies_test.php
new file mode 100644
index 0000000000..ebe8717fa7
--- /dev/null
+++ b/tests/functional/acp_smilies_test.php
@@ -0,0 +1,43 @@
+<?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.
+ *
+ */
+
+/**
+ * @group functional
+ */
+class phpbb_functional_acp_smilies_test extends phpbb_functional_test_case
+{
+ public function test_htmlspecialchars()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Create the BBCode
+ $crawler = self::request('GET', 'adm/index.php?i=acp_icons&sid=' . $this->sid . '&mode=smilies&action=edit&id=1');
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'code[icon_e_biggrin.gif]' => '>:D',
+ 'emotion[icon_e_biggrin.gif]' => '>:D'
+ ));
+ self::submit($form);
+
+ // Test it in the "new topic" preview
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'subject',
+ 'message' => '>:D'
+ ));
+ $crawler = self::submit($form);
+
+ $html = $crawler->filter('#preview')->html();
+ $this->assertRegexp('(<img [^>]+ alt="&gt;:D" title="&gt;:D"[^>]*>)', $html);
+ }
+}
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php
index b9e74a280f..280e814c06 100644
--- a/tests/functional/browse_test.php
+++ b/tests/functional/browse_test.php
@@ -34,9 +34,21 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
}
+ public function test_help_faq()
+ {
+ $crawler = self::request('GET', 'app.php/help/faq');
+ $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count());
+ }
+
+ public function test_help_bbcode()
+ {
+ $crawler = self::request('GET', 'app.php/help/bbcode');
+ $this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count());
+ }
+
public function test_feed()
{
- $crawler = self::request('GET', 'feed.php', array(), false);
+ $crawler = self::request('GET', 'app.php/feed', array(), false);
self::assert_response_xml();
$this->assertGreaterThan(0, $crawler->filter('entry')->count());
}
diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php
new file mode 100644
index 0000000000..9499888a1a
--- /dev/null
+++ b/tests/functional/controllers_compatibility_test.php
@@ -0,0 +1,56 @@
+<?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.
+*
+*/
+
+/**
+* @group functional
+*/
+
+class phpbb_functional_controllers_compatibility_test extends phpbb_functional_test_case
+{
+ public function test_report_compatibility()
+ {
+ $this->assert301('report.php?f=1&p=1', 'app.php/post/1/report');
+ $this->assert301('report.php?p=1', 'app.php/post/1/report');
+ $this->assert301('report.php?pm=1', 'app.php/pm/1/report');
+ }
+
+ public function test_feed_compatibility()
+ {
+ $this->assert301('feed.php', 'app.php/feed');
+ $this->assert301('feed.php?mode=foobar', 'app.php/feed/foobar');
+ $this->assert301('feed.php?mode=news', 'app.php/feed/news');
+ $this->assert301('feed.php?mode=topics', 'app.php/feed/topics');
+ $this->assert301('feed.php?mode=topics_news', 'app.php/feed/topics_news');
+ $this->assert301('feed.php?mode=topics_active', 'app.php/feed/topics_active');
+ $this->assert301('feed.php?mode=forums', 'app.php/feed/forums');
+ $this->assert301('feed.php?f=1', 'app.php/feed/forum/1');
+ $this->assert301('feed.php?t=1', 'app.php/feed/topic/1');
+ }
+
+ protected function assert301($from, $to)
+ {
+ self::$client->followRedirects(false);
+ self::request('GET', $from, array(), false);
+
+ // Fix sid issues
+ $location = self::$client->getResponse()->getHeader('Location');
+ $location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location);
+ if (substr($location, -1) === '?')
+ {
+ $location = substr($location, 0, -1);
+ }
+
+ $this->assertEquals(301, self::$client->getResponse()->getStatus());
+ $this->assertStringEndsWith($to, $location);
+ }
+}
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 1e863210e6..3d4f316d72 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -11,10 +11,7 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-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';
/**
* @group functional
@@ -58,7 +55,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Download #1'], $post['topic_id'], 'Re: Download Topic #1-#2', 'This is a test post posted by the testing framework.', array('upload_files' => 1));
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id'];
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 8a71a5ce04..ce0f4911e3 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -26,7 +26,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
}
@@ -133,7 +133,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
{
- $text = $crawler->filter('dl')->eq($i)->text();
+ $text = trim($crawler->filter('dl')->eq($i)->text());
$match = false;
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 18eb9ad4c6..58c3878b8b 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -34,7 +34,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index f615114c08..a1e2547745 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index ee084720e4..d3a66b9b35 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -29,7 +29,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
@@ -49,8 +49,9 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
$this->phpbb_extension_manager = $this->get_extension_manager();
$this->phpbb_extension_manager->enable('foo/bar');
- $modules = new acp_modules();
$db = $this->get_db();
+ $cache = $this->get_cache_driver();
+ $modules = new \phpbb\module\module_manager($cache, $db, $this->phpbb_extension_manager, MODULES_TABLE, dirname(__FILE__) . '/../../phpBB/', 'php');
$sql = 'SELECT module_id
FROM ' . MODULES_TABLE . "
@@ -70,7 +71,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
'module_mode' => '',
'module_auth' => '',
);
- $modules->update_module_data($parent_data, true);
+ $modules->update_module_data($parent_data);
$module_data = array(
'module_basename' => 'foo\\bar\\acp\\main_module',
@@ -82,7 +83,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
'module_mode' => 'mode',
'module_auth' => '',
);
- $modules->update_module_data($module_data, true);
+ $modules->update_module_data($module_data);
$parent_data = array(
'module_basename' => '',
@@ -94,7 +95,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
'module_mode' => '',
'module_auth' => '',
);
- $modules->update_module_data($parent_data, true);
+ $modules->update_module_data($parent_data);
$module_data = array(
'module_basename' => 'foo\\bar\\ucp\\main_module',
@@ -106,7 +107,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
'module_mode' => 'mode',
'module_auth' => '',
);
- $modules->update_module_data($module_data, true);
+ $modules->update_module_data($module_data);
$this->purge_cache();
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 92d8d596c7..f570d45215 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -30,7 +30,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index e48dfc043a..725a44ae5e 100644
--- a/tests/functional/feed_test.php
+++ b/tests/functional/feed_test.php
@@ -30,9 +30,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
{
parent::__construct($name, $data, $dataName);
- $this->backupStaticAttributesBlacklist += array(
- 'phpbb_functional_feed_test' => array('init_values'),
- );
+ $this->backupStaticAttributesBlacklist['phpbb_functional_feed_test'] = array('init_values');
+
+ $this->purge_cache();
}
public function test_setup_config_before_state()
@@ -61,66 +61,64 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form->setValues($values);
$crawler = self::submit($form);
- $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
+ self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
// Special config (Guest can't see attachments)
$this->add_lang('acp/permissions');
$crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1");
- $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
+ self::assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
$form['setting[1][0][u_download]']->select(-1);
$crawler = self::submit($form);
- $this->assertContainsLang('AUTH_UPDATED', $crawler->filter('.successbox')->text());
+ self::assertContainsLang('AUTH_UPDATED', $crawler->filter('.successbox')->text());
}
public function test_dump_board_state()
{
- $crawler = self::request('GET', 'feed.php?mode=forums', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/forums', array(), false);
self::assert_response_xml();
self::$init_values['disapprove_user']['forums_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=overall', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/overall', array(), false);
self::assert_response_xml();
self::$init_values['disapprove_user']['overall_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics', array(), false);
self::assert_response_xml();
self::$init_values['disapprove_user']['topics_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics_new', array(), false);
self::assert_response_xml();
self::$init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics_active', array(), false);
self::assert_response_xml();
self::$init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath('//entry')->count();
$this->login();
- $crawler = self::request('GET', 'feed.php?mode=forums', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/forums', array(), false);
self::assert_response_xml();
self::$init_values['admin']['forums_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=overall', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/overall', array(), false);
self::assert_response_xml();
self::$init_values['admin']['overall_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics', array(), false);
self::assert_response_xml();
self::$init_values['admin']['topics_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics_new', array(), false);
self::assert_response_xml();
self::$init_values['admin']['topics_new_value'] = $crawler->filterXPath('//entry')->count();
- $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false);
+ $crawler = self::request('GET', 'app.php/feed/topics_active', array(), false);
self::assert_response_xml();
self::$init_values['admin']['topics_active_value'] = $crawler->filterXPath('//entry')->count();
-
-
}
public function test_setup_forums()
@@ -138,7 +136,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form = $crawler->selectButton('update')->form(array(
'forum_perm_from' => 2,
));
- $crawler = self::submit($form);
+ self::submit($form);
$this->load_ids(array(
'forums' => array(
@@ -155,7 +153,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form = $crawler->selectButton('update')->form(array(
'forum_perm_from' => 2,
));
- $crawler = self::submit($form);
+ self::submit($form);
// 'Feeds #news' will be used for feed.php?mode=news
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
@@ -166,9 +164,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form = $crawler->selectButton('update')->form(array(
'forum_perm_from' => 2,
));
- $crawler = self::submit($form);
+ self::submit($form);
- // 'Feeds #exclude' will not be displayed on feed.php?mode=forums
+ // 'Feeds #exclude' will not be displayed on app.php/feed/forums
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
$form = $crawler->selectButton('addforum')->form(array(
'forum_name' => 'Feeds #exclude',
@@ -177,7 +175,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form = $crawler->selectButton('update')->form(array(
'forum_perm_from' => 2,
));
- $crawler = self::submit($form);
+ self::submit($form);
}
public function test_setup_config_after_forums()
@@ -201,7 +199,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form['feed_exclude_id']->select(array($this->data['forums']['Feeds #exclude']));
$crawler = self::submit($form);
- $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
+ self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
}
public function test_feeds_empty()
@@ -272,6 +270,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
'id' => $this->data['forums']['Feeds #exclude'],
'contents_lang' => array('NO_FEED'),
'invalid' => true,
+ 'response_code' => 404,
),
),
't' => array(
@@ -279,6 +278,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
'id' => $this->data['topics']['Feeds #exclude - Topic #1'],
'contents_lang' => array('NO_FEED'),
'invalid' => true,
+ 'response_code' => 404,
),
),
'overall' => array(
@@ -331,15 +331,15 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text());
+ self::assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text());
$this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id'];
$this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text());
+ self::assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id'];
}
@@ -493,9 +493,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text());
+ self::assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id'];
}
@@ -516,14 +516,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->add_lang('posting');
$crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Feeds #1']}&p={$this->data['posts']['Re: Feeds #1 - Topic #2']}&sid={$this->sid}");
- $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
+ self::assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$form = $crawler->selectButton('Yes')->form();
$crawler = self::submit($form);
- $this->assertContainsLang('POST_DELETED', $crawler->text());
+ self::assertContainsLang('POST_DELETED', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}");
- $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ self::assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
}
public function test_feeds_softdeleted_post_admin()
@@ -615,15 +615,15 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->add_lang('posting');
$crawler = $this->get_quickmod_page($this->data['topics']['Feeds #1 - Topic #2'], 'DELETE_TOPIC');
- $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
+ self::assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
$this->add_lang('mcp');
$form = $crawler->selectButton('Yes')->form();
$crawler = self::submit($form);
- $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
+ self::assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}");
- $this->assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text());
+ self::assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text());
}
public function test_feeds_softdeleted_topic_admin()
@@ -716,8 +716,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
't' => array(
array(
'id' => $this->data['topics']['Feeds #1 - Topic #2'],
- 'contents_lang' => array('SORRY_AUTH_READ'),
+ 'contents_lang' => array('SORRY_AUTH_READ_TOPIC'),
'invalid' => true,
+ 'response_code' => 403,
),
),
'overall' => array(
@@ -758,10 +759,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
// Test creating a reply
$this->login('disapprove_user');
- $post2 = $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
+ $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}");
- $this->assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text());
+ self::assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text());
}
public function test_feeds_unapproved_post_admin()
@@ -853,7 +854,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id'];
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}");
- $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
+ self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
$this->logout();
$this->set_flood_interval(15);
@@ -869,10 +870,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$form = $crawler->selectButton('Submit')->form();
$values = $form->getValues();
- $values["config[flood_interval]"] = $flood_interval;
+ $values['config[flood_interval]'] = $flood_interval;
$form->setValues($values);
$crawler = self::submit($form);
- $this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
+ self::assertGreaterThan(0, $crawler->filter('.successbox')->count());
$this->logout();
}
@@ -964,8 +965,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
't' => array(
array(
'id' => $this->data['topics']['Feeds #1.1 - Topic #3'],
- 'contents_lang' => array('SORRY_AUTH_READ'),
+ 'contents_lang' => array('SORRY_AUTH_READ_TOPIC'),
'invalid' => true,
+ 'response_code' => 403,
),
),
'overall' => array(
@@ -1004,7 +1006,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #3', 'This is a test topic posted by the testing framework. [attachment=0]Attachment #0[/attachment]', array('upload_files' => 1));
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text());
+ self::assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text());
$this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id'];
}
@@ -1220,9 +1222,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
// Test creating a reply with 1 missing attachment
$post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
- $this->assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text());
+ self::assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text());
$this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id'];
}
@@ -1322,9 +1324,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
{
foreach ($feeds as $feed_data)
{
- if ($mode === 'f' || $mode === 't')
+ if ($mode === 'f')
+ {
+ $params = "/forum/{$feed_data['id']}";
+ $this->assert_feed($params, $feed_data);
+ }
+ else if ($mode === 't')
{
- $params = "?{$mode}={$feed_data['id']}";
+ $params = "/topic/{$feed_data['id']}";
$this->assert_feed($params, $feed_data);
}
else
@@ -1348,10 +1355,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
case 'news':
break;
default:
- $this->fail('Unsupported feed mode: ' . $mode);
+ self::fail('Unsupported feed mode: ' . $mode);
}
- $params = "?mode={$mode}";
+ $params = "/{$mode}";
$this->assert_feed($params, $feed_data);
}
}
@@ -1360,19 +1367,19 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
protected function assert_feed($params, $data)
{
- $crawler = self::request('GET', 'feed.php' . $params, array(), false);
+ $crawler = self::request('GET', 'app.php/feed' . $params, array(), false);
if (empty($data['invalid']))
{
self::assert_response_xml();
- $this->assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'feed.php{$params}'");
+ self::assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'app.php/feed{$params}'");
if (!empty($data['xpath']))
{
foreach($data['xpath'] as $xpath => $count_expected)
{
- $this->assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'feed.php{$params}', Search for {$xpath}");
+ self::assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'app.php/feed{$params}', Search for {$xpath}");
}
}
@@ -1381,7 +1388,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
foreach($data['contents'] as $entry_id => $string)
{
$content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text();
- $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'");
+ self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
@@ -1390,7 +1397,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
foreach($data['contents_lang'] as $entry_id => $string)
{
$content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text();
- $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'");
+ self::assertContainsLang($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
@@ -1398,21 +1405,21 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
{
foreach($data['attachments'] as $entry_id => $attachments)
{
+ $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text();
foreach ($attachments as $i => $attachment)
{
- $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text();
$url = self::$root_url . "download/file.php?id={$attachment['id']}";
$string = "Attachment #{$i}";
if ($attachment['displayed'])
{
- $this->assertContains($url, $content, "Tested feed : 'feed.php{$params}'");
- $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'");
+ self::assertContains($url, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertNotContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
else
{
- $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'");
- $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'");
+ self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'");
+ self::assertNotContains($url, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
}
@@ -1420,14 +1427,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
}
else
{
- self::assert_response_html();
+ self::assert_response_html($data['response_code'] ?: 202);
if (!empty($data['contents_lang']))
{
+ $content = $crawler->filter('html')->text();
foreach($data['contents_lang'] as $string)
{
- $content = $crawler->filter('html')->text();
- $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'");
+ self::assertContainsLang($string, $content, "Tested feed : 'app.php/feed{$params}'");
}
}
}
@@ -1445,7 +1452,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (in_array($row['forum_name'], $data['forums']))
+ if (in_array($row['forum_name'], $data['forums'], false))
{
$this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
}
@@ -1461,7 +1468,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (in_array($row['topic_title'], $data['topics']))
+ if (in_array($row['topic_title'], $data['topics'], false))
{
$this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
}
@@ -1478,7 +1485,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
- if (in_array($row['post_subject'], $data['posts']))
+ if (in_array($row['post_subject'], $data['posts'], false))
{
$this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
$post_ids[] = (int) $row['post_id'];
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index d381fa1ae2..ff9450be0d 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -46,6 +46,13 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
private function upload_file($filename, $mimetype)
{
+ $crawler = self::$client->request(
+ 'GET',
+ 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid
+ );
+
+ $file_form_data = array_merge(['add_file' => $this->lang('ADD_FILE')], $this->get_hidden_fields($crawler, 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid));
+
$file = array(
'tmp_name' => $this->path . $filename,
'name' => $filename,
@@ -57,7 +64,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$crawler = self::$client->request(
'POST',
'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
- array('add_file' => $this->lang('ADD_FILE')),
+ $file_form_data,
array('fileupload' => $file)
);
@@ -99,7 +106,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$form = $crawler->selectButton('Submit')->form(array(
'config[check_attachment_content]' => 0,
- 'config[img_imagick]' => '',
));
self::submit($form);
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 6ece150b23..426ebcee53 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -11,13 +11,29 @@
*
*/
-require_once __DIR__ . '/../../phpBB/includes/functions_upload.php';
-
/**
* @group functional
*/
class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
{
+ /** @var \phpbb\filesystem\filesystem_interface */
+ protected $filesystem;
+
+ /** @var \phpbb\files\factory */
+ protected $factory;
+
+ /** @var \bantu\IniGetWrapper\IniGetWrapper */
+ protected $php_ini;
+
+ /** @var \phpbb\language\language */
+ protected $language;
+
+ /** @var \phpbb\request\request_interface */
+ protected $request;
+
+ /** @var string phpBB root path */
+ protected $phpbb_root_path;
+
public function setUp()
{
parent::setUp();
@@ -25,19 +41,28 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
// URL
// Global $config required by unique_id
- // Global $user required by fileupload::remote_upload
- global $config, $user;
+ global $config, $phpbb_root_path, $phpEx;
if (!is_array($config))
{
- $config = array();
+ $config = new \phpbb\config\config(array());
}
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
+ $config['remote_upload_verify'] = 0;
+
+ $this->filesystem = new \phpbb\filesystem\filesystem();
+ $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
+ $this->request = $this->getMock('\phpbb\request\request');
+ $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
- $user = new phpbb_mock_user();
- $user->lang = new phpbb_mock_lang();
+ $container = new phpbb_mock_container_builder();
+ $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path));
+ $this->factory = new \phpbb\files\factory($container);
+ $container->set('files.factory', $this->factory);
+ $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path));
+ $this->phpbb_root_path = $phpbb_root_path;
}
public function tearDown()
@@ -49,31 +74,48 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
public function test_invalid_extension()
{
- $upload = new fileupload('', array('jpg'), 100);
- $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif');
+ /** @var \phpbb\files\upload $upload */
+ $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $upload->set_error_prefix('')
+ ->set_allowed_extensions(array('jpg'))
+ ->set_max_filesize(100);
+ $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/blank.gif');
$this->assertEquals('URL_INVALID', $file->error[0]);
}
public function test_empty_file()
{
- $upload = new fileupload('', array('jpg'), 100);
- $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg');
+ /** @var \phpbb\files\upload $upload */
+ $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $upload->set_error_prefix('')
+ ->set_allowed_extensions(array('jpg'))
+ ->set_max_filesize(100);
+ $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/blank.jpg');
$this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]);
}
public function test_successful_upload()
{
- $upload = new fileupload('', array('gif'), 1000);
- $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
- $this->assertEquals(0, sizeof($file->error));
- $this->assertTrue(file_exists($file->filename));
+ /** @var \phpbb\files\upload $upload */
+ $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $upload->set_error_prefix('')
+ ->set_allowed_extensions(array('gif'))
+ ->set_max_filesize(2000);
+ $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
+ $this->assertEquals(0, count($file->error));
+ $this->assertTrue(file_exists($file->get('filename')));
+ $this->assertTrue($file->is_uploaded());
}
public function test_too_large()
{
- $upload = new fileupload('', array('gif'), 100);
- $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
- $this->assertEquals(1, sizeof($file->error));
+ /** @var \phpbb\files\upload $upload */
+ $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $upload->set_error_prefix('')
+ ->set_allowed_extensions(array('gif'))
+ ->set_max_filesize(100);
+ $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
+ $this->assertEquals(1, count($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
}
}
diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
index ec378e0e75..371ab7c967 100644
--- a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
+++ b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
@@ -28,7 +28,6 @@ class main_info
return array(
'filename' => 'foo\bar\acp\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/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml
index d35be7955a..495c775a1f 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/services.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -2,13 +2,13 @@ services:
foo_bar.controller:
class: foo\bar\controller\controller
arguments:
- - @controller.helper
- - @path_helper
- - @template
- - @config
- - @user
- - %core.root_path%
- - %core.php_ext%
+ - '@controller.helper'
+ - '@path_helper'
+ - '@template'
+ - '@config'
+ - '@user'
+ - '%core.root_path%'
+ - '%core.php_ext%'
foo_bar.listener.permission:
class: foo\bar\event\permission
diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
index d34244f800..4c74442639 100644
--- a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
+++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
@@ -20,7 +20,6 @@ class main_info
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/forum_style_test.php b/tests/functional/forum_style_test.php
index 65be94f4d0..b3c1115b7f 100644
--- a/tests/functional/forum_style_test.php
+++ b/tests/functional/forum_style_test.php
@@ -16,16 +16,28 @@
*/
class phpbb_functional_forum_style_test extends phpbb_functional_test_case
{
+ public function test_font_awesome_style()
+ {
+ $crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
+ $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href'));
+
+ $crawler = self::request('GET', 'viewtopic.php?t=1');
+ $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href'));
+
+ $crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
+ $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href'));
+ }
+
public function test_default_forum_style()
{
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
- $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
}
public function test_custom_forum_style()
@@ -35,13 +47,13 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2');
$crawler = self::request('GET', 'viewtopic.php?t=1&f=2');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$crawler = self::request('GET', 'viewtopic.php?t=1&view=next');
- $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->attr('href'));
+ $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href'));
$db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2');
$this->delete_style(2, 'test_style');
diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php
index 0d2fdf082e..8456c40f00 100644
--- a/tests/functional/metadata_manager_test.php
+++ b/tests/functional/metadata_manager_test.php
@@ -35,7 +35,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
{
parent::setUpBeforeClass();
- self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper = new phpbb_test_case_helpers(__CLASS__);
self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index f21d73817a..91fc962846 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -21,15 +21,15 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
return array(
// Rows inserted by phpBB/install/schemas/schema_data.sql
// Also see PHPBB3-11460
- array('notification.type.post_notification', true),
- array('notification.type.topic_notification', true),
+ array('notification.type.post_notification.method.board', true),
+ array('notification.type.topic_notification.method.board', true),
array('notification.type.post_notification.method.email', true),
array('notification.type.topic_notification.method.email', true),
// Default behaviour for in-board notifications:
// If user did not opt-out, in-board notifications are on.
- array('notification.type.bookmark_notification', true),
- array('notification.type.quote_notification', true),
+ array('notification.type.bookmark_notification.method.board', true),
+ array('notification.type.quote_notification.method.board', true),
// Default behaviour for email notifications:
// If user did not opt-in, email notifications are off.
diff --git a/tests/functional/permission_roles_test.php b/tests/functional/permission_roles_test.php
new file mode 100644
index 0000000000..e6506fb37c
--- /dev/null
+++ b/tests/functional/permission_roles_test.php
@@ -0,0 +1,84 @@
+<?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.
+*
+*/
+
+/**
+* @group functional
+*/
+class functional_permission_roles_test extends phpbb_functional_test_case
+{
+ public function data_permission_roles()
+ {
+ return array(
+ array(
+ array(0, 14),
+ array(17, 17),
+ array(
+ 'role[5][1]' => 14,
+ )
+ ),
+ array(
+ array(14, 14),
+ array(17, 17),
+ array(
+ 'role[5][1]' => 0,
+ )
+ ),
+ array(
+ array(0, 14),
+ array(17, 17)
+ ),
+ );
+ }
+ /**
+ * @dataProvider data_permission_roles
+ */
+ public function test_permission_roles($admin_roles, $guest_roles, $set_values = array())
+ {
+ $this->login();
+ $this->admin_login();
+ $this->add_lang('acp/permissions');
+ $crawler = self::request('GET', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid);
+
+ // Select forums
+ $form = $crawler->filter('form[id=select_victim]')->form();
+ $form['forum_id']->setValue(array(1,2));
+ $crawler = self::$client->submit($form);
+
+ // Select administrators and guests
+ $groups_form = $crawler->filter('form[id=groups]')->form();
+ $groups_form['group_id']->setValue(array(1,5));
+
+ $crawler = self::submit($groups_form);
+ $form = $crawler->filter('form')->form();
+ $values = $form->getValues();
+
+ // Check default settings
+ $this->assertEquals($admin_roles[0], $values['role[5][1]']);
+ $this->assertEquals($admin_roles[1], $values['role[5][2]']);
+ $this->assertEquals($guest_roles[0], $values['role[1][1]']);
+ $this->assertEquals($guest_roles[1], $values['role[1][2]']);
+
+ // Set admin to full access on category
+ foreach ($set_values as $key => $value)
+ {
+ $form[$key]->setValue($value);
+ }
+
+ $form_values = $form->getValues();
+ $form_values['action[apply_all_permissions]'] = true;
+ $crawler = self::request('POST', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid, $form_values);
+ $this->assertContainsLang('AUTH_UPDATED', $crawler->text());
+
+ $this->logout();
+ }
+}
diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php
index d358681ad1..4ab1c8e9e5 100644
--- a/tests/functional/plupload_test.php
+++ b/tests/functional/plupload_test.php
@@ -76,6 +76,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
$chunk_size = ceil(filesize($this->path . 'valid.jpg') / self::CHUNKS);
$handle = fopen($this->path . 'valid.jpg', 'rb');
+ $crawler = self::$client->request('POST', $url . '&sid=' . $this->sid);
+
+ $file_form_data = $this->get_hidden_fields($crawler, $url);
+
for ($i = 0; $i < self::CHUNKS; $i++)
{
$chunk = fread($handle, $chunk_size);
@@ -94,24 +98,24 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
$crawler = self::$client->request(
'POST',
$url . '&sid=' . $this->sid,
- array(
+ array_merge(array(
'chunk' => $i,
'chunks' => self::CHUNKS,
'name' => md5('valid') . '.jpg',
'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'),
- ),
+ ), $file_form_data),
array('fileupload' => $file),
array('X-PHPBB-USING-PLUPLOAD' => '1')
);
if ($i < self::CHUNKS - 1)
{
- $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent());
+ $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content());
}
else
{
- $response = json_decode(self::$client->getResponse()->getContent(), true);
+ $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
}
@@ -134,21 +138,23 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
'error' => UPLOAD_ERR_OK,
);
- $crawler = self::$client->request(
+ $file_form_data = $this->get_hidden_fields(null, $url);
+
+ self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1');
+ self::$client->request(
'POST',
$url . '&sid=' . $this->sid,
- array(
+ array_merge(array(
'chunk' => '0',
'chunks' => '1',
'name' => md5('valid') . '.jpg',
'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'),
- ),
- array('fileupload' => $file),
- array('X-PHPBB-USING-PLUPLOAD' => '1')
+ ), $file_form_data),
+ array('fileupload' => $file)
);
- $response = json_decode(self::$client->getResponse()->getContent(), true);
+ $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
}
}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 914233240e..49447e1133 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -29,7 +29,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
// Test creating a reply with bbcode
$post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
// Test quoting a message
@@ -41,23 +41,62 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->login();
- $this->add_lang('posting');
+ $post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.');
+ $this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.');
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text());
+ }
- self::create_post(2,
- 1,
- 'Unsupported characters',
- "This is a test with these weird characters: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6",
- array(),
- 'Your message contains the following unsupported characters'
- );
+ public function test_supported_unicode_characters()
+ {
+ $this->login();
- self::create_post(2,
- 1,
- "Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6",
- 'This is a test with emoji characters in the topic title.',
- array(),
- 'Your subject contains the following unsupported characters'
- );
+ $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
+ $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x84\x90 \xF0\x9F\x84\x91");
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text());
+ }
+
+ public function test_html_entities()
+ {
+ $this->login();
+
+ $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
+ $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', '&#128512;');
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains('&#128512;', $crawler->text());
+ }
+
+ public function test_quote()
+ {
+ $text = 'Test post </textarea>"\' &&amp;amp;';
+ $expected = "(\\[quote=admin[^\\]]*\\]\n" . preg_quote($text) . "\n\\[/quote\\])";
+
+ $this->login();
+ $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic');
+ $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+
+ $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}");
+
+ $this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
+ }
+
+ /**
+ * @see https://tracker.phpbb.com/browse/PHPBB3-14962
+ */
+ public function test_edit()
+ {
+ $this->login();
+ $this->create_topic(2, 'Test Topic post', 'Test topic post');
+
+ $url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri();
+ $post_id = $this->get_parameter_from_link($url, 'p');
+ $crawler = self::request('GET', "posting.php?mode=edit&f=2&p={$post_id}&sid={$this->sid}");
+ $form = $crawler->selectButton('Submit')->form();
+ $form->setValues(array('message' => 'Edited post'));
+ $crawler = self::submit($form);
+
+ $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text());
}
/**
@@ -67,10 +106,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$text = '0[quote]1[quote]2[/quote]1[/quote]0';
$expected = array(
- 0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]',
- 1 => '[quote="admin"]00[/quote]',
- 2 => '[quote="admin"]0[quote]11[/quote]0[/quote]',
- 3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]',
+ 0 => '0[quote]1[quote]2[/quote]1[/quote]0',
+ 1 => '00',
+ 2 => '0[quote]11[/quote]0',
+ 3 => '0[quote]1[quote]2[/quote]1[/quote]0',
);
$this->login();
@@ -83,7 +122,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->set_quote_depth($quote_depth);
$crawler = self::request('GET', $quote_url);
- $this->assertContains($expected_text, $crawler->filter('textarea#message')->text());
+ $this->assertRegexp(
+ "(\\[quote=admin[^\\]]*\\]\n?" . preg_quote($expected_text) . "\n?\\[/quote\\])",
+ $crawler->filter('textarea#message')->text()
+ );
}
}
@@ -114,7 +156,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->set_quote_depth($quote_depth);
- $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+ $post = $this->create_post(2, $topic['topic_id'], "Re: Test Topic 1#$quote_depth", $text);
$url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}";
$crawler = self::request('GET', $url);
@@ -156,4 +198,106 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$this->assertEquals(1, $crawler->filter('.successbox')->count());
}
+
+ public function test_ticket_8420()
+ {
+ $text = '[b][url=http://example.org] :arrow: here[/url][/b]';
+
+ $this->login();
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => $text
+ ));
+ $crawler = self::submit($form);
+ $this->assertEquals($text, $crawler->filter('#message')->text());
+ }
+
+ public function test_old_signature_in_preview()
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]',
+ user_sig_bbcode_uid = '2u8sdcwb',
+ user_sig_bbcode_bitfield = 'QA=='
+ WHERE user_id = 2";
+ $this->get_db()->sql_query($sql);
+
+ $this->login();
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => 'My post',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContains(
+ '<strong class="text-strong">My signature</strong>',
+ $crawler->filter('#preview .signature')->html()
+ );
+ }
+
+ /**
+ * @ticket PHPBB3-10628
+ */
+ public function test_www_links_preview()
+ {
+ $text = 'www.example.org';
+ $url = 'http://' . $text;
+
+ $this->add_lang('posting');
+ $this->login();
+
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => $text
+ ));
+ $crawler = self::submit($form);
+
+ // Test that the textarea remains unchanged
+ $this->assertEquals($text, $crawler->filter('#message')->text());
+
+ // Test that the preview contains the correct link
+ $this->assertEquals($url, $crawler->filter('#preview a')->attr('href'));
+ }
+
+ public function test_allowed_schemes_links()
+ {
+ $text = 'http://example.org/ tcp://localhost:22/ServiceName';
+
+ $this->login();
+ $this->admin_login();
+
+ // Post with default settings
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => $text,
+ ));
+ $crawler = self::submit($form);
+ $this->assertContains(
+ '<a href="http://example.org/" class="postlink">http://example.org/</a> tcp://localhost:22/ServiceName',
+ $crawler->filter('#preview .content')->html()
+ );
+
+ // Update allowed schemes
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+ $values['config[allowed_schemes_links]'] = 'https,tcp';
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertEquals(1, $crawler->filter('.successbox')->count());
+
+ // Post with new settings
+ $crawler = self::request('GET', 'posting.php?mode=post&f=2');
+ $form = $crawler->selectButton('Preview')->form(array(
+ 'subject' => 'Test subject',
+ 'message' => $text,
+ ));
+ $crawler = self::submit($form);
+ $this->assertContains(
+ 'http://example.org/ <a href="tcp://localhost:22/ServiceName" class="postlink">tcp://localhost:22/ServiceName</a>',
+ $crawler->filter('#preview .content')->html()
+ );
+ }
}
diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php
index 1f6dc3a979..ce709524a9 100644
--- a/tests/functional/private_messages_test.php
+++ b/tests/functional/private_messages_test.php
@@ -66,4 +66,45 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());
}
+
+ public function test_quote_post()
+ {
+ $text = 'Test post';
+
+ $this->login();
+ $topic = $this->create_topic(2, 'Test Topic 1', 'Test topic');
+ $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+
+ $expected = '(\\[quote=admin post_id=' . $post['post_id'] . ' time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])';
+
+ $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid);
+
+ $this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
+ }
+
+ public function test_quote_pm()
+ {
+ $text = 'This is a test private message sent by the testing framework.';
+ $expected = "(\\[quote=admin msg_id=\\d+ time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])";
+
+ $this->login();
+ $message_id = $this->create_private_message('Test', $text, array(2));
+
+ $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quote&p=' . $message_id . '&sid=' . $this->sid);
+
+ $this->assertRegexp($expected, $crawler->filter('textarea#message')->text());
+ }
+
+ public function test_quote_forward()
+ {
+ $text = 'This is a test private message sent by the testing framework.';
+ $expected = "[quote=admin]\n" . $text . "\n[/quote]";
+
+ $this->login();
+ $message_id = $this->create_private_message('Test', $text, array(2));
+
+ $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid);
+
+ $this->assertContains($expected, $crawler->filter('textarea#message')->text());
+ }
}
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index c014119b98..2bf0280d62 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -77,7 +77,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Prune Shadow'], $this->post['topic_id'], 'Re: Prune Shadow #1-#2', 'This is a test post posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('Re: Prune Shadow #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $post2['post_id'];
diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php
index 690f4ae9f2..48982edc8c 100644
--- a/tests/functional/registration_test.php
+++ b/tests/functional/registration_test.php
@@ -36,6 +36,10 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case
{
$this->add_lang('ucp');
+ // Check that we can't skip
+ self::request('GET', 'ucp.php?mode=register&agreed=1');
+ $this->assertContainsLang('AGREE', $this->get_content());
+
$crawler = self::request('GET', 'ucp.php?mode=register');
$this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text());
@@ -64,4 +68,54 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case
$this->assert_checkbox_is_checked($crawler, 'notification.type.post_notification.method.email');
$this->assert_checkbox_is_checked($crawler, 'notification.type.topic_notification.method.email');
}
+
+ /**
+ * @depends test_disable_captcha_on_registration
+ */
+ public function test_register_coppa_account()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}");
+ $form = $crawler->selectButton('Submit')->form();
+ $form['config[coppa_enable]']->setValue('1');
+ $crawler = self::submit($form);
+
+ $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('#main .successbox')->text());
+ $this->logout();
+
+ $this->add_lang('ucp');
+
+ // Check that we can't skip
+ $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1');
+ $this->assertContainsLang('COPPA_BIRTHDAY', $crawler->html());
+
+ $form = $crawler->selectButton('coppa_yes')->form();
+ $crawler = self::submit($form);
+
+ $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text());
+
+ $form = $crawler->selectButton('I agree to these terms')->form();
+ $crawler = self::submit($form);
+
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'username' => 'user-coppa-test',
+ 'email' => 'user-coppa-test@phpbb.com',
+ 'new_password' => 'user-coppa-testuser-coppa-test',
+ 'password_confirm' => 'user-coppa-testuser-coppa-test',
+ ));
+ $form['tz']->select('Europe/Berlin');
+ $crawler = self::submit($form);
+
+ $this->assertContainsLang('ACCOUNT_COPPA', $crawler->filter('#message')->text());
+
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}");
+ $form = $crawler->selectButton('Submit')->form();
+ $form['config[coppa_enable]']->setValue('0');
+ $crawler = self::submit($form);
+ }
}
diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php
index 93a03bd931..36a1a9ee4d 100644
--- a/tests/functional/report_post_captcha_test.php
+++ b/tests/functional/report_post_captcha_test.php
@@ -18,12 +18,13 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca
{
public function test_guest_report_post()
{
- $crawler = self::request('GET', 'report.php?f=2&p=1');
+ $crawler = self::request('GET', 'app.php/post/1/report', array(), false);
+ $this->assert_response_html(403);
$this->add_lang('mcp');
$this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());
$this->set_reporting_guest(1);
- $crawler = self::request('GET', 'report.php?f=2&p=1');
+ $crawler = self::request('GET', 'app.php/post/1/report');
$this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
$this->set_reporting_guest(-1);
}
@@ -31,7 +32,7 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca
public function test_user_report_post()
{
$this->login();
- $crawler = self::request('GET', 'report.php?f=2&p=1');
+ $crawler = self::request('GET', 'app.php/post/1/report');
$this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());
$this->add_lang('mcp');
diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php
index f1e9b517d4..48c444fb76 100644
--- a/tests/functional/search/base.php
+++ b/tests/functional/search/base.php
@@ -36,6 +36,8 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->login();
$this->admin_login();
+ $this->create_search_index('\phpbb\search\fulltext_native');
+
$post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.');
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=settings&sid=' . $this->sid);
@@ -58,6 +60,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->delete_topic($post['topic_id']);
$this->markTestSkipped("Search backend is not supported/running");
}
+
$this->create_search_index();
}
@@ -72,7 +75,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$this->delete_topic($post['topic_id']);
}
- protected function create_search_index()
+ protected function create_search_index($backend = null)
{
$this->add_lang('acp/search');
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid);
@@ -80,7 +83,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
$form_values = $form->getValues();
$form_values = array_merge($form_values,
array(
- 'search_type' => $this->search_backend,
+ 'search_type' => ( ($backend === null) ? $this->search_backend : $backend ),
'action' => 'create',
)
);
diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php
index cd18a0fcae..445c124158 100644
--- a/tests/functional/ucp_groups_test.php
+++ b/tests/functional/ucp_groups_test.php
@@ -54,4 +54,72 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
}
+
+ public function test_create_request_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' => 'request-group'));
+
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, array('group_name' => 'request-group'));
+
+ $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text());
+
+ $group_id = $this->get_group_id('request-group');
+
+ // Make admin group leader
+ $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid);
+ $form = $crawler->filter('input[name=addusers]')->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, [
+ 'leader' => 1,
+ 'usernames' => 'admin',
+ ]);
+
+ $this->assertContainsLang('GROUP_MODS_ADDED', $crawler->filter('#main')->text());
+ }
+
+ /**
+ * @depends test_create_request_group
+ */
+ public function test_request_group_membership()
+ {
+ $this->create_user('request-group-user');
+ $this->login('request-group-user');
+ $this->add_lang('groups');
+
+ $group_id = $this->get_group_id('request-group');
+
+ $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=membership&sid=' . $this->sid);
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, ['selected' => $group_id, 'action' => 'join']);
+ $this->assertContainsLang('GROUP_JOIN_PENDING_CONFIRM', $crawler->text());
+
+ $form = $crawler->selectButton($this->lang('YES'))->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('GROUP_JOINED_PENDING', $crawler->text());
+ }
+
+ /**
+ * @depends test_request_group_membership
+ */
+ public function test_approve_group_membership()
+ {
+ $this->login();
+ $this->add_lang('acp/groups');
+
+ $group_id = $this->get_group_id('request-group');
+ $crawler = self::request('GET', 'ucp.php?i=ucp_groups&mode=manage&action=list&g=' . $group_id . '&sid=' . $this->sid);
+ $form = $crawler->filter('input[name=update]')->selectButton($this->lang('SUBMIT'))->form();
+ $crawler = self::submit($form, [
+ 'mark' => [$crawler->filter('input[name="mark[]"]')->first()->attr('value')],
+ 'action' => 'approve',
+ ]);
+
+ $this->assertContainsLang('USERS_APPROVED', $crawler->text());
+ }
}
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
index 3da78407cf..2361eed066 100644
--- a/tests/functional/user_password_reset_test.php
+++ b/tests/functional/user_password_reset_test.php
@@ -21,25 +21,56 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_password_reset()
{
$this->add_lang('ucp');
- $user_id = $this->create_user('reset-password-test-user');
+ $user_id = $this->create_user('reset-password-test-user', 'reset-password-test-user@test.com');
+ // test without email
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
+
+ // test with non-existent email
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
- 'username' => 'reset-password-test-user',
+ 'email' => 'non-existent@email.com',
));
$crawler = self::submit($form);
- $this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+ // test with correct email
$crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
- 'username' => 'reset-password-test-user',
- 'email' => 'nobody@example.com',
+ 'email' => 'reset-password-test-user@test.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+
+ // Check if columns in database were updated for password reset
+ $this->get_user_data('reset-password-test-user');
+ $this->assertNotNull($this->user_data['user_actkey']);
+ $this->assertNotNull($this->user_data['user_newpasswd']);
+
+ // Create another user with the same email
+ $this->create_user('reset-password-test-user1', 'reset-password-test-user@test.com');
+
+ // Test that username is now also required
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email' => 'reset-password-test-user@test.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('EMAIL_NOT_UNIQUE', $crawler->text());
+
+ // Provide both username and email
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email' => 'reset-password-test-user@test.com',
+ 'username' => 'reset-password-test-user1',
));
$crawler = self::submit($form);
- $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text());
+ $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
// Check if columns in database were updated for password reset
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user1');
$this->assertNotNull($this->user_data['user_actkey']);
$this->assertNotNull($this->user_data['user_newpasswd']);
@@ -73,7 +104,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_activate_new_password($expected, $user_id, $act_key)
{
$this->add_lang('ucp');
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id;
$act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key;
@@ -119,7 +150,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
public function test_acivateAfterDeactivate()
{
// User is active, actkey should not exist
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertEmpty($this->user_data['user_actkey']);
$this->login();
@@ -143,7 +174,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$crawler = self::request('GET', preg_replace('#(.+)(adm/index.php.+)#', '$2', $link->getUri()));
// Ensure again that actkey is empty after deactivation
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertEmpty($this->user_data['user_actkey']);
// Force reactivation of account and check that act key is not empty anymore
@@ -152,16 +183,16 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$crawler = self::submit($form, array('action' => 'reactivate'));
$this->assertContainsLang('FORCE_REACTIVATION_SUCCESS', $crawler->filter('html')->text());
- $this->get_user_data();
+ $this->get_user_data('reset-password-test-user');
$this->assertNotEmpty($this->user_data['user_actkey']);
}
- protected function get_user_data()
+ protected function get_user_data($username)
{
$db = $this->get_db();
$sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
FROM ' . USERS_TABLE . "
- WHERE username = 'reset-password-test-user'";
+ WHERE username = '" . $db->sql_escape($username) . "'";
$result = $db->sql_query($sql);
$this->user_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php
index 6450c00c1e..fd994361a5 100644
--- a/tests/functional/visibility_softdelete_test.php
+++ b/tests/functional/visibility_softdelete_test.php
@@ -97,7 +97,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text());
$this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $post2['post_id'];
@@ -114,7 +114,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
// Test creating another reply
$post3 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#3', 'This is another test post posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post3['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post3['post_id']}&sid={$this->sid}");
$this->assertContains('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text());
$this->data['posts']['Re: Soft Delete Topic #1-#3'] = (int) $post3['post_id'];
diff --git a/tests/functional/visit_installer_test.php b/tests/functional/visit_installer_test.php
new file mode 100644
index 0000000000..b4a75c0b51
--- /dev/null
+++ b/tests/functional/visit_installer_test.php
@@ -0,0 +1,30 @@
+<?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.
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_visit_installer_test extends phpbb_functional_test_case
+{
+ public function test_visit_installer()
+ {
+ self::request('GET', 'install/', [], false);
+ $this->assertContains('<meta http-equiv="refresh" content="0; url=./app.php" />', $this->get_content());
+
+ self::request('GET', 'install/index.html', [], false);
+ $this->assertContains('<meta http-equiv="refresh" content="0; url=./app.php" />', $this->get_content());
+
+ self::request('GET', 'install/app.php');
+ $this->assertContains('installation system', $this->get_content());
+ }
+}