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_profile_field_test.php71
-rw-r--r--tests/functional/common_avatar_test_case.php2
-rw-r--r--tests/functional/download_test.php15
-rw-r--r--tests/functional/fileupload_form_test.php23
-rw-r--r--tests/functional/prune_shadow_topic_test.php2
6 files changed, 182 insertions, 9 deletions
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php
new file mode 100644
index 0000000000..8e810a508a
--- /dev/null
+++ b/tests/functional/acp_attachments_test.php
@@ -0,0 +1,78 @@
+<?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_profile_field_test.php b/tests/functional/acp_profile_field_test.php
new file mode 100644
index 0000000000..88df782faa
--- /dev/null
+++ b/tests/functional/acp_profile_field_test.php
@@ -0,0 +1,71 @@
+<?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_profile_field_test extends phpbb_functional_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->login();
+ $this->admin_login();
+ $this->add_lang('acp/profile');
+ }
+
+ public function data_add_profile_field()
+ {
+ return array(
+ array('bool', 'profilefields.type.bool',
+ array(
+ 'lang_options[0]' => 'foo',
+ 'lang_options[1]' => 'bar',
+ ),
+ array(),
+ ),
+ array('dropdown', 'profilefields.type.dropdown',
+ array(
+ 'lang_options' => "foo\nbar\nbar\nfoo",
+ ),
+ array(),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider data_add_profile_field
+ */
+ public function test_add_profile_field($name, $type, $page1_settings, $page2_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);
+
+ // Fill form for profile field options
+ $form = $crawler->selectButton('Profile type specific options')->form($page1_settings);
+ $crawler = self::submit($form);
+
+ // Fill form for profile field specific options
+ $form = $crawler->selectButton('Save')->form($page2_settings);
+ $crawler= self::submit($form);
+
+ $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
+ }
+}
diff --git a/tests/functional/common_avatar_test_case.php b/tests/functional/common_avatar_test_case.php
index 7278f23bcc..924eb1273c 100644
--- a/tests/functional/common_avatar_test_case.php
+++ b/tests/functional/common_avatar_test_case.php
@@ -62,7 +62,7 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional
{
if (is_array($value))
{
- $form[$key]->$value[0]($value[1]);
+ $form[$key]->{$value[0]}($value[1]);
}
else
{
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 4e4995c21e..1e863210e6 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -66,6 +66,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_accessible()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
@@ -118,6 +123,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_softdeleted_post()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
@@ -180,6 +190,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_softdeleted_topic()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index b8c48389e0..d381fa1ae2 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -93,23 +93,32 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$this->login();
$this->admin_login();
$this->add_lang('ucp');
- $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
- $form = $crawler->selectButton('Submit')->form();
- $values = $form->getValues();
+ // Make sure check_attachment_content is set to false
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
- $values["config[check_attachment_content]"] = 0;
- $form->setValues($values);
- $crawler = self::submit($form);
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'config[check_attachment_content]' => 0,
+ 'config[img_imagick]' => '',
+ ));
+ self::submit($form);
// Request index for correct URL
- $crawler = self::request('GET', 'index.php?sid=' . $this->sid);
+ self::request('GET', 'index.php?sid=' . $this->sid);
$crawler = $this->upload_file('disallowed.jpg', 'image/jpeg');
// Hitting the UNABLE_GET_IMAGE_SIZE error means we passed the
// DISALLOWED_CONTENT check
$this->assertContainsLang('UNABLE_GET_IMAGE_SIZE', $crawler->text());
+
+ // Reset check_attachment_content to default (enabled)
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
+
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'config[check_attachment_content]' => 1,
+ ));
+ self::submit($form);
}
public function test_too_large()
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index f00303060d..c014119b98 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -62,7 +62,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$crawler = self::request('GET', "viewtopic.php?t={$this->post['topic_id']}&sid={$this->sid}");
$this->assertContains('Prune Shadow #1', $crawler->filter('html')->text());
- $this->data['topics']['Prune Shadow #1'] = (int) $post['topic_id'];
+ $this->data['topics']['Prune Shadow #1'] = (int) $this->post['topic_id'];
$this->data['posts']['Prune Shadow #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(