mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge remote-tracking branch 'remotes/nickv/ticket/11568-develop' into develop
# By Joas Schilling # Via Joas Schilling * remotes/nickv/ticket/11568-develop: (21 commits) [ticket/11568] Split status code and html debug assertion into two methods [ticket/11568] Add comma at end of array key-value couple [ticket/11568] Invert logic for asserting the response [ticket/11568] Use static calls for static methods [ticket/develop/11568] Remove unneccessary second call with wrong arguments [ticket/11568] Remove unused method [ticket/11568] Only assert string when doctype is there at all [ticket/develop/11568] Fix some more tests in 3.1 [ticket/develop/11568] Remove php extension parameter [ticket/develop/11568] Remove unneccessary calls to assert_response_success() [ticket/develop/11568] Do not directly access $client from tests [ticket/11568] Add method to get page content [ticket/11568] Allow different status codes [ticket/11568] Trim the output to allow Tabs before INCLUDE overall_header [ticket/11568] Fix common_groups_test.php form handling [ticket/11568] Make CookieJar static aswell [ticket/11568] Remove manual calls to assert_response_success() [ticket/11568] Only use a static version of the client [ticket/11568] Any output before the doc type means there was an error [ticket/11568] Set client manually so we can increase the cURL timeout ...
This commit is contained in:
commit
6bc775a75b
18 changed files with 222 additions and 186 deletions
|
@ -100,7 +100,7 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te
|
||||||
$form['group_teampage']->untick();
|
$form['group_teampage']->untick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
|
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
|
||||||
|
|
||||||
$form = $this->get_group_manage_form($group_id);
|
$form = $this->get_group_manage_form($group_id);
|
||||||
|
|
|
@ -25,25 +25,22 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
// Permissions tab
|
// Permissions tab
|
||||||
// XXX hardcoded id
|
// XXX hardcoded id
|
||||||
$crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
|
$crawler = self::request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
// these language strings are html
|
// 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()
|
public function test_select_user()
|
||||||
{
|
{
|
||||||
// User permissions
|
// User permissions
|
||||||
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
|
$crawler = self::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->get_content());
|
||||||
$this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
|
|
||||||
|
|
||||||
// Select admin
|
// Select admin
|
||||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||||
$data = array('username[0]' => 'admin');
|
$data = array('username[0]' => 'admin');
|
||||||
$form->setValues($data);
|
$form->setValues($data);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
|
$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)
|
public function test_change_permission($description, $permission_type, $permission, $mode, $object_name, $object_id)
|
||||||
{
|
{
|
||||||
// Get the form
|
// 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);
|
$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->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
|
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
|
||||||
|
|
||||||
// XXX globals for phpbb_auth, refactor it later
|
// 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
|
// set to never
|
||||||
$data = array("setting[$object_id][0][$permission]" => '0');
|
$data = array("setting[$object_id][0][$permission]" => '0');
|
||||||
$form->setValues($data);
|
$form->setValues($data);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text());
|
$this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text());
|
||||||
|
|
||||||
// check acl again
|
// check acl again
|
||||||
|
|
|
@ -17,8 +17,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
|
||||||
$this->login();
|
$this->login();
|
||||||
|
|
||||||
// check for logout link
|
// check for logout link
|
||||||
$crawler = $this->request('GET', 'index.php');
|
$crawler = self::request('GET', 'index.php');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
|
$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->create_user('anothertestuser');
|
||||||
$this->login('anothertestuser');
|
$this->login('anothertestuser');
|
||||||
$crawler = $this->request('GET', 'index.php');
|
$crawler = self::request('GET', 'index.php');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text());
|
$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');
|
$this->add_lang('ucp');
|
||||||
|
|
||||||
// logout
|
// logout
|
||||||
$crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
||||||
|
|
||||||
// look for a register link, which should be visible only when logged out
|
// look for a register link, which should be visible only when logged out
|
||||||
$crawler = $this->request('GET', 'index.php');
|
$crawler = self::request('GET', 'index.php');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
|
$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();
|
$this->admin_login();
|
||||||
|
|
||||||
// check that we are logged in
|
// check that we are logged in
|
||||||
$crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
|
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
|
$this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,22 +14,19 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
public function test_index()
|
public function test_index()
|
||||||
{
|
{
|
||||||
$crawler = $this->request('GET', 'index.php');
|
$crawler = self::request('GET', 'index.php');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_viewforum()
|
public function test_viewforum()
|
||||||
{
|
{
|
||||||
$crawler = $this->request('GET', 'viewforum.php?f=2');
|
$crawler = self::request('GET', 'viewforum.php?f=2');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_viewtopic()
|
public function test_viewtopic()
|
||||||
{
|
{
|
||||||
$crawler = $this->request('GET', 'viewtopic.php?t=1');
|
$crawler = self::request('GET', 'viewtopic.php?t=1');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
|
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,7 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
|
||||||
protected function get_group_manage_form($group_id = 5)
|
protected function get_group_manage_form($group_id = 5)
|
||||||
{
|
{
|
||||||
// Manage Administrators group
|
// Manage Administrators group
|
||||||
$crawler = $this->request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
|
$crawler = self::request('GET', $this->get_url() . "&g=$group_id&sid=" . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
//var_export($this->client->getResponse()->getContent());
|
|
||||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +57,7 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test
|
||||||
// Manage Administrators group
|
// Manage Administrators group
|
||||||
$form = $this->get_group_manage_form();
|
$form = $this->get_group_manage_form();
|
||||||
$form['group_colour']->setValue($input);
|
$form['group_colour']->setValue($input);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assertContains($this->lang($expected), $crawler->text());
|
$this->assertContains($this->lang($expected), $crawler->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
public function test_list()
|
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(1, $crawler->filter('.ext_enabled'));
|
||||||
$this->assertCount(5, $crawler->filter('.ext_disabled'));
|
$this->assertCount(5, $crawler->filter('.ext_disabled'));
|
||||||
|
@ -131,7 +131,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
public function test_details()
|
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(
|
$validation = array(
|
||||||
'DISPLAY_NAME' => 'phpBB Foo Extension',
|
'DISPLAY_NAME' => 'phpBB Foo Extension',
|
||||||
|
@ -174,46 +174,46 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||||
public function test_enable_pre()
|
public function test_enable_pre()
|
||||||
{
|
{
|
||||||
// Foo is already enabled (redirect to list)
|
// 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_NAME', $crawler->filter('html')->text());
|
||||||
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
|
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
|
||||||
$this->assertContainsLang('EXTENSION_ACTIONS', $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());
|
$this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_disable_pre()
|
public function test_disable_pre()
|
||||||
{
|
{
|
||||||
// Moo is not enabled (redirect to list)
|
// 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_NAME', $crawler->filter('html')->text());
|
||||||
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
|
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
|
||||||
$this->assertContainsLang('EXTENSION_ACTIONS', $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());
|
$this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_purge_pre()
|
public function test_purge_pre()
|
||||||
{
|
{
|
||||||
// test2 is not available (error)
|
// 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());
|
$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());
|
$this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_actions()
|
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());
|
$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());
|
$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());
|
$this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
* @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
|
* @group functional
|
||||||
|
@ -90,8 +91,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
public function test_foo_bar()
|
public function test_foo_bar()
|
||||||
{
|
{
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
$crawler = $this->request('GET', 'app.php?controller=foo/bar');
|
$crawler = self::request('GET', 'app.php?controller=foo/bar', array(), false);
|
||||||
$this->assert_response_success();
|
self::assert_response_status_code();
|
||||||
$this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
|
$this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
|
||||||
$this->phpbb_extension_manager->purge('foo/bar');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
}
|
}
|
||||||
|
@ -102,8 +103,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
public function test_controller_with_template()
|
public function test_controller_with_template()
|
||||||
{
|
{
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
$crawler = $this->request('GET', 'app.php?controller=foo/template');
|
$crawler = self::request('GET', 'app.php?controller=foo/template');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains("I am a variable", $crawler->filter('#content')->text());
|
$this->assertContains("I am a variable", $crawler->filter('#content')->text());
|
||||||
$this->phpbb_extension_manager->purge('foo/bar');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
public function test_missing_argument()
|
public function test_missing_argument()
|
||||||
{
|
{
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
$crawler = $this->request('GET', 'app.php?controller=foo/baz');
|
$crawler = self::request('GET', 'app.php?controller=foo/baz', array(), false);
|
||||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
$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->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');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
}
|
}
|
||||||
|
@ -127,8 +127,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
public function test_exception_should_result_in_500_status_code()
|
public function test_exception_should_result_in_500_status_code()
|
||||||
{
|
{
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
$crawler = $this->request('GET', 'app.php?controller=foo/exception');
|
$crawler = self::request('GET', 'app.php?controller=foo/exception', array(), false);
|
||||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
$this->assert_response_html(500);
|
||||||
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
|
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
|
||||||
$this->phpbb_extension_manager->purge('foo/bar');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
}
|
}
|
||||||
|
@ -144,8 +144,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||||
*/
|
*/
|
||||||
public function test_error_ext_disabled_or_404()
|
public function test_error_ext_disabled_or_404()
|
||||||
{
|
{
|
||||||
$crawler = $this->request('GET', 'app.php?controller=does/not/exist');
|
$crawler = self::request('GET', 'app.php?controller=does/not/exist', array(), false);
|
||||||
$this->assertEquals(404, $this->client->getResponse()->getStatus());
|
$this->assert_response_html(404);
|
||||||
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
|
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,8 +122,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
$this->login();
|
$this->login();
|
||||||
$this->admin_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);
|
$crawler = self::request('GET', 'adm/index.php?i=phpbb_ext_foo_bar_acp_main_module&mode=mode&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
|
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
|
||||||
$this->phpbb_extension_manager->purge('foo/bar');
|
$this->phpbb_extension_manager->purge('foo/bar');
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,15 +99,13 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
|
||||||
$this->phpbb_extension_manager->enable('foo/bar');
|
$this->phpbb_extension_manager->enable('foo/bar');
|
||||||
|
|
||||||
// User permissions
|
// User permissions
|
||||||
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
|
$crawler = self::request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
// Select admin
|
// Select admin
|
||||||
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
|
||||||
$data = array('username[0]' => 'admin');
|
$data = array('username[0]' => 'admin');
|
||||||
$form->setValues($data);
|
$form->setValues($data);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
// language from language/en/acp/permissions_phpbb.php
|
// language from language/en/acp/permissions_phpbb.php
|
||||||
$this->assertContains('Can attach files', $crawler->filter('body')->text());
|
$this->assertContains('Can attach files', $crawler->filter('body')->text());
|
||||||
|
|
|
@ -32,7 +32,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
|
||||||
'error' => UPLOAD_ERR_OK,
|
'error' => UPLOAD_ERR_OK,
|
||||||
);
|
);
|
||||||
|
|
||||||
$crawler = $this->client->request(
|
$crawler = self::$client->request(
|
||||||
'POST',
|
'POST',
|
||||||
'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
|
'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
|
||||||
array('add_file' => $this->lang('ADD_FILE')),
|
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.');
|
$this->markTestIncomplete('Test fails intermittently.');
|
||||||
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
|
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
|
||||||
$this->assert_response_success();
|
|
||||||
// ensure there was no error message rendered
|
// 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());
|
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
|
||||||
public function test_successful_upload()
|
public function test_successful_upload()
|
||||||
{
|
{
|
||||||
$upload = new fileupload('', array('gif'), 1000);
|
$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->assertEquals(0, sizeof($file->error));
|
||||||
$this->assertTrue(file_exists($file->filename));
|
$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()
|
public function test_too_large()
|
||||||
{
|
{
|
||||||
$upload = new fileupload('', array('gif'), 100);
|
$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]);
|
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$this->add_lang('ucp');
|
$this->add_lang('ucp');
|
||||||
$crawler = $this->request('GET', 'ucp.php?mode=sendpassword');
|
$crawler = self::request('GET', 'ucp.php?mode=sendpassword');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertEquals($this->lang('SEND_PASSWORD'), $crawler->filter('h2')->text());
|
$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->login();
|
||||||
$this->admin_login();
|
$this->admin_login();
|
||||||
$this->add_lang('ucp');
|
$this->add_lang('ucp');
|
||||||
$crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=security');
|
$crawler = self::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);
|
|
||||||
|
|
||||||
$form = $crawler->selectButton('Submit')->form();
|
$form = $crawler->selectButton('Submit')->form();
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
|
|
||||||
$values["config[allow_password_reset]"] = 0;
|
$values["config[allow_password_reset]"] = 0;
|
||||||
$form->setValues($values);
|
$form->setValues($values);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
|
|
||||||
$this->logout();
|
$this->logout();
|
||||||
|
|
||||||
$crawler = $this->request('GET', 'ucp.php?mode=sendpassword');
|
$crawler = self::request('GET', 'ucp.php?mode=sendpassword');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
|
$this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,18 +17,15 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
|
||||||
$this->create_user('memberlist-test-user');
|
$this->create_user('memberlist-test-user');
|
||||||
// logs in as admin
|
// logs in as admin
|
||||||
$this->login();
|
$this->login();
|
||||||
$crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid);
|
$crawler = self::request('GET', 'memberlist.php?sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||||
|
|
||||||
// restrict by first character
|
// restrict by first character
|
||||||
$crawler = $this->request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
|
$crawler = self::request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||||
|
|
||||||
// make sure results for wrong character are not returned
|
// make sure results for wrong character are not returned
|
||||||
$crawler = $this->request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
|
$crawler = self::request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertNotContains('memberlist-test-user', $crawler->text());
|
$this->assertNotContains('memberlist-test-user', $crawler->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +33,13 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
$this->login();
|
$this->login();
|
||||||
// XXX hardcoded user id
|
// XXX hardcoded user id
|
||||||
$crawler = $this->request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
|
$crawler = self::request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains('admin', $crawler->filter('h2')->text());
|
$this->assertContains('admin', $crawler->filter('h2')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_memberlist_leaders_table_crawler()
|
protected function get_memberlist_leaders_table_crawler()
|
||||||
{
|
{
|
||||||
$crawler = $this->request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
|
$crawler = self::request('GET', 'memberlist.php?mode=leaders&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
return $crawler->filter('.forumbg-table');
|
return $crawler->filter('.forumbg-table');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,9 +75,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
public function test_extensions_list()
|
public function test_extensions_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->assert_response_success();
|
|
||||||
|
|
||||||
$this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text());
|
$this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text());
|
||||||
$this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text());
|
$this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text());
|
||||||
$this->assertContains('Details', $crawler->filter('#main')->text());
|
$this->assertContains('Details', $crawler->filter('#main')->text());
|
||||||
|
@ -85,8 +83,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
||||||
|
|
||||||
public function test_extensions_details()
|
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);
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
// Test whether the details are displayed
|
// Test whether the details are displayed
|
||||||
$this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text());
|
$this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text());
|
||||||
|
@ -97,13 +94,12 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case
|
||||||
// Details should be html escaped
|
// Details should be html escaped
|
||||||
// However, text() only returns the displayed text, so HTML Special Chars are decoded.
|
// However, text() only returns the displayed text, so HTML Special Chars are decoded.
|
||||||
// So we test this directly on the content of the response.
|
// So we test this directly on the content of the response.
|
||||||
$this->assertContains('<p id="require_php">>=5.3</p>', $this->client->getResponse()->getContent());
|
$this->assertContains('<p id="require_php">>=5.3</p>', $this->get_content());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_extensions_details_notexists()
|
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);
|
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
// Error message because the files do not exist
|
// Error message because the files do not exist
|
||||||
$this->assertContains('The required file does not exist:', $crawler->filter('#main')->text());
|
$this->assertContains('The required file does not exist:', $crawler->filter('#main')->text());
|
||||||
|
|
|
@ -40,8 +40,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
|
||||||
public function test_user_subscriptions($checkbox_name, $expected_status)
|
public function test_user_subscriptions($checkbox_name, $expected_status)
|
||||||
{
|
{
|
||||||
$this->login();
|
$this->login();
|
||||||
$crawler = $this->request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
|
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
|
||||||
$this->assert_response_success();
|
|
||||||
|
|
||||||
$cplist = $crawler->filter('.table1');
|
$cplist = $crawler->filter('.table1');
|
||||||
if ($expected_status)
|
if ($expected_status)
|
||||||
|
|
|
@ -19,18 +19,17 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||||
// Test creating topic
|
// Test creating topic
|
||||||
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
|
$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());
|
$this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
|
||||||
|
|
||||||
// Test creating a reply
|
// 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.');
|
$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());
|
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
|
||||||
|
|
||||||
// Test quoting a message
|
// 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}");
|
$crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
|
$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,
|
'post' => true,
|
||||||
), $additional_form_data);
|
), $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,
|
'post' => true,
|
||||||
), $additional_form_data);
|
), $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');
|
$this->add_lang('posting');
|
||||||
|
|
||||||
$crawler = $this->request('GET', $posting_url);
|
$crawler = self::request('GET', $posting_url);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
|
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$hidden_fields = array(
|
$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
|
// 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)
|
// 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.
|
// Instead, I send it as a request with the submit button "post" set to true.
|
||||||
$crawler = $this->client->request('POST', $posting_url, $form_data);
|
$crawler = self::request('POST', $posting_url, $form_data);
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||||
|
|
|
@ -46,7 +46,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te
|
||||||
// submitting the ucp_group_manage page
|
// submitting the ucp_group_manage page
|
||||||
$form = $this->get_group_manage_form();
|
$form = $this->get_group_manage_form();
|
||||||
$teampage_settings = $this->get_teampage_settings();
|
$teampage_settings = $this->get_teampage_settings();
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = self::submit($form);
|
||||||
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
|
$this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text());
|
||||||
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
|
$this->assertEquals($teampage_settings, $this->get_teampage_settings());
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,9 @@ require_once __DIR__ . '/../../phpBB/includes/functions_install.php';
|
||||||
|
|
||||||
class phpbb_functional_test_case extends phpbb_test_case
|
class phpbb_functional_test_case extends phpbb_test_case
|
||||||
{
|
{
|
||||||
protected $client;
|
static protected $client;
|
||||||
protected $root_url;
|
static protected $cookieJar;
|
||||||
|
static protected $root_url;
|
||||||
|
|
||||||
protected $cache = null;
|
protected $cache = null;
|
||||||
protected $db = null;
|
protected $db = null;
|
||||||
|
@ -39,6 +40,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
parent::setUpBeforeClass();
|
parent::setUpBeforeClass();
|
||||||
|
|
||||||
self::$config = phpbb_test_case_helpers::get_test_config();
|
self::$config = phpbb_test_case_helpers::get_test_config();
|
||||||
|
self::$root_url = self::$config['phpbb_functional_url'];
|
||||||
|
|
||||||
// Important: this is used both for installation and by
|
// Important: this is used both for installation and by
|
||||||
// test cases for querying the tables.
|
// test cases for querying the tables.
|
||||||
|
@ -64,12 +66,12 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
|
|
||||||
$this->bootstrap();
|
$this->bootstrap();
|
||||||
|
|
||||||
$this->cookieJar = new CookieJar;
|
self::$cookieJar = new CookieJar;
|
||||||
$this->client = new Goutte\Client(array(), null, $this->cookieJar);
|
self::$client = new Goutte\Client(array(), null, self::$cookieJar);
|
||||||
// Reset the curl handle because it is 0 at this point and not a valid
|
// Reset the curl handle because it is 0 at this point and not a valid
|
||||||
// resource
|
// resource
|
||||||
$this->client->getClient()->getCurlMulti()->reset(true);
|
self::$client->getClient()->getCurlMulti()->reset(true);
|
||||||
$this->root_url = self::$config['phpbb_functional_url'];
|
|
||||||
// Clear the language array so that things
|
// Clear the language array so that things
|
||||||
// that were added in other tests are gone
|
// that were added in other tests are gone
|
||||||
$this->lang = array();
|
$this->lang = array();
|
||||||
|
@ -77,9 +79,55 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
$this->purge_cache();
|
$this->purge_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request($method, $path)
|
/**
|
||||||
|
* Perform a request to page
|
||||||
|
*
|
||||||
|
* @param string $method HTTP Method
|
||||||
|
* @param string $path Page path, relative from phpBB root path
|
||||||
|
* @param array $form_data An array of form field values
|
||||||
|
* @param bool $assert_response_html Should we perform standard assertions for a normal html page
|
||||||
|
* @return Symfony\Component\DomCrawler\Crawler
|
||||||
|
*/
|
||||||
|
static public function request($method, $path, $form_data = array(), $assert_response_html = true)
|
||||||
{
|
{
|
||||||
return $this->client->request($method, $this->root_url . $path);
|
$crawler = self::$client->request($method, self::$root_url . $path, $form_data);
|
||||||
|
|
||||||
|
if ($assert_response_html)
|
||||||
|
{
|
||||||
|
self::assert_response_html();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $crawler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits a form
|
||||||
|
*
|
||||||
|
* @param Symfony\Component\DomCrawler\Form $form A Form instance
|
||||||
|
* @param array $values An array of form field values
|
||||||
|
* @param bool $assert_response_html Should we perform standard assertions for a normal html page
|
||||||
|
* @return Symfony\Component\DomCrawler\Crawler
|
||||||
|
*/
|
||||||
|
static public function submit(Symfony\Component\DomCrawler\Form $form, array $values = array(), $assert_response_html = true)
|
||||||
|
{
|
||||||
|
$crawler = self::$client->submit($form, $values);
|
||||||
|
|
||||||
|
if ($assert_response_html)
|
||||||
|
{
|
||||||
|
self::assert_response_html();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $crawler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Client Content
|
||||||
|
*
|
||||||
|
* @return string HTML page
|
||||||
|
*/
|
||||||
|
static public function get_content()
|
||||||
|
{
|
||||||
|
return self::$client->getResponse()->getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bootstrap, called after board is set up
|
// bootstrap, called after board is set up
|
||||||
|
@ -183,26 +231,73 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// begin data
|
self::$cookieJar = new CookieJar;
|
||||||
$data = array();
|
self::$client = new Goutte\Client(array(), null, self::$cookieJar);
|
||||||
|
// Set client manually so we can increase the cURL timeout
|
||||||
|
self::$client->setClient(new Guzzle\Http\Client('', array(
|
||||||
|
Guzzle\Http\Client::DISABLE_REDIRECTS => true,
|
||||||
|
'curl.options' => array(
|
||||||
|
CURLOPT_TIMEOUT => 120,
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
|
||||||
$data = array_merge($data, self::$config);
|
// Reset the curl handle because it is 0 at this point and not a valid
|
||||||
|
// resource
|
||||||
$data = array_merge($data, array(
|
self::$client->getClient()->getCurlMulti()->reset(true);
|
||||||
'default_lang' => 'en',
|
|
||||||
'admin_name' => 'admin',
|
|
||||||
'admin_pass1' => 'admin',
|
|
||||||
'admin_pass2' => 'admin',
|
|
||||||
'board_email' => 'nobody@example.com',
|
|
||||||
));
|
|
||||||
|
|
||||||
$parseURL = parse_url(self::$config['phpbb_functional_url']);
|
$parseURL = parse_url(self::$config['phpbb_functional_url']);
|
||||||
|
|
||||||
$data = array_merge($data, array(
|
$crawler = self::request('GET', 'install/index.php?mode=install');
|
||||||
|
self::assertContains('Welcome to Installation', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('Installation compatibility', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('Database configuration', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form(array(
|
||||||
|
// Installer uses 3.0-style dbms name
|
||||||
|
'dbms' => str_replace('phpbb_db_driver_', '', self::$config['dbms']),
|
||||||
|
'dbhost' => self::$config['dbhost'],
|
||||||
|
'dbport' => self::$config['dbport'],
|
||||||
|
'dbname' => self::$config['dbname'],
|
||||||
|
'dbuser' => self::$config['dbuser'],
|
||||||
|
'dbpasswd' => self::$config['dbpasswd'],
|
||||||
|
'table_prefix' => self::$config['table_prefix'],
|
||||||
|
));
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('Successful connection', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('Administrator configuration', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form(array(
|
||||||
|
'default_lang' => 'en',
|
||||||
|
'admin_name' => 'admin',
|
||||||
|
'admin_pass1' => 'adminadmin',
|
||||||
|
'admin_pass2' => 'adminadmin',
|
||||||
|
'board_email' => 'nobody@example.com',
|
||||||
|
));
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('Tests passed', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('The configuration file has been written.', $crawler->filter('#main')->text());
|
||||||
|
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, true));
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form(array(
|
||||||
'email_enable' => true,
|
'email_enable' => true,
|
||||||
'smtp_delivery' => true,
|
'smtp_delivery' => true,
|
||||||
'smtp_host' => 'nxdomain.phpbb.com',
|
'smtp_host' => 'nxdomain.phpbb.com',
|
||||||
'smtp_auth' => '',
|
'smtp_auth' => 'PLAIN',
|
||||||
'smtp_user' => 'nxuser',
|
'smtp_user' => 'nxuser',
|
||||||
'smtp_pass' => 'nxpass',
|
'smtp_pass' => 'nxpass',
|
||||||
'cookie_secure' => false,
|
'cookie_secure' => false,
|
||||||
|
@ -212,50 +307,17 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80,
|
'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80,
|
||||||
'script_path' => $parseURL['path'],
|
'script_path' => $parseURL['path'],
|
||||||
));
|
));
|
||||||
// end data
|
|
||||||
|
|
||||||
$content = self::do_request('install');
|
$crawler = self::submit($form);
|
||||||
self::assertNotSame(false, $content);
|
self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text());
|
||||||
self::assertContains('Welcome to Installation', $content);
|
self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text());
|
||||||
|
$form = $crawler->selectButton('submit')->form();
|
||||||
|
|
||||||
// Installer uses 3.0-style dbms name
|
$crawler = self::submit($form);
|
||||||
$data['dbms'] = str_replace('phpbb_db_driver_', '', $data['dbms']);
|
self::assertContains('You have successfully installed', $crawler->text());
|
||||||
$content = self::do_request('create_table', $data);
|
|
||||||
self::assertNotSame(false, $content);
|
|
||||||
self::assertContains('The database tables used by phpBB', $content);
|
|
||||||
// 3.0 or 3.1
|
|
||||||
self::assertContains('have been created and populated with some initial data.', $content);
|
|
||||||
|
|
||||||
$content = self::do_request('config_file', $data);
|
|
||||||
self::assertNotSame(false, $content);
|
|
||||||
self::assertContains('Configuration file', $content);
|
|
||||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], true, true));
|
|
||||||
|
|
||||||
$content = self::do_request('final', $data);
|
|
||||||
self::assertNotSame(false, $content);
|
|
||||||
self::assertContains('You have successfully installed', $content);
|
|
||||||
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
||||||
}
|
}
|
||||||
|
|
||||||
static private function do_request($sub, $post_data = null)
|
|
||||||
{
|
|
||||||
$context = null;
|
|
||||||
|
|
||||||
if ($post_data)
|
|
||||||
{
|
|
||||||
$context = stream_context_create(array(
|
|
||||||
'http' => array(
|
|
||||||
'method' => 'POST',
|
|
||||||
'header' => 'Content-Type: application/x-www-form-urlencoded',
|
|
||||||
'content' => http_build_query($post_data),
|
|
||||||
'ignore_errors' => true,
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context);
|
|
||||||
}
|
|
||||||
|
|
||||||
static private function recreate_database($config)
|
static private function recreate_database($config)
|
||||||
{
|
{
|
||||||
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
|
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
|
||||||
|
@ -314,7 +376,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
'user_lang' => 'en',
|
'user_lang' => 'en',
|
||||||
'user_timezone' => 0,
|
'user_timezone' => 0,
|
||||||
'user_dateformat' => '',
|
'user_dateformat' => '',
|
||||||
'user_password' => phpbb_hash($username),
|
'user_password' => phpbb_hash($username . $username),
|
||||||
);
|
);
|
||||||
return user_add($user_row);
|
return user_add($user_row);
|
||||||
}
|
}
|
||||||
|
@ -407,15 +469,14 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
{
|
{
|
||||||
$this->add_lang('ucp');
|
$this->add_lang('ucp');
|
||||||
|
|
||||||
$crawler = $this->request('GET', 'ucp.php');
|
$crawler = self::request('GET', 'ucp.php');
|
||||||
$this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
|
$this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
|
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
|
||||||
$crawler = $this->client->submit($form, array('username' => $username, 'password' => $username));
|
$crawler = self::submit($form, array('username' => $username, 'password' => $username . $username));
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text());
|
$this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$cookies = $this->cookieJar->all();
|
$cookies = self::$cookieJar->all();
|
||||||
|
|
||||||
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
||||||
foreach ($cookies as $cookie);
|
foreach ($cookies as $cookie);
|
||||||
|
@ -431,8 +492,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
{
|
{
|
||||||
$this->add_lang('ucp');
|
$this->add_lang('ucp');
|
||||||
|
|
||||||
$crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
||||||
unset($this->sid);
|
unset($this->sid);
|
||||||
|
|
||||||
|
@ -453,7 +513,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
|
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid);
|
||||||
$this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
|
$this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
|
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
|
||||||
|
@ -462,11 +522,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
{
|
{
|
||||||
if (strpos($field, 'password_') === 0)
|
if (strpos($field, 'password_') === 0)
|
||||||
{
|
{
|
||||||
$crawler = $this->client->submit($form, array('username' => $username, $field => $username));
|
$crawler = self::submit($form, array('username' => $username, $field => $username . $username));
|
||||||
$this->assert_response_success();
|
|
||||||
$this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text());
|
$this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text());
|
||||||
|
|
||||||
$cookies = $this->cookieJar->all();
|
$cookies = self::$cookieJar->all();
|
||||||
|
|
||||||
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
|
||||||
foreach ($cookies as $cookie);
|
foreach ($cookies as $cookie);
|
||||||
|
@ -531,22 +590,38 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform some basic assertions for the page
|
||||||
|
*
|
||||||
|
* Checks for debug/error output before the actual page content and the status code
|
||||||
|
*
|
||||||
|
* @param mixed $status_code Expected status code, false to disable check
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
static public function assert_response_html($status_code = 200)
|
||||||
|
{
|
||||||
|
if ($status_code !== false)
|
||||||
|
{
|
||||||
|
self::assert_response_status_code($status_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Any output before the doc type means there was an error
|
||||||
|
$content = self::$client->getResponse()->getContent();
|
||||||
|
self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Heuristic function to check that the response is success.
|
* Heuristic function to check that the response is success.
|
||||||
*
|
*
|
||||||
* When php decides to die with a fatal error, it still sends 200 OK
|
* When php decides to die with a fatal error, it still sends 200 OK
|
||||||
* status code. This assertion tries to catch that.
|
* status code. This assertion tries to catch that.
|
||||||
*
|
*
|
||||||
|
* @param int $status_code Expected status code
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
public function assert_response_success()
|
static public function assert_response_status_code($status_code = 200)
|
||||||
{
|
{
|
||||||
$this->assertEquals(200, $this->client->getResponse()->getStatus());
|
self::assertEquals($status_code, self::$client->getResponse()->getStatus());
|
||||||
$content = $this->client->getResponse()->getContent();
|
|
||||||
$this->assertNotContains('Fatal error:', $content);
|
|
||||||
$this->assertNotContains('Notice:', $content);
|
|
||||||
$this->assertNotContains('Warning:', $content);
|
|
||||||
$this->assertNotContains('[phpBB Debug]', $content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assert_filter($crawler, $expr, $msg = null)
|
public function assert_filter($crawler, $expr, $msg = null)
|
||||||
|
|
Loading…
Add table
Reference in a new issue