aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/composer.json5
-rw-r--r--tests/composer.lock66
-rw-r--r--tests/extension/ext/vendor2/bar/migrations/bar.php7
-rw-r--r--tests/extension/ext/vendor2/bar/migrations/foo.php54
-rw-r--r--tests/extension/extension_base_test.php11
-rw-r--r--tests/files/types_remote_test.php34
-rw-r--r--tests/functional/fileupload_remote_test.php5
-rw-r--r--tests/functional/plupload_test.php12
-rw-r--r--tests/installer/installer_config_test.php7
-rw-r--r--tests/language/language_test.php19
-rw-r--r--tests/mock/migrator.php4
-rw-r--r--tests/mock/phpbb_di_container_builder.php10
-rw-r--r--tests/path_helper/path_helper_test.php37
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php15
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php34
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php67
-rw-r--r--tests/ui/quick_links_test.php1
17 files changed, 250 insertions, 138 deletions
diff --git a/tests/composer.json b/tests/composer.json
deleted file mode 100644
index 69512f30a6..0000000000
--- a/tests/composer.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "require-dev": {
- "facebook/webdriver": "dev-master"
- }
-}
diff --git a/tests/composer.lock b/tests/composer.lock
deleted file mode 100644
index f714495d84..0000000000
--- a/tests/composer.lock
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
- ],
- "hash": "cf1d8a4841e5e669b148e0df6645a788",
- "packages": [
-
- ],
- "packages-dev": [
- {
- "name": "facebook/webdriver",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/facebook/php-webdriver.git",
- "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/b6e002e5bf811a8edba393ce6872322c1b7cf796",
- "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.19"
- },
- "require-dev": {
- "phpdocumentor/phpdocumentor": "2.*",
- "phpunit/phpunit": "3.7.*"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "lib/"
- ]
- },
- "notification-url": "http://packagist.org/downloads/",
- "license": [
- "Apache-2.0"
- ],
- "description": "A php client for WebDriver",
- "homepage": "https://github.com/facebook/php-webdriver",
- "keywords": [
- "facebook",
- "php",
- "selenium",
- "webdriver"
- ],
- "time": "2014-08-05 02:55:46"
- }
- ],
- "aliases": [
-
- ],
- "minimum-stability": "stable",
- "stability-flags": {
- "facebook/webdriver": 20
- },
- "platform": [
-
- ],
- "platform-dev": [
-
- ]
-}
diff --git a/tests/extension/ext/vendor2/bar/migrations/bar.php b/tests/extension/ext/vendor2/bar/migrations/bar.php
new file mode 100644
index 0000000000..ea5ddb6b8b
--- /dev/null
+++ b/tests/extension/ext/vendor2/bar/migrations/bar.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace vendor2\foo\migrations;
+
+class bar
+{
+}
diff --git a/tests/extension/ext/vendor2/bar/migrations/foo.php b/tests/extension/ext/vendor2/bar/migrations/foo.php
new file mode 100644
index 0000000000..d727c2f954
--- /dev/null
+++ b/tests/extension/ext/vendor2/bar/migrations/foo.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace vendor2\foo\migrations;
+
+class foo implements \phpbb\db\migration\migration_interface
+{
+ /**
+ * {@inheritdoc}
+ */
+ static public function depends_on()
+ {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function effectively_installed()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function update_schema()
+ {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function revert_schema()
+ {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function update_data()
+ {
+ return array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function revert_data()
+ {
+ return array();
+ }
+}
diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php
index eee38186db..775a23e198 100644
--- a/tests/extension/extension_base_test.php
+++ b/tests/extension/extension_base_test.php
@@ -11,6 +11,9 @@
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/bar.php';
+require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/foo.php';
+require_once dirname(__FILE__) . '/ext/vendor2/bar/migrations/migration.php';
class phpbb_extension_extension_base_test extends phpbb_test_case
{
@@ -61,9 +64,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
return array(
array(
'vendor2/bar',
- array(
- '\vendor2\bar\migrations\migration',
- ),
+ array('\vendor2\bar\migrations\migration'),
),
);
}
@@ -74,6 +75,8 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
public function test_suffix_get_classes($extension_name, $expected)
{
$extension = $this->extension_manager->get_extension($extension_name);
- $this->assertEquals($expected, self::$reflection_method_get_migration_file_list->invoke($extension));
+ $migration_classes = self::$reflection_method_get_migration_file_list->invoke($extension);
+ sort($migration_classes);
+ $this->assertEquals($expected, $migration_classes);
}
}
diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php
index a85844ee78..476d8ed3ba 100644
--- a/tests/files/types_remote_test.php
+++ b/tests/files/types_remote_test.php
@@ -20,6 +20,9 @@ class phpbb_files_types_remote_test extends phpbb_test_case
private $filesystem;
+ /** @var \phpbb\config\config */
+ protected $config;
+
/** @var \Symfony\Component\DependencyInjection\ContainerInterface */
protected $container;
@@ -43,6 +46,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case
global $config, $phpbb_root_path, $phpEx;
$config = new \phpbb\config\config(array());
+ $this->config = $config;
+ $this->config->set('remote_upload_verify', 0);
$this->request = $this->getMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem();
@@ -67,7 +72,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
public function test_upload_fsock_fail()
{
- $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
@@ -85,8 +90,8 @@ class phpbb_files_types_remote_test extends phpbb_test_case
array('500k', 'http://example.com/foo/bar.png'),
array('500M', 'http://example.com/foo/bar.png'),
array('500m', 'http://example.com/foo/bar.png'),
- array('500k', 'http://google.com/.png', 'DISALLOWED_CONTENT'),
- array('1', 'http://google.com/.png', 'WRONG_FILESIZE'),
+ array('500k', 'http://google.com/?.png', array('DISALLOWED_EXTENSION', 'DISALLOWED_CONTENT')),
+ array('1', 'http://google.com/?.png', array('WRONG_FILESIZE')),
array('500g', 'http://example.com/foo/bar.png'),
array('foobar', 'http://example.com/foo/bar.png'),
array('-5k', 'http://example.com/foo/bar.png'),
@@ -96,44 +101,31 @@ class phpbb_files_types_remote_test extends phpbb_test_case
/**
* @dataProvider data_get_max_file_size
*/
- public function test_get_max_file_size($max_file_size, $link, $expected = 'URL_NOT_FOUND')
+ public function test_get_max_file_size($max_file_size, $link, $expected = array('URL_NOT_FOUND'))
{
$php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString'));
$php_ini->expects($this->any())
->method('getString')
->willReturn($max_file_size);
- $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path);
+ $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
$file = $type_remote->upload($link);
- $this->assertSame(array($expected), $file->error);
- }
-
- public function test_upload_timeout()
- {
- $type_remote = new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
- $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
- $upload->set_allowed_extensions(array('png'));
- $type_remote->set_upload($upload);
- $upload->upload_timeout = -5;
-
- $file = $type_remote->upload('http://google.com/.png');
-
- $this->assertSame(array('REMOTE_UPLOAD_TIMEOUT'), $file->error);
+ $this->assertSame($expected, $file->error);
}
public function test_upload_wrong_path()
{
- $type_remote = new \phpbb\files\types\foo($this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
+ $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path);
$upload->set_allowed_extensions(array('png'));
$type_remote->set_upload($upload);
$type_remote::$tempnam_path = $this->phpbb_root_path . 'cache/wrong/path';
- $file = $type_remote->upload('http://google.com/.png');
+ $file = $type_remote->upload('http://google.com/?.png');
$this->assertSame(array('NOT_UPLOADED'), $file->error);
$type_remote::$tempnam_path = '';
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 7e0f192b40..b70d49cddd 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -45,11 +45,12 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
if (!is_array($config))
{
- $config = array();
+ $config = new \phpbb\config\config(array());
}
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
+ $config['remote_upload_verify'] = 0;
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
@@ -60,7 +61,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path));
$this->factory = new \phpbb\files\factory($container);
$container->set('files.factory', $this->factory);
- $container->set('files.types.remote', new \phpbb\files\types\remote($this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path));
+ $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path));
$this->phpbb_root_path = $phpbb_root_path;
}
diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php
index d358681ad1..9d284a7e57 100644
--- a/tests/functional/plupload_test.php
+++ b/tests/functional/plupload_test.php
@@ -107,11 +107,11 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
if ($i < self::CHUNKS - 1)
{
- $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent());
+ $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content());
}
else
{
- $response = json_decode(self::$client->getResponse()->getContent(), true);
+ $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
}
@@ -134,7 +134,8 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
'error' => UPLOAD_ERR_OK,
);
- $crawler = self::$client->request(
+ self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1');
+ self::$client->request(
'POST',
$url . '&sid=' . $this->sid,
array(
@@ -144,11 +145,10 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'),
),
- array('fileupload' => $file),
- array('X-PHPBB-USING-PLUPLOAD' => '1')
+ array('fileupload' => $file)
);
- $response = json_decode(self::$client->getResponse()->getContent(), true);
+ $response = json_decode(self::get_content(), true);
$this->assertEquals('valid.jpg', $response['data'][0]['real_filename']);
}
}
diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php
index c8e482e260..13ac325a79 100644
--- a/tests/installer/installer_config_test.php
+++ b/tests/installer/installer_config_test.php
@@ -52,8 +52,8 @@ class phpbb_installer_config_test extends phpbb_test_case
public function test_progress_tracking()
{
- $this->config->set_finished_task('foo');
- $this->config->set_active_module('bar');
+ $this->config->set_finished_task(0);
+ $this->config->set_active_module('bar', 5);
$this->config->set_task_progress_count(10);
$this->config->increment_current_task_progress();
@@ -66,7 +66,8 @@ class phpbb_installer_config_test extends phpbb_test_case
$result = $this->config->get_progress_data();
$expected_result = array(
'last_task_module_name' => 'bar',
- 'last_task_name' => 'foo',
+ 'last_task_module_index' => 5,
+ 'last_task_index' => 0,
'max_task_progress' => 10,
'current_task_progress' => 3,
);
diff --git a/tests/language/language_test.php b/tests/language/language_test.php
index 6a814e39dc..29b4873dcb 100644
--- a/tests/language/language_test.php
+++ b/tests/language/language_test.php
@@ -53,6 +53,25 @@ class phpbb_language_test extends phpbb_test_case
$this->assertFalse($this->lang->is_set(array('PHPBB', 'PHP')));
}
+ public function test_lang_raw()
+ {
+ $this->assertEquals($this->lang->lang_raw('FOO'), 'BAR');
+ $this->assertEquals($this->lang->lang_raw('VOID'), 'VOID');
+ $this->assertEquals($this->lang->lang_raw('ARRY'), array(
+ 0 => 'No posts', // 0
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 2+
+ ));
+ }
+
+ public function test_lang_array()
+ {
+ $this->assertEquals($this->lang->lang_array('FOO'), 'BAR');
+ $this->assertEquals($this->lang->lang_array('VOID'), 'VOID');
+ $this->assertEquals($this->lang->lang_array('ARRY', [0]), 'No posts');
+ $this->assertEquals($this->lang->lang_array('FOO', [2, 3, 'BARZ']), 'BAR');
+ }
+
public function test_lang()
{
// No param
diff --git a/tests/mock/migrator.php b/tests/mock/migrator.php
index 293f115335..4d1aca0a0a 100644
--- a/tests/mock/migrator.php
+++ b/tests/mock/migrator.php
@@ -21,10 +21,6 @@ class phpbb_mock_migrator extends \phpbb\db\migrator
{
}
- public function set_migrations($class_names)
- {
- }
-
public function update()
{
}
diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php
index 59cdf0bb2b..23dc3d1e8b 100644
--- a/tests/mock/phpbb_di_container_builder.php
+++ b/tests/mock/phpbb_di_container_builder.php
@@ -17,4 +17,14 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder
{
return $this->phpbb_root_path . '../../tmp/container.' . $this->php_ext;
}
+
+ /**
+ * Get the filename under which the dumped extensions autoloader will be stored.
+ *
+ * @return string Path for dumped extensions autoloader
+ */
+ protected function get_autoload_filename()
+ {
+ return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext;
+ }
}
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php
index 007441bc92..49dd40fbec 100644
--- a/tests/path_helper/path_helper_test.php
+++ b/tests/path_helper/path_helper_test.php
@@ -135,6 +135,43 @@ class phpbb_path_helper_test extends phpbb_test_case
'/phpbb3-fork/phpBB/app.php',
'./../',
),
+
+ // No correction if the path is already prepend by the web root path
+ array(
+ './../' . $this->phpbb_root_path . 'test.php',
+ '//',
+ null,
+ null,
+ '',
+ ),
+ array(
+ './../' . $this->phpbb_root_path . 'test.php',
+ '//',
+ 'foo/bar.php',
+ 'bar.php',
+ '',
+ ),
+ array(
+ './../../' . $this->phpbb_root_path . 'test.php',
+ '/foo/template',
+ '/phpbb3-fork/phpBB/app.php/foo/template',
+ '/phpbb3-fork/phpBB/app.php',
+ '',
+ ),
+ array(
+ './../' . $this->phpbb_root_path . 'test.php',
+ '/foo/template',
+ '/phpbb3-fork/phpBB/foo/template',
+ '/phpbb3-fork/phpBB/app.php',
+ '',
+ ),
+ array(
+ './../'.$this->phpbb_root_path . 'test.php',
+ '/',
+ '/phpbb3-fork/phpBB/app.php/',
+ '/phpbb3-fork/phpBB/app.php',
+ '',
+ ),
);
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index fa50d89a70..27ac64e21d 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -84,11 +84,18 @@ class phpbb_database_test_connection_manager
break;
default:
- $dsn .= 'host=' . $this->config['dbhost'];
-
- if ($this->config['dbport'])
+ if (!empty($this->config['dbport']) && !is_numeric($this->config['dbport']) && $this->dbms['PDO'] != 'pgsql')
+ {
+ $dsn .= 'unix_socket=' . $this->config['dbport'];
+ }
+ else
{
- $dsn .= ';port=' . $this->config['dbport'];
+ $dsn .= 'host=' . $this->config['dbhost'];
+
+ if ($this->config['dbport'])
+ {
+ $dsn .= ';port=' . $this->config['dbport'];
+ }
}
if ($use_db)
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index b91894f9c0..53519617b3 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -16,9 +16,11 @@ require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php';
class phpbb_functional_test_case extends phpbb_test_case
{
+ /** @var \Goutte\Client */
static protected $client;
static protected $cookieJar;
static protected $root_url;
+ static protected $install_success = false;
protected $cache = null;
protected $db = null;
@@ -77,13 +79,15 @@ class phpbb_functional_test_case extends phpbb_test_case
{
parent::setUp();
+ if (!self::$install_success)
+ {
+ $this->fail('Installing phpBB has failed.');
+ }
+
$this->bootstrap();
self::$cookieJar = new 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
- // resource
- self::$client->getClient()->getCurlMulti()->reset(true);
// Clear the language array so that things
// that were added in other tests are gone
@@ -94,6 +98,8 @@ class phpbb_functional_test_case extends phpbb_test_case
foreach (static::setup_extensions() as $extension)
{
+ $this->purge_cache();
+
$sql = 'SELECT ext_active
FROM ' . EXT_TABLE . "
WHERE ext_name = '" . $db->sql_escape($extension). "'";
@@ -167,7 +173,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
static public function get_content()
{
- return self::$client->getResponse()->getContent();
+ return (string) self::$client->getResponse()->getContent();
}
// bootstrap, called after board is set up
@@ -360,17 +366,21 @@ class phpbb_functional_test_case extends phpbb_test_case
$iohandler->set_input('script_path', $parseURL['path']);
$iohandler->set_input('submit_server', 'submit');
- do
- {
- $installer->run();
- }
- while (file_exists($phpbb_root_path . 'store/install_config.php'));
+ $installer->run();
copy($config_file, $config_file_test);
+ self::$install_success = true;
+
+ if (file_exists($phpbb_root_path . 'store/install_config.php'))
+ {
+ self::$install_success = false;
+ @unlink($phpbb_root_path . 'store/install_config.php');
+ }
+
if (file_exists($phpbb_root_path . 'cache/install_lock'))
{
- unlink($phpbb_root_path . 'cache/install_lock');
+ @unlink($phpbb_root_path . 'cache/install_lock');
}
global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template;
@@ -841,7 +851,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static public function assert_response_html($status_code = 200)
{
// Any output before the doc type means there was an error
- $content = self::$client->getResponse()->getContent();
+ $content = self::get_content();
self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<!DOCTYPE', trim($content), 'Output found before DOCTYPE specification.');
@@ -862,7 +872,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static public function assert_response_xml($status_code = 200)
{
// Any output before the xml opening means there was an error
- $content = self::$client->getResponse()->getContent();
+ $content = self::get_content();
self::assertNotContains('[phpBB Debug]', $content);
self::assertStringStartsWith('<?xml', trim($content), 'Output found before XML specification.');
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
index e118801972..8b60096081 100644
--- a/tests/test_framework/phpbb_ui_test_case.php
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -11,6 +11,11 @@
*
*/
+use Facebook\WebDriver\WebDriverBy;
+use Facebook\WebDriver\Exception\WebDriverCurlException;
+use Facebook\WebDriver\Remote\RemoteWebDriver;
+use Facebook\WebDriver\Remote\DesiredCapabilities;
+
require_once __DIR__ . '/mock/phpbb_mock_null_installer_task.php';
class phpbb_ui_test_case extends phpbb_test_case
@@ -19,13 +24,15 @@ class phpbb_ui_test_case extends phpbb_test_case
static protected $port = 8910;
/**
- * @var \RemoteWebDriver
+ * @var RemoteWebDriver
*/
static protected $webDriver;
static protected $config;
static protected $root_url;
static protected $already_installed = false;
+ static protected $install_success = false;
+ static protected $db;
static public function setUpBeforeClass()
{
@@ -35,7 +42,7 @@ class phpbb_ui_test_case extends phpbb_test_case
{
self::markTestSkipped('UI test case requires at least PHP 5.3.19.');
}
- else if (!class_exists('\RemoteWebDriver'))
+ else if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver'))
{
self::markTestSkipped(
'Could not find RemoteWebDriver class. ' .
@@ -60,7 +67,7 @@ class phpbb_ui_test_case extends phpbb_test_case
if (!self::$webDriver)
{
try {
- $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
+ $capabilities = DesiredCapabilities::firefox();
self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities);
} catch (WebDriverCurlException $e) {
self::markTestSkipped('PhantomJS webserver is not running.');
@@ -74,6 +81,25 @@ class phpbb_ui_test_case extends phpbb_test_case
}
}
+ public function setUp()
+ {
+ if (!self::$install_success)
+ {
+ $this->fail('Installing phpBB has failed.');
+ }
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+
+ if (self::$db instanceof \phpbb\db\driver\driver_interface)
+ {
+ // Close the database connections again this test
+ self::$db->sql_close();
+ }
+ }
+
static public function visit($path)
{
self::$webDriver->get(self::$root_url . $path);
@@ -98,10 +124,12 @@ class phpbb_ui_test_case extends phpbb_test_case
static public function install_board()
{
- global $phpbb_root_path, $phpEx;
+ global $phpbb_root_path, $phpEx, $db;
self::recreate_database(self::$config);
+ $db = self::get_db();
+
$config_file = $phpbb_root_path . "config.$phpEx";
$config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
$config_file_test = $phpbb_root_path . "config_test.$phpEx";
@@ -194,21 +222,40 @@ class phpbb_ui_test_case extends phpbb_test_case
$iohandler->set_input('script_path', $parseURL['path']);
$iohandler->set_input('submit_server', 'submit');
- do
- {
- $installer->run();
- }
- while (file_exists($phpbb_root_path . 'store/install_config.php'));
+ $installer->run();
copy($config_file, $config_file_test);
+ self::$install_success = true;
+
+ if (file_exists($phpbb_root_path . 'store/install_config.php'))
+ {
+ self::$install_success = false;
+ @unlink($phpbb_root_path . 'store/install_config.php');
+ }
+
if (file_exists($phpbb_root_path . 'cache/install_lock'))
{
- unlink($phpbb_root_path . 'cache/install_lock');
+ @unlink($phpbb_root_path . 'cache/install_lock');
}
global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template;
$phpbb_container->reset();
unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template);
}
+
+ static protected function get_db()
+ {
+ global $phpbb_root_path, $phpEx;
+ // so we don't reopen an open connection
+ if (!(self::$db instanceof \phpbb\db\driver\driver_interface))
+ {
+ $dbms = self::$config['dbms'];
+ /** @var \phpbb\db\driver\driver_interface $db */
+ $db = new $dbms();
+ $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
+ self::$db = $db;
+ }
+ return self::$db;
+ }
}
diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php
index 5bddb44a8b..582aeafcae 100644
--- a/tests/ui/quick_links_test.php
+++ b/tests/ui/quick_links_test.php
@@ -16,7 +16,6 @@
*/
class quick_links_test extends phpbb_ui_test_case
{
-
public function test_quick_links()
{
$this->visit('index.php');