mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +02:00
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/11531
This commit is contained in:
21
tests/functional/acp_groups_test.php
Normal file
21
tests/functional/acp_groups_test.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_groups_test.php';
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test
|
||||
{
|
||||
protected function get_url()
|
||||
{
|
||||
return 'adm/index.php?i=groups&mode=manage&action=edit';
|
||||
}
|
||||
}
|
51
tests/functional/common_groups_test.php
Normal file
51
tests/functional/common_groups_test.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
abstract class phpbb_functional_common_groups_test extends phpbb_functional_test_case
|
||||
{
|
||||
abstract protected function get_url();
|
||||
|
||||
public function groups_manage_test_data()
|
||||
{
|
||||
return array(
|
||||
array('', 'GROUP_UPDATED'),
|
||||
array('aa0000', 'GROUP_UPDATED'),
|
||||
|
||||
array('AAG000','WRONG_DATA_COLOUR'),
|
||||
array('#AA0000', 'WRONG_DATA_COLOUR'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider groups_manage_test_data
|
||||
*/
|
||||
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'));
|
||||
|
||||
// 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['group_colour']->setValue($input);
|
||||
$crawler = $this->client->submit($form);
|
||||
$this->assertContains($this->lang($expected), $crawler->text());
|
||||
}
|
||||
}
|
@@ -112,7 +112,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
|
||||
$crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
|
||||
|
||||
$this->assertCount(1, $crawler->filter('.ext_enabled'));
|
||||
$this->assertCount(4, $crawler->filter('.ext_disabled'));
|
||||
$this->assertCount(5, $crawler->filter('.ext_disabled'));
|
||||
|
||||
$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
|
||||
$this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text());
|
||||
|
130
tests/functional/extension_module_test.php
Normal file
130
tests/functional/extension_module_test.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php';
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
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 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/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
global $db;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->phpbb_extension_manager = $this->get_extension_manager();
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
|
||||
$modules = new acp_modules();
|
||||
$db = $this->get_db();
|
||||
|
||||
$sql = 'SELECT module_id
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_langname = 'acp'
|
||||
AND module_class = 'ACP_CAT_DOT_MODS'";
|
||||
$result = $db->sql_query($sql);
|
||||
$module_id = (int) $db->sql_fetchfield('module_id');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$parent_data = array(
|
||||
'module_basename' => '',
|
||||
'module_enabled' => 1,
|
||||
'module_display' => 1,
|
||||
'parent_id' => $module_id,
|
||||
'module_class' => 'acp',
|
||||
'module_langname' => 'ACP_FOOBAR_TITLE',
|
||||
'module_mode' => '',
|
||||
'module_auth' => '',
|
||||
);
|
||||
$modules->update_module_data($parent_data, true);
|
||||
|
||||
$module_data = array(
|
||||
'module_basename' => 'phpbb_ext_foo_bar_acp_main_module',
|
||||
'module_enabled' => 1,
|
||||
'module_display' => 1,
|
||||
'parent_id' => $parent_data['module_id'],
|
||||
'module_class' => 'acp',
|
||||
'module_langname' => 'ACP_FOOBAR_TITLE',
|
||||
'module_mode' => 'mode',
|
||||
'module_auth' => '',
|
||||
);
|
||||
$modules->update_module_data($module_data, true);
|
||||
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a controller for extension foo/bar.
|
||||
*/
|
||||
public function test_foo_bar()
|
||||
{
|
||||
$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();
|
||||
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
}
|
118
tests/functional/extension_permission_lang_test.php
Normal file
118
tests/functional/extension_permission_lang_test.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_extension_permission_lang_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/');
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->get_db();
|
||||
|
||||
$acl_ary = array(
|
||||
'auth_option' => 'u_foo',
|
||||
'is_global' => 1,
|
||||
);
|
||||
|
||||
$sql = 'INSERT INTO phpbb_acl_options ' . $this->db->sql_build_array('INSERT', $acl_ary);
|
||||
$this->db->sql_query($sql);
|
||||
|
||||
$this->phpbb_extension_manager = $this->get_extension_manager();
|
||||
|
||||
$this->purge_cache();
|
||||
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
$this->add_lang('acp/permissions');
|
||||
}
|
||||
|
||||
public function test_auto_include_permission_lang_from_extensions()
|
||||
{
|
||||
$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();
|
||||
|
||||
// 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();
|
||||
|
||||
// language from language/en/acp/permissions_phpbb.php
|
||||
$this->assertContains('Can attach files', $crawler->filter('body')->text());
|
||||
|
||||
// language from ext/foo/bar/language/en/permissions_foo.php
|
||||
$this->assertContains('Can view foo', $crawler->filter('body')->text());
|
||||
}
|
||||
}
|
32
tests/functional/fixtures/ext/foo/bar/acp/main_info.php
Normal file
32
tests/functional/fixtures/ext/foo/bar/acp/main_info.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class phpbb_ext_foo_bar_acp_main_info
|
||||
{
|
||||
function module()
|
||||
{
|
||||
return array(
|
||||
'filename' => 'phpbb_ext_foo_bar_acp_main_module',
|
||||
'title' => 'ACP_FOOBAR_TITLE',
|
||||
'version' => '1.0.0',
|
||||
'modes' => array(
|
||||
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
28
tests/functional/fixtures/ext/foo/bar/acp/main_module.php
Normal file
28
tests/functional/fixtures/ext/foo/bar/acp/main_module.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class phpbb_ext_foo_bar_acp_main_module
|
||||
{
|
||||
var $u_action;
|
||||
|
||||
function main($id, $mode)
|
||||
{
|
||||
$this->tpl_name = 'foobar';
|
||||
$this->page_title = 'Bertie';
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
<!-- INCLUDE overall_header.html -->
|
||||
Bertie rulez!
|
||||
<!-- INCLUDE overall_footer.html -->
|
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Admin Permissions
|
||||
$lang = array_merge($lang, array(
|
||||
'acl_u_foo' => array('lang' => 'Can view foo', 'cat' => 'misc'),
|
||||
));
|
@@ -43,7 +43,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
|
||||
$crawler = $this->request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
|
||||
$this->assert_response_success();
|
||||
|
||||
$cplist = $crawler->filter('.cplist');
|
||||
$cplist = $crawler->filter('.table1');
|
||||
if ($expected_status)
|
||||
{
|
||||
$this->assert_checkbox_is_checked($cplist, $checkbox_name);
|
||||
|
21
tests/functional/ucp_groups_test.php
Normal file
21
tests/functional/ucp_groups_test.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_groups_test.php';
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test
|
||||
{
|
||||
protected function get_url()
|
||||
{
|
||||
return 'ucp.php?i=groups&mode=manage&action=edit';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user