1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-22 16:51:56 +02:00

Merge pull request from dhruvgoel92/feature/phantom

[feature/phantom]

* dhruvgoel92/feature/phantom:
  [ticket/12962] Rename setup-phpbb-test
  [ticket/12962] Use phpVersion in phpunit.xml
  [ticket/12962] Functional tests run for php <5.3.19
  [ticket/12962] Clean up composer.json
  [ticket/12962] Fix Line Endings in bootstrap
  [ticket/12962] Load composer test dependencies for php >= 5.3.19
  [ticket/12962] bootstrap functional and ui test when php >5.3.19
  [ticket/12962] Install test dependencies on travis
  [ticket/12962] Add facebook/webdriver dependency
  [ticket/12962] Fix whitespace characters
  [ticket/12962] Run tests for all databases on Travis
  [ticket/12962] Force language=en for UI tests installation
  [ticket/12962] Dump server output to /dev/null
  [ticket/12962] Start phantomjs on travis in background
  [ticket/12962] Mark test skipped when phantom server not running
  [ticket/12962] Add setup-phantomjs-server.sh
  [ticket/12962] Run UI tests on Travis-mysql
  [ticket/12962] Add UI tests to phpunit.xml.dist
  [ticket/12962] Add quick-links JS test
  [ticket/12962] Add initial class for ui_testing
This commit is contained in:
Andreas Fischer 2014-10-29 15:09:22 +01:00
commit 932b75c166
15 changed files with 339 additions and 0 deletions

1
.gitignore vendored

@ -22,3 +22,4 @@
/tests/phpbb_unit_tests.sqlite*
/tests/test_config*.php
/tests/tmp/*
/tests/vendor

@ -34,6 +34,7 @@ install:
before_script:
- travis/setup-database.sh $DB $TRAVIS_PHP_VERSION
- phantomjs --webdriver=8910 > /dev/null &
script:
- travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION

@ -16,6 +16,7 @@
<directory suffix="_test.php">./tests</directory>
<exclude>./tests/functional</exclude>
<exclude>./tests/lint_test.php</exclude>
<exclude>./tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php">./tests/functional</directory>
@ -23,6 +24,10 @@
<testsuite name="phpBB Lint Test">
<file>./tests/lint_test.php</file>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19"
phpVersionOperator=">=">./tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -33,3 +33,8 @@ 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';
require_once 'test_framework/phpbb_functional_test_case.php';
if (version_compare(PHP_VERSION,'5.3.19', ">="))
{
require_once 'test_framework/phpbb_ui_test_case.php';
}

5
tests/composer.json Normal file

@ -0,0 +1,5 @@
{
"require-dev": {
"facebook/webdriver": "dev-master"
}
}

66
tests/composer.lock generated Normal file

@ -0,0 +1,66 @@
{
"_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": "2affca245bd4946ca7acdf46f100af3c",
"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": [
]
}

@ -0,0 +1,192 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once __DIR__ . '/../vendor/facebook/webdriver/lib/__init__.php';
require_once __DIR__ . '/../../phpBB/includes/functions_install.php';
class phpbb_ui_test_case extends phpbb_test_case
{
static protected $host = '127.0.0.1';
static protected $port = 8910;
/**
* @var \RemoteWebDriver
*/
static protected $webDriver;
static protected $config;
static protected $root_url;
static protected $already_installed = false;
static public function setUpBeforeClass()
{
parent::setUpBeforeClass();
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
// test cases for querying the tables.
// Therefore table prefix must be set before a board is
// installed, and also before each test case is run.
self::$config['table_prefix'] = 'phpbb_';
if (!isset(self::$config['phpbb_functional_url']))
{
self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
}
if (!self::$webDriver)
{
try {
$capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities);
} catch (WebDriverCurlException $e) {
self::markTestSkipped('PhantomJS webserver is not running.');
}
}
if (!self::$already_installed)
{
self::install_board();
self::$already_installed = true;
}
}
static public function visit($path)
{
self::$webDriver->get(self::$root_url . $path);
}
static protected function recreate_database($config)
{
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
$db_conn_mgr->recreate_db();
}
static public function find_element($type, $value)
{
return self::$webDriver->findElement(WebDriverBy::$type($value));
}
static public function submit($type = 'id', $value = 'submit')
{
$element = self::find_element($type, $value);
$element->click();
}
static public function install_board()
{
global $phpbb_root_path, $phpEx;
self::recreate_database(self::$config);
$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";
if (file_exists($config_file))
{
if (!file_exists($config_file_dev))
{
rename($config_file, $config_file_dev);
}
else
{
unlink($config_file);
}
}
$parseURL = parse_url(self::$config['phpbb_functional_url']);
self::visit('install/index.php?mode=install&language=en');
self::assertContains('Welcome to Installation', self::find_element('id', 'main')->getText());
// install/index.php?mode=install&sub=requirements
self::submit();
self::assertContains('Installation compatibility', self::find_element('id', 'main')->getText());
// install/index.php?mode=install&sub=database
self::submit();
self::assertContains('Database configuration', self::find_element('id', 'main')->getText());
self::find_element('id','dbms')->sendKeys(str_replace('phpbb\db\driver\\', '', self::$config['dbms']));
self::find_element('id','dbhost')->sendKeys(self::$config['dbhost']);
self::find_element('id','dbport')->sendKeys(self::$config['dbport']);
self::find_element('id','dbname')->sendKeys(self::$config['dbname']);
self::find_element('id','dbuser')->sendKeys(self::$config['dbuser']);
self::find_element('id','dbpasswd')->sendKeys(self::$config['dbpasswd']);
// Need to clear default phpbb_ prefix
self::find_element('id','table_prefix')->clear();
self::find_element('id','table_prefix')->sendKeys(self::$config['table_prefix']);
// install/index.php?mode=install&sub=database
self::submit();
self::assertContains('Successful connection', self::find_element('id','main')->getText());
// install/index.php?mode=install&sub=administrator
self::submit();
self::assertContains('Administrator configuration', self::find_element('id','main')->getText());
self::find_element('id','admin_name')->sendKeys('admin');
self::find_element('id','admin_pass1')->sendKeys('adminadmin');
self::find_element('id','admin_pass2')->sendKeys('adminadmin');
self::find_element('id','board_email')->sendKeys('nobody@example.com');
// install/index.php?mode=install&sub=administrator
self::submit();
self::assertContains('Tests passed', self::find_element('id','main')->getText());
// install/index.php?mode=install&sub=config_file
self::submit();
// Installer has created a config.php file, we will overwrite it with a
// config file of our own in order to get the DEBUG constants defined
$config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true);
$config_created = file_put_contents($config_file, $config_php_data) !== false;
if (!$config_created)
{
self::markTestSkipped("Could not write $config_file file.");
}
if (strpos(self::find_element('id','main')->getText(), 'The configuration file has been written') === false)
{
self::submit('id', 'dldone');
}
self::assertContains('The configuration file has been written', self::find_element('id','main')->getText());
// install/index.php?mode=install&sub=advanced
self::submit();
self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', self::find_element('id','main')->getText());
self::find_element('id','smtp_delivery')->sendKeys('1');
self::find_element('id','smtp_host')->sendKeys('nxdomain.phpbb.com');
self::find_element('id','smtp_user')->sendKeys('nxuser');
self::find_element('id','smtp_pass')->sendKeys('nxpass');
self::find_element('id','server_protocol')->sendKeys($parseURL['scheme'] . '://');
self::find_element('id','server_name')->sendKeys('localhost');
self::find_element('id','server_port')->sendKeys(isset($parseURL['port']) ? $parseURL['port'] : 80);
self::find_element('id','script_path')->sendKeys($parseURL['path']);
// install/index.php?mode=install&sub=create_table
self::submit();
self::assertContains('The database tables used by phpBB', self::find_element('id','main')->getText());
self::assertContains('have been created and populated with some initial data.', self::find_element('id','main')->getText());
// install/index.php?mode=install&sub=final
self::submit();
self::assertContains('You have successfully installed', self::find_element('id', 'main')->getText());
copy($config_file, $config_file_test);
}
}

@ -0,0 +1,27 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* @group ui
*/
class quick_links_test extends phpbb_ui_test_case
{
public function test_quick_links()
{
$this->visit('index.php');
$this->assertEmpty(self::find_element('className', 'dropdown')->getText());
self::find_element('className', 'dropdown-toggle')->click();
$this->assertNotNull(self::find_element('className', 'dropdown')->getText());
}
}

@ -0,0 +1,16 @@
#!/bin/bash
#
# This file is part of the phpBB Forum Software package.
#
# @copyright (c) phpBB Limited <https://www.phpbb.com>
# @license GNU General Public License, version 2 (GPL-2.0)
#
# For full copyright and license information, please see
# the docs/CREDITS.txt file.
#
set -e
set -x
cd tests
php ../composer.phar install --dev --no-interaction --prefer-source
cd ..

@ -16,10 +16,14 @@
<directory suffix="_test.php">../tests</directory>
<exclude>../tests/functional</exclude>
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -16,10 +16,14 @@
<directory suffix="_test.php">../tests</directory>
<exclude>../tests/functional</exclude>
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -16,6 +16,7 @@
<directory suffix="_test.php">../tests</directory>
<exclude>../tests/functional</exclude>
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Lint Test">
<file>../tests/lint_test.php</file>
@ -23,6 +24,9 @@
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -16,10 +16,14 @@
<directory suffix="_test.php">../tests</directory>
<exclude>../tests/functional</exclude>
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -16,10 +16,14 @@
<directory suffix="_test.php">../tests</directory>
<exclude>../tests/functional</exclude>
<exclude>../tests/lint_test.php</exclude>
<exclude>../tests/ui</exclude>
</testsuite>
<testsuite name="phpBB Functional Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
<testsuite name="phpBB UI Tests">
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">../tests/ui</directory>
</testsuite>
</testsuites>
<groups>

@ -33,6 +33,7 @@ fi
if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` == "1" ]
then
travis/setup-webserver.sh
travis/install-phpbb-test-dependencies.sh
fi
cd phpBB