1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge remote-tracking branch 'upstream/develop' into feature/merging-style-components

* upstream/develop: (65 commits)
  [ticket/10730] Added label tag around "select" text in post splitting UI
  [ticket/10732] Add config_dev.php and config_test.php to .gitignore
  [ticket/10586] Added space in if statement
  [ticket/10586] Tidy up comments
  [task/php5.3] Updated range of tested PHP versions
  [task/php5.3] Looks like I missed a few places that needed PHP 5.2 changed to PHP 5.3.2
  [task/php5.3] Changed minimum PHP requirement for Ascraeus to 5.3.2
  [ticket/10723] Stop Travis running all tests on sqlite
  [ticket/10703] Added a condition to check if ext directory exists
  [task/travis] Refactor php version check for dbunit install
  [task/travis] Exclude functional and slow tests
  [ticket/10719] Revert "Skip functional tests on PHP 5.2"
  [task/travis-develop2] Update version from 5.3 to 5.3.2
  [task/travis] Dropping support for 5.2 in develop branch
  [task/travis] Some more small travis fixes
  [task/travis] Rename travis phpunit config files
  [task/travis] Fixing some travis issues
  [ticket/10684] Adjust function and parameter name, minor changes.
  [task/travis] Add automated testing to readme
  [task/travis] Removing development information
  ...

Conflicts:
	phpBB/install/database_update.php
This commit is contained in:
Vjacheslav Trushkin
2012-03-29 22:38:07 +03:00
65 changed files with 766 additions and 97 deletions

View File

@@ -25,8 +25,4 @@ require_once 'test_framework/phpbb_test_case_helpers.php';
require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
require_once 'test_framework/phpbb_database_test_connection_manager.php';
if (version_compare(PHP_VERSION, '5.3.0-dev', '>='))
{
require_once 'test_framework/phpbb_functional_test_case.php';
}
require_once 'test_framework/phpbb_functional_test_case.php';

View File

@@ -0,0 +1,153 @@
<?php
/**
*
* @package testing
* @copyright (c) 2011 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
{
protected $phpbb_extension_manager;
/**
* 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();
// these directories need to be created before the files can be copied
$directories = array(
$phpbb_root_path . 'ext/error/class/',
$phpbb_root_path . 'ext/error/classtype/',
$phpbb_root_path . 'ext/error/disabled/',
$phpbb_root_path . 'ext/foo/bar/',
$phpbb_root_path . 'ext/foo/bar/styles/prosilver/template/',
$phpbb_root_path . 'ext/foobar/',
$phpbb_root_path . 'ext/foobar/styles/prosilver/template/',
);
foreach ($directories as $dir)
{
if (!is_dir($dir))
{
mkdir($dir, 0777, true);
}
}
$fixtures = array(
'error/class/controller.php',
'error/class/ext.php',
'error/classtype/controller.php',
'error/classtype/ext.php',
'error/disabled/controller.php',
'error/disabled/ext.php',
'foo/bar/controller.php',
'foo/bar/ext.php',
'foo/bar/styles/prosilver/template/foobar_body.html',
'foobar/controller.php',
'foobar/ext.php',
'foobar/styles/prosilver/template/foobar_body.html',
);
foreach ($fixtures as $fixture)
{
if (!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture"))
{
echo 'Could not copy file ' . $fixture;
}
}
}
public static function tearDownAfterClass()
{
$phpbb_root_path = self::$config['phpbb_functional_path'];
// @todo delete the fixtures from the $phpbb_root_path board
// Note that it might be best to find a public domain function
// and port it into here instead of writing it from scratch
}
public function setUp()
{
parent::setUp();
$this->phpbb_extension_manager = $this->get_extension_manager();
$this->purge_cache();
}
/**
* Check an extension at ./ext/foobar/ which should have the class
* phpbb_ext_foobar_controller
*/
public function test_foobar()
{
$this->phpbb_extension_manager->enable('foobar');
$crawler = $this->request('GET', 'index.php?ext=foobar');
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
$this->phpbb_extension_manager->purge('foobar');
}
/**
* Check an extension at ./ext/foo/bar/ which should have the class
* phpbb_ext_foo_bar_controller
*/
public function test_foo_bar()
{
$this->phpbb_extension_manager->enable('foo/bar');
$crawler = $this->request('GET', 'index.php?ext=foo/bar');
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
/**
* Check the error produced by extension at ./ext/error/class which has class
* phpbb_ext_foobar_controller
*/
public function test_error_class_name()
{
$this->phpbb_extension_manager->enable('error/class');
$crawler = $this->request('GET', 'index.php?ext=error/class');
$this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text());
$this->phpbb_extension_manager->purge('error/class');
}
/**
* Check the error produced by extension at ./ext/error/classtype which has class
* phpbb_ext_error_classtype_controller but does not implement phpbb_extension_controller_interface
*/
public function test_error_class_type()
{
$this->phpbb_extension_manager->enable('error/classtype');
$crawler = $this->request('GET', 'index.php?ext=error/classtype');
$this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text());
$this->phpbb_extension_manager->purge('error/classtype');
}
/**
* Check the error produced by extension at ./ext/error/disabled that is (obviously)
* a disabled extension
*/
public function test_error_ext_disabled()
{
$crawler = $this->request('GET', 'index.php?ext=error/disabled');
$this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text());
}
/**
* Check the error produced by extension at ./ext/error/404 that is (obviously)
* not existant
*/
public function test_error_ext_missing()
{
$crawler = $this->request('GET', 'index.php?ext=error/404');
$this->assertContains("The extension error/404 does not exist.", $crawler->filter('#message')->text());
}
}

View File

@@ -0,0 +1,17 @@
<?php
class phpbb_ext_foobar_controller implements phpbb_extension_controller_interface
{
public function handle()
{
global $template;
$template->set_ext_dir_prefix($phpbb_root_path . 'ext/error/class/');
$template->set_filenames(array(
'body' => 'index_body.html'
));
page_header('Test extension');
page_footer();
}
}

View File

@@ -0,0 +1,6 @@
<?php
class phpbb_ext_error_class_ext extends phpbb_extension_base
{
}

View File

@@ -0,0 +1,17 @@
<?php
class phpbb_ext_error_classtype_controller
{
public function handle()
{
global $template;
$template->set_ext_dir_prefix($phpbb_root_path . 'ext/error/classtype/');
$template->set_filenames(array(
'body' => 'index_body.html'
));
page_header('Test extension');
page_footer();
}
}

View File

@@ -0,0 +1,6 @@
<?php
class phpbb_ext_error_classtype_ext extends phpbb_extension_base
{
}

View File

@@ -0,0 +1,17 @@
<?php
class phpbb_ext_error_disabled_controller implements phpbb_extension_controller_interface
{
public function handle()
{
global $template;
$template->set_ext_dir_prefix($phpbb_root_path . 'ext/error/disabled/');
$template->set_filenames(array(
'body' => 'index_body.html'
));
page_header('Test extension');
page_footer();
}
}

View File

@@ -0,0 +1,6 @@
<?php
class phpbb_ext_error_disabled_ext extends phpbb_extension_base
{
}

View File

@@ -0,0 +1,17 @@
<?php
class phpbb_ext_foo_bar_controller implements phpbb_extension_controller_interface
{
public function handle()
{
global $template;
$template->set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/');
$template->set_filenames(array(
'body' => 'foobar_body.html'
));
page_header('Test extension');
page_footer();
}
}

View File

@@ -0,0 +1,6 @@
<?php
class phpbb_ext_foo_bar_ext extends phpbb_extension_base
{
}

View File

@@ -0,0 +1,5 @@
<!-- INCLUDE overall_header.html -->
<div id="welcome">This is for testing purposes.</div>
<!-- INCLUDE overall_footer.html -->

View File

@@ -0,0 +1,17 @@
<?php
class phpbb_ext_foobar_controller implements phpbb_extension_controller_interface
{
public function handle()
{
global $template;
$template->set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/');
$template->set_filenames(array(
'body' => 'foobar_body.html'
));
page_header('Test extension');
page_footer();
}
}

View File

@@ -0,0 +1,6 @@
<?php
class phpbb_ext_foobar_ext extends phpbb_extension_base
{
}

View File

@@ -0,0 +1,5 @@
<!-- INCLUDE overall_header.html -->
<div id="welcome">This is for testing purposes.</div>
<!-- INCLUDE overall_footer.html -->

View File

@@ -14,6 +14,10 @@ class phpbb_functional_test_case extends phpbb_test_case
protected $client;
protected $root_url;
protected $cache = null;
protected $db = null;
protected $extension_manager = null;
static protected $config = array();
static protected $already_installed = false;
@@ -66,6 +70,60 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
protected function get_db()
{
global $phpbb_root_path, $phpEx;
// so we don't reopen an open connection
if (!($this->db instanceof dbal))
{
if (!class_exists('dbal_' . self::$config['dbms']))
{
include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx");
}
$sql_db = 'dbal_' . self::$config['dbms'];
$this->db = new $sql_db();
$this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
}
return $this->db;
}
protected function get_cache_driver()
{
if (!$this->cache)
{
$this->cache = new phpbb_cache_driver_file;
}
return $this->cache;
}
protected function purge_cache()
{
$cache = $this->get_cache_driver();
$cache->purge();
$cache->unload();
$cache->load();
}
protected function get_extension_manager()
{
global $phpbb_root_path, $phpEx;
if (!$this->extension_manager)
{
$this->extension_manager = new phpbb_extension_manager(
$this->get_db(),
self::$config['table_prefix'] . 'ext',
$phpbb_root_path,
".$phpEx",
$this->get_cache_driver()
);
}
return $this->extension_manager;
}
protected function install_board()
{
global $phpbb_root_path, $phpEx;