aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-06-18 18:08:44 +0200
committerMarc Alexander <admin@m-a-styles.de>2013-06-18 18:08:44 +0200
commit2996120e97dabda684f1aadfd0b7a8c5fd298c24 (patch)
treed8764746945868997b8dc4df3ff9c1e71123a3f2 /tests/functional
parentaf8c4b29009548fd1a28c3210c4734d84e4ebb48 (diff)
parent80747a053073582fd3bcdcfff405cebcae52945f (diff)
downloadforums-2996120e97dabda684f1aadfd0b7a8c5fd298c24.tar
forums-2996120e97dabda684f1aadfd0b7a8c5fd298c24.tar.gz
forums-2996120e97dabda684f1aadfd0b7a8c5fd298c24.tar.bz2
forums-2996120e97dabda684f1aadfd0b7a8c5fd298c24.tar.xz
forums-2996120e97dabda684f1aadfd0b7a8c5fd298c24.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/11531
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/acp_groups_test.php99
-rw-r--r--tests/functional/acp_permissions_test.php19
-rw-r--r--tests/functional/auth_test.php15
-rw-r--r--tests/functional/browse_test.php9
-rw-r--r--tests/functional/common_groups_test.php38
-rw-r--r--tests/functional/extension_acp_test.php74
-rw-r--r--tests/functional/extension_controller_test.php76
-rw-r--r--tests/functional/extension_module_test.php49
-rw-r--r--tests/functional/extension_permission_lang_test.php50
-rw-r--r--tests/functional/fileupload_form_test.php5
-rw-r--r--tests/functional/fileupload_remote_test.php5
-rw-r--r--tests/functional/forgot_password_test.php15
-rw-r--r--tests/functional/memberlist_test.php28
-rw-r--r--tests/functional/metadata_manager_test.php44
-rw-r--r--tests/functional/notification_test.php3
-rw-r--r--tests/functional/posting_test.php17
-rw-r--r--tests/functional/ucp_groups_test.php32
17 files changed, 269 insertions, 309 deletions
diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php
index 3d8cabb086..cdf8bf5117 100644
--- a/tests/functional/acp_groups_test.php
+++ b/tests/functional/acp_groups_test.php
@@ -14,8 +14,107 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
*/
class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test
{
+ protected $form_data;
+
protected function get_url()
{
return 'adm/index.php?i=groups&mode=manage&action=edit';
}
+
+ public function acp_group_test_data()
+ {
+ return array(
+ 'both_yes' => array(
+ 5,
+ true,
+ true,
+ ),
+ 'legend_no_teampage' => array(
+ 5,
+ true,
+ false,
+ ),
+ 'no_legend_teampage' => array(
+ 5,
+ false,
+ true,
+ ),
+ 'both_no' => array(
+ 5,
+ false,
+ false,
+ ),
+ 'no_change' => array(
+ 5,
+ NULL,
+ NULL,
+ ),
+ 'back_to_default' => array(
+ 5,
+ true,
+ true,
+ ),
+ // Remove and add moderators back in order to reset
+ // group order to default one
+ 'mods_both_no' => array(
+ 4,
+ false,
+ false,
+ ),
+ 'mods_back_to_default' => array(
+ 4,
+ true,
+ true,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider acp_group_test_data
+ */
+ public function test_acp_groups_teampage($group_id, $tick_legend, $tick_teampage)
+ {
+ $this->group_manage_login();
+
+ // Manage Administrators group
+ $form = $this->get_group_manage_form($group_id);
+ $this->form_data[0] = $form->getValues();
+
+ if (isset($tick_legend) && isset($tick_teampage))
+ {
+ if ($tick_legend)
+ {
+ $form['group_legend']->tick();
+ }
+ else
+ {
+ $form['group_legend']->untick();
+ }
+
+ if ($tick_teampage)
+ {
+ $form['group_teampage']->tick();
+ }
+ else
+ {
+ $form['group_teampage']->untick();
+ }
+ }
+ $crawler = self::submit($form);
+ $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
+
+ $form = $this->get_group_manage_form($group_id);
+ if (!isset($tick_legend) && !isset($tick_teampage))
+ {
+ $this->form_data[1] = $form->getValues();
+ unset($this->form_data[0]['creation_time'], $this->form_data[0]['form_token'], $this->form_data[1]['creation_time'], $this->form_data[1]['form_token']);
+ $this->assertEquals($this->form_data[0], $this->form_data[1]);
+ }
+ else
+ {
+ $this->form_data = $form->getValues();
+ $this->assertEquals($tick_legend, $this->form_data['group_legend']);
+ $this->assertEquals($tick_teampage, $this->form_data['group_teampage']);
+ }
+ }
}
diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php
index f7fd44fc89..a3d272906f 100644
--- a/tests/functional/acp_permissions_test.php
+++ b/tests/functional/acp_permissions_test.php
@@ -25,25 +25,22 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
{
// Permissions tab
// XXX hardcoded id
- $crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
// these language strings are html
- $this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
+ $this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->get_content());
}
public function test_select_user()
{
// User permissions
- $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
- $this->assert_response_success();
- $this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
+ $crawler = self::request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
+ $this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->get_content());
// Select admin
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$data = array('username[0]' => 'admin');
$form->setValues($data);
- $crawler = $this->client->submit($form);
- $this->assert_response_success();
+ $crawler = self::submit($form);
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
}
@@ -91,8 +88,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
public function test_change_permission($description, $permission_type, $permission, $mode, $object_name, $object_id)
{
// Get the form
- $crawler = $this->request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid);
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
// XXX globals for phpbb_auth, refactor it later
@@ -114,8 +110,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
// set to never
$data = array("setting[$object_id][0][$permission]" => '0');
$form->setValues($data);
- $crawler = $this->client->submit($form);
- $this->assert_response_success();
+ $crawler = self::submit($form);
$this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text());
// check acl again
diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php
index f92a4a2210..ff4d3ced5c 100644
--- a/tests/functional/auth_test.php
+++ b/tests/functional/auth_test.php
@@ -17,8 +17,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->login();
// check for logout link
- $crawler = $this->request('GET', 'index.php');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'index.php');
$this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
}
@@ -26,8 +25,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
{
$this->create_user('anothertestuser');
$this->login('anothertestuser');
- $crawler = $this->request('GET', 'index.php');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'index.php');
$this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text());
}
@@ -40,13 +38,11 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->add_lang('ucp');
// logout
- $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
// look for a register link, which should be visible only when logged out
- $crawler = $this->request('GET', 'index.php');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'index.php');
$this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
}
@@ -56,8 +52,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->admin_login();
// check that we are logged in
- $crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
$this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
}
}
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php
index b5748059c6..18a2ad9464 100644
--- a/tests/functional/browse_test.php
+++ b/tests/functional/browse_test.php
@@ -14,22 +14,19 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
{
public function test_index()
{
- $crawler = $this->request('GET', 'index.php');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'index.php');
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
}
public function test_viewforum()
{
- $crawler = $this->request('GET', 'viewforum.php?f=2');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'viewforum.php?f=2');
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
}
public function test_viewtopic()
{
- $crawler = $this->request('GET', 'viewtopic.php?t=1');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'viewtopic.php?t=1');
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
}
}
diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php
index cc6afa54b9..8c014aebed 100644
--- a/tests/functional/common_groups_test.php
+++ b/tests/functional/common_groups_test.php
@@ -14,6 +14,28 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
{
abstract protected function get_url();
+ /**
+ * Get group_manage form
+ * @param int $group_id ID of the group that should be managed
+ */
+ protected function get_group_manage_form($group_id = 5)
+ {
+ // Manage Administrators group
+ $crawler = self::request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ return $form;
+ }
+
+ /**
+ * Execute login calls and add_lang() calls for tests
+ */
+ protected function group_manage_login()
+ {
+ $this->login();
+ $this->admin_login();
+ $this->add_lang(array('ucp', 'acp/groups'));
+ }
+
public function groups_manage_test_data()
{
return array(
@@ -30,22 +52,12 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
*/
public function test_groups_manage($input, $expected)
{
- $this->markTestIncomplete(
- 'Test fails on develop due to another test deleting the Administrators group.'
- );
- // See https://github.com/phpbb/phpbb3/pull/1407#issuecomment-18465480
- // and https://gist.github.com/bantu/22dc4f6c6c0b8f9e0fa1
-
- $this->login();
- $this->admin_login();
- $this->add_lang(array('ucp', 'acp/groups'));
+ $this->group_manage_login();
// Manage Administrators group
- $crawler = $this->request('GET', $this->get_url() . '&g=5&sid=' . $this->sid);
- $this->assert_response_success();
- $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $form = $this->get_group_manage_form();
$form['group_colour']->setValue($input);
- $crawler = $this->client->submit($form);
+ $crawler = self::submit($form);
$this->assertContains($this->lang($expected), $crawler->text());
}
}
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 1b406e5042..8614c0c963 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -12,34 +12,25 @@
*/
class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
{
- static private $copied_files = array();
static private $helper;
- /**
- * This should only be called once before the tests are run.
- * This is used to copy the extensions to the phpBB install
- */
+ static protected $fixtures = array(
+ './',
+ );
+
static public function setUpBeforeClass()
{
- global $phpbb_root_path;
-
parent::setUpBeforeClass();
self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures);
+ }
- self::$copied_files = array();
-
- if (file_exists($phpbb_root_path . 'ext/'))
- {
- // First, move any extensions setup on the board to a temp directory
- self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
-
- // Then empty the ext/ directory on the board (for accurate test cases)
- self::$helper->empty_dir($phpbb_root_path . 'ext/');
- }
+ static public function tearDownAfterClass()
+ {
+ parent::tearDownAfterClass();
- // Copy our ext/ files from the test case to the board
- self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/../extension/ext/', $phpbb_root_path . 'ext/'));
+ self::$helper->restore_original_ext_dir();
}
public function setUp()
@@ -84,32 +75,9 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->add_lang('acp/extensions');
}
- /**
- * This should only be called once after the tests are run.
- * This is used to remove the files copied to the phpBB install
- */
- static public function tearDownAfterClass()
- {
- global $phpbb_root_path;
-
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- // Copy back the board installed extensions from the temp directory
- self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
- }
-
- // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
- self::$helper->remove_files(self::$copied_files);
-
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
- }
- }
-
public function test_list()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertCount(1, $crawler->filter('.ext_enabled'));
$this->assertCount(5, $crawler->filter('.ext_disabled'));
@@ -131,7 +99,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_details()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
$validation = array(
'DISPLAY_NAME' => 'phpBB Foo Extension',
@@ -174,46 +142,46 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_enable_pre()
{
// Foo is already enabled (redirect to list)
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text());
}
public function test_disable_pre()
{
// Moo is not enabled (redirect to list)
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text());
}
public function test_purge_pre()
{
// test2 is not available (error)
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid);
$this->assertContains('The required file does not exist', $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text());
}
public function test_actions()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text());
}
} \ No newline at end of file
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index f28b321942..9ddf1e3e5c 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -6,6 +6,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
/**
* @group functional
@@ -14,65 +15,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
protected $phpbb_extension_manager;
+ static private $helper;
+
static protected $fixtures = array(
- 'foo/bar/config/routing.yml',
- 'foo/bar/config/services.yml',
- 'foo/bar/controller/controller.php',
- 'foo/bar/styles/prosilver/template/foo_bar_body.html',
+ 'foo/bar/config/',
+ 'foo/bar/controller/',
+ 'foo/bar/styles/prosilver/template/',
);
- /**
- * This should only be called once before the tests are run.
- * This is used to copy the fixtures to the phpBB install
- */
static public function setUpBeforeClass()
{
- global $phpbb_root_path;
parent::setUpBeforeClass();
- $directories = array(
- $phpbb_root_path . 'ext/foo/bar/',
- $phpbb_root_path . 'ext/foo/bar/config/',
- $phpbb_root_path . 'ext/foo/bar/controller/',
- $phpbb_root_path . 'ext/foo/bar/styles/prosilver/template',
- );
-
- foreach ($directories as $dir)
- {
- if (!is_dir($dir))
- {
- mkdir($dir, 0777, true);
- }
- }
-
- foreach (self::$fixtures as $fixture)
- {
- copy(
- "tests/functional/fixtures/ext/$fixture",
- "{$phpbb_root_path}ext/$fixture");
- }
+ self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- /**
- * This should only be called once after the tests are run.
- * This is used to remove the fixtures from the phpBB install
- */
static public function tearDownAfterClass()
{
- global $phpbb_root_path;
-
- foreach (self::$fixtures as $fixture)
- {
- unlink("{$phpbb_root_path}ext/$fixture");
- }
+ parent::tearDownAfterClass();
- rmdir("{$phpbb_root_path}ext/foo/bar/config");
- rmdir("{$phpbb_root_path}ext/foo/bar/controller");
- rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver/template");
- rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver");
- rmdir("{$phpbb_root_path}ext/foo/bar/styles");
- rmdir("{$phpbb_root_path}ext/foo/bar");
- rmdir("{$phpbb_root_path}ext/foo");
+ self::$helper->restore_original_ext_dir();
}
public function setUp()
@@ -90,8 +53,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_foo_bar()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = $this->request('GET', 'app.php?controller=foo/bar');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'app.php?controller=foo/bar', array(), false);
+ self::assert_response_status_code();
$this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -102,8 +65,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_controller_with_template()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = $this->request('GET', 'app.php?controller=foo/template');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'app.php?controller=foo/template');
$this->assertContains("I am a variable", $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -115,8 +77,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_missing_argument()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = $this->request('GET', 'app.php?controller=foo/baz');
- $this->assertEquals(500, $this->client->getResponse()->getStatus());
+ $crawler = self::request('GET', 'app.php?controller=foo/baz', array(), false);
+ $this->assert_response_html(500);
$this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -127,8 +89,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function test_exception_should_result_in_500_status_code()
{
$this->phpbb_extension_manager->enable('foo/bar');
- $crawler = $this->request('GET', 'app.php?controller=foo/exception');
- $this->assertEquals(500, $this->client->getResponse()->getStatus());
+ $crawler = self::request('GET', 'app.php?controller=foo/exception', array(), false);
+ $this->assert_response_html(500);
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
@@ -144,8 +106,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
*/
public function test_error_ext_disabled_or_404()
{
- $crawler = $this->request('GET', 'app.php?controller=does/not/exist');
- $this->assertEquals(404, $this->client->getResponse()->getStatus());
+ $crawler = self::request('GET', 'app.php?controller=does/not/exist', array(), false);
+ $this->assert_response_html(404);
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
}
}
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index cf67675a28..c573ea5410 100644
--- a/tests/functional/extension_module_test.php
+++ b/tests/functional/extension_module_test.php
@@ -16,56 +16,26 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php';
class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
- static private $copied_files = array();
+
static private $helper;
- /**
- * This should only be called once before the tests are run.
- * This is used to copy the fixtures to the phpBB install
- */
+ static protected $fixtures = array(
+ './',
+ );
+
static public function setUpBeforeClass()
{
- global $phpbb_root_path;
parent::setUpBeforeClass();
self::$helper = new phpbb_test_case_helpers(self);
-
- self::$copied_files = array();
-
- if (file_exists($phpbb_root_path . 'ext/'))
- {
- // First, move any extensions setup on the board to a temp directory
- self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
-
- // Then empty the ext/ directory on the board (for accurate test cases)
- self::$helper->empty_dir($phpbb_root_path . 'ext/');
- }
-
- // Copy our ext/ files from the test case to the board
- self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/', $phpbb_root_path . 'ext/'));
+ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- /**
- * This should only be called once after the tests are run.
- * This is used to remove the fixtures from the phpBB install
- */
static public function tearDownAfterClass()
{
- global $phpbb_root_path;
-
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- // Copy back the board installed extensions from the temp directory
- self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
- }
-
- // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
- self::$helper->remove_files(self::$copied_files);
+ parent::tearDownAfterClass();
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
- }
+ self::$helper->restore_original_ext_dir();
}
public function setUp()
@@ -122,8 +92,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
{
$this->login();
$this->admin_login();
- $crawler = $this->request('GET', 'adm/index.php?i=phpbb_ext_foo_bar_acp_main_module&mode=mode&sid=' . $this->sid, array(), true);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?i=phpbb_ext_foo_bar_acp_main_module&mode=mode&sid=' . $this->sid);
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 26ec4d28a1..6c1720735c 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -16,59 +16,23 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
static private $helper;
- static private $copied_files = array();
-
static protected $fixtures = array(
'foo/bar/language/en/',
);
- /**
- * This should only be called once before the tests are run.
- * This is used to copy the fixtures to the phpBB install
- */
static public function setUpBeforeClass()
{
- global $phpbb_root_path;
parent::setUpBeforeClass();
self::$helper = new phpbb_test_case_helpers(self);
-
- self::$copied_files = array();
-
- if (file_exists($phpbb_root_path . 'ext/'))
- {
- // First, move any extensions setup on the board to a temp directory
- self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
-
- // Then empty the ext/ directory on the board (for accurate test cases)
- self::$helper->empty_dir($phpbb_root_path . 'ext/');
- }
-
- // Copy our ext/ files from the test case to the board
- self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture));
+ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- /**
- * This should only be called once after the tests are run.
- * This is used to remove the fixtures from the phpBB install
- */
static public function tearDownAfterClass()
{
- global $phpbb_root_path;
-
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- // Copy back the board installed extensions from the temp directory
- self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
- }
-
- // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
- self::$helper->remove_files(self::$copied_files);
-
- if (file_exists($phpbb_root_path . 'store/temp_ext/'))
- {
- self::$helper->empty_dir($phpbb_root_path . 'store/temp_ext/');
- }
+ parent::tearDownAfterClass();
+
+ self::$helper->restore_original_ext_dir();
}
public function setUp()
@@ -99,15 +63,13 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
$this->phpbb_extension_manager->enable('foo/bar');
// User permissions
- $crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
// Select admin
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$data = array('username[0]' => 'admin');
$form->setValues($data);
- $crawler = $this->client->submit($form);
- $this->assert_response_success();
+ $crawler = self::submit($form);
// language from language/en/acp/permissions_phpbb.php
$this->assertContains('Can attach files', $crawler->filter('body')->text());
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index b663c89e95..998c402fa3 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -32,7 +32,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
'error' => UPLOAD_ERR_OK,
);
- $crawler = $this->client->request(
+ $crawler = self::$client->request(
'POST',
'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
array('add_file' => $this->lang('ADD_FILE')),
@@ -66,9 +66,8 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
{
$this->markTestIncomplete('Test fails intermittently.');
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
- $this->assert_response_success();
// ensure there was no error message rendered
- $this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->client->getResponse()->getContent());
+ $this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->get_content());
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
}
}
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 0deb79acf6..8e361ab77b 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -58,7 +58,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
public function test_successful_upload()
{
$upload = new fileupload('', array('gif'), 1000);
- $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif');
+ $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));
}
@@ -66,7 +66,8 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
public function test_too_large()
{
$upload = new fileupload('', array('gif'), 100);
- $file = $upload->remote_upload($this->root_url . 'styles/prosilver/theme/images/forum_read.gif');
+ $file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
+ $this->assertEquals(1, sizeof($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
}
}
diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php
index bfb4616d64..906224efbb 100644
--- a/tests/functional/forgot_password_test.php
+++ b/tests/functional/forgot_password_test.php
@@ -16,8 +16,7 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
{
global $config;
$this->add_lang('ucp');
- $crawler = $this->request('GET', 'ucp.php?mode=sendpassword');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'ucp.php?mode=sendpassword');
$this->assertEquals($this->lang('SEND_PASSWORD'), $crawler->filter('h2')->text());
}
@@ -26,24 +25,18 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
$this->login();
$this->admin_login();
$this->add_lang('ucp');
- $crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=security');
- $this->assertEquals(200, $this->client->getResponse()->getStatus());
- $content = $this->client->getResponse()->getContent();
- $this->assertNotContains('Fatal error:', $content);
- $this->assertNotContains('Notice:', $content);
- $this->assertNotContains('[phpBB Debug]', $content);
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=security');
$form = $crawler->selectButton('Submit')->form();
$values = $form->getValues();
$values["config[allow_password_reset]"] = 0;
$form->setValues($values);
- $crawler = $this->client->submit($form);
+ $crawler = self::submit($form);
$this->logout();
- $crawler = $this->request('GET', 'ucp.php?mode=sendpassword');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'ucp.php?mode=sendpassword');
$this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
}
diff --git a/tests/functional/memberlist_test.php b/tests/functional/memberlist_test.php
index 92ede8bd04..738ec4f9dd 100644
--- a/tests/functional/memberlist_test.php
+++ b/tests/functional/memberlist_test.php
@@ -17,18 +17,15 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$this->create_user('memberlist-test-user');
// logs in as admin
$this->login();
- $crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'memberlist.php?sid=' . $this->sid);
$this->assertContains('memberlist-test-user', $crawler->text());
// restrict by first character
- $crawler = $this->request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
$this->assertContains('memberlist-test-user', $crawler->text());
// make sure results for wrong character are not returned
- $crawler = $this->request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
$this->assertNotContains('memberlist-test-user', $crawler->text());
}
@@ -36,16 +33,13 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
{
$this->login();
// XXX hardcoded user id
- $crawler = $this->request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
$this->assertContains('admin', $crawler->filter('h2')->text());
}
protected function get_memberlist_leaders_table_crawler()
{
- $crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
- $this->assert_response_success();
-
+ $crawler = self::request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
return $crawler->filter('.forumbg-table');
}
@@ -95,5 +89,17 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$crawler = $this->get_memberlist_leaders_table_crawler();
$this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text());
$this->assertContains('memberlist-test-moderator', $crawler->eq(1)->text());
+
+ // Add admin to moderators, should be visible as moderator
+ $this->add_user_group('GLOBAL_MODERATORS', array('admin'), true);
+ $crawler = $this->get_memberlist_leaders_table_crawler();
+ $this->assertNotContains('admin', $crawler->eq(0)->text());
+ $this->assertContains('admin', $crawler->eq(1)->text());
+
+ // Add admin to admins as leader, should be visible as admin, not moderator
+ $this->add_user_group('ADMINISTRATORS', array('admin'), true, true);
+ $crawler = $this->get_memberlist_leaders_table_crawler();
+ $this->assertContains('admin', $crawler->eq(0)->text());
+ $this->assertNotContains('admin', $crawler->eq(1)->text());
}
}
diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php
index 0125886e04..c55e7373ea 100644
--- a/tests/functional/metadata_manager_test.php
+++ b/tests/functional/metadata_manager_test.php
@@ -16,47 +16,25 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
- static private $helpers;
+ static private $helper;
static protected $fixtures = array(
'foo/bar/',
);
- /**
- * This should only be called once before the tests are run.
- * This is used to copy the fixtures to the phpBB install
- */
static public function setUpBeforeClass()
{
- global $phpbb_root_path;
parent::setUpBeforeClass();
- self::$helpers = new phpbb_test_case_helpers(self);
-
- if (!file_exists($phpbb_root_path . 'ext/foo/bar/'))
- {
- self::$helpers->makedirs($phpbb_root_path . 'ext/foo/bar/');
- }
-
- foreach (self::$fixtures as $fixture)
- {
- self::$helpers->copy_dir(dirname(__FILE__) . '/fixtures/ext/' . $fixture, $phpbb_root_path . 'ext/' . $fixture);
- }
+ self::$helper = new phpbb_test_case_helpers(self);
+ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures);
}
- /**
- * This should only be called once after the tests are run.
- * This is used to remove the fixtures from the phpBB install
- */
static public function tearDownAfterClass()
{
- global $phpbb_root_path;
+ parent::tearDownAfterClass();
- foreach (self::$fixtures as $fixture)
- {
- self::$helpers->empty_dir($phpbb_root_path . 'ext/' . $fixture);
- }
- self::$helpers->empty_dir($phpbb_root_path . 'ext/foo/');
+ self::$helper->restore_original_ext_dir();
}
public function setUp()
@@ -75,9 +53,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
public function test_extensions_list()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
- $this->assert_response_success();
-
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text());
$this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text());
$this->assertContains('Details', $crawler->filter('#main')->text());
@@ -85,8 +61,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
public function test_extensions_details()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid);
// Test whether the details are displayed
$this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text());
@@ -97,13 +72,12 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
// Details should be html escaped
// However, text() only returns the displayed text, so HTML Special Chars are decoded.
// So we test this directly on the content of the response.
- $this->assertContains('<p id="require_php">&gt;=5.3</p>', $this->client->getResponse()->getContent());
+ $this->assertContains('<p id="require_php">&gt;=5.3</p>', $this->get_content());
}
public function test_extensions_details_notexists()
{
- $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid);
- $this->assert_response_success();
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid);
// Error message because the files do not exist
$this->assertContains('The required file does not exist:', $crawler->filter('#main')->text());
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index fa6513a0ba..7f33ad1859 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -40,8 +40,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
public function test_user_subscriptions($checkbox_name, $expected_status)
{
$this->login();
- $crawler = $this->request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
- $this->assert_response_success();
+ $crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
$cplist = $crawler->filter('.table1');
if ($expected_status)
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index d05207edf0..9bcfcc2fda 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -19,18 +19,17 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
// Test creating topic
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
- $crawler = $this->request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
$this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
// Test creating a reply
$post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post posted by the testing framework.');
- $crawler = $this->request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
// Test quoting a message
- $crawler = $this->request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
- $this->assert_response_success();
+ $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
}
@@ -55,7 +54,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
'post' => true,
), $additional_form_data);
- return $this->submit_post($posting_url, 'POST_TOPIC', $form_data);
+ return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
}
/**
@@ -79,7 +78,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
'post' => true,
), $additional_form_data);
- return $this->submit_post($posting_url, 'POST_REPLY', $form_data);
+ return self::submit_post($posting_url, 'POST_REPLY', $form_data);
}
/**
@@ -94,8 +93,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->add_lang('posting');
- $crawler = $this->request('GET', $posting_url);
- $this->assert_response_success();
+ $crawler = self::request('GET', $posting_url);
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
$hidden_fields = array(
@@ -119,8 +117,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
// I use a request because the form submission method does not allow you to send data that is not
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
// Instead, I send it as a request with the submit button "post" set to true.
- $crawler = $this->client->request('POST', $posting_url, $form_data);
- $this->assert_response_success();
+ $crawler = self::request('POST', $posting_url, $form_data);
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php
index 9c6b1edc5e..f48c793ea1 100644
--- a/tests/functional/ucp_groups_test.php
+++ b/tests/functional/ucp_groups_test.php
@@ -14,8 +14,40 @@ require_once dirname(__FILE__) . '/common_groups_test.php';
*/
class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test
{
+ protected $db;
+
protected function get_url()
{
return 'ucp.php?i=groups&mode=manage&action=edit';
}
+
+ protected function get_teampage_settings()
+ {
+ if (!isset($this->db))
+ {
+ $this->db = $this->get_db();
+ }
+ $sql = 'SELECT g.group_legend AS group_legend, t.teampage_position AS group_teampage
+ FROM ' . GROUPS_TABLE . ' g
+ LEFT JOIN ' . TEAMPAGE_TABLE . ' t
+ ON (t.group_id = g.group_id)
+ WHERE g.group_id = 5';
+ $result = $this->db->sql_query($sql);
+ $group_row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+ return $group_row;
+ }
+
+ public function test_ucp_groups_teampage()
+ {
+ $this->group_manage_login();
+
+ // Test if group_legend or group_teampage are modified while
+ // submitting the ucp_group_manage page
+ $form = $this->get_group_manage_form();
+ $teampage_settings = $this->get_teampage_settings();
+ $crawler = self::submit($form);
+ $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
+ $this->assertEquals($teampage_settings, $this->get_teampage_settings());
+ }
}