From 637d8eabe76907ce4a1e810d8b6bd964acb1b303 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 21 Aug 2011 19:26:15 +0200 Subject: [feature/functional-tests] Implementing functional test framework with goutte PHPBB3-10414 --- .../test_framework/phpbb_functional_test_case.php | 128 +++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tests/test_framework/phpbb_functional_test_case.php (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php new file mode 100644 index 0000000000..ddaa894061 --- /dev/null +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -0,0 +1,128 @@ +client = new Goutte\Client(); + $this->root_url = $_SERVER['PHPBB_FUNCTIONAL_URL']; + } + + public function request($method, $path) + { + return $this->client->request($method, $this->root_url . $path); + } + + static public function setUpBeforeClass() + { + global $phpbb_root_path, $phpEx; + + if (!isset($_SERVER['PHPBB_FUNCTIONAL_URL'])) + { + self::markTestSkipped("The 'PHPBB_FUNCTIONAL_URL' environment variable was not set."); + } + + if (!file_exists($phpbb_root_path . "config.$phpEx")) + { + self::markTestSkipped("config.php does not exist, it is required for running functional tests."); + } + + require $phpbb_root_path . "config.$phpEx"; + + $db_config = array( + 'dbhost' => $dbhost, + 'dbport' => $dbport, + 'dbname' => $dbname, + 'dbuser' => $dbuser, + 'dbpasswd' => $dbpasswd, + 'dbms' => $dbms, + 'table_prefix' => 'phpbb_', + ); + self::recreate_database($db_config); + + rename($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "_config.$phpEx"); + + // begin data + $data = array(); + + $data = array_merge($data, $db_config); + + $data = array_merge($data, array( + 'default_lang' => 'en', + 'admin_name' => 'admin', + 'admin_pass1' => 'admin', + 'admin_pass2' => 'admin', + 'board_email1' => 'nobody@example.com', + 'board_email2' => 'nobody@example.com', + )); + + $parseURL = parse_url($_SERVER['PHPBB_FUNCTIONAL_URL']); + + $data = array_merge($data, array( + 'email_enable' => false, + 'smtp_delivery' => false, + 'smtp_host' => '', + 'smtp_auth' => '', + 'smtp_user' => '', + 'smtp_pass' => '', + 'cookie_secure' => false, + 'force_server_vars' => false, + 'server_protocol' => $parseURL['scheme'] . '://', + 'server_name' => 'localhost', + 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80, + 'script_path' => $parseURL['path'], + )); + // end data + + $content = self::do_request('install'); + self::assertContains('Welcome to Installation', $content); + + self::do_request('config_file', $data); + + rename($phpbb_root_path . "_config.$phpEx", $phpbb_root_path . "config.$phpEx"); + + self::do_request('create_table', $data); + self::do_request('final', $data); + } + + static public function tearDownAfterClass() + { + } + + 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($_SERVER['PHPBB_FUNCTIONAL_URL'] . 'install/index.php?mode=install&sub=' . $sub, false, $context); + } + + static private function recreate_database($config) + { + $db_conn_mgr = new phpbb_database_test_connection_manager($config); + $db_conn_mgr->recreate_db(); + } +} -- cgit v1.2.1 From 0ffe494edd274647ba6694648dba070c63e55d89 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 14 Oct 2011 16:05:35 +0200 Subject: [feature/functional-tests] Configure functional tests through config file The functional tests now also use the test database PHPBB3-10414 --- .../test_framework/phpbb_functional_test_case.php | 54 ++++++++++++---------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ddaa894061..02d51d71de 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,6 +14,8 @@ class phpbb_functional_test_case extends phpbb_test_case protected $client; protected $root_url; + static protected $config; + public function setUp() { $this->client = new Goutte\Client(); @@ -29,35 +31,32 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - if (!isset($_SERVER['PHPBB_FUNCTIONAL_URL'])) - { - self::markTestSkipped("The 'PHPBB_FUNCTIONAL_URL' environment variable was not set."); - } + self::$config = phpbb_test_case_helpers::get_test_config(); - if (!file_exists($phpbb_root_path . "config.$phpEx")) + if (!isset(self::$config['phpbb_functional_url'])) { - self::markTestSkipped("config.php does not exist, it is required for running functional tests."); + self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } - require $phpbb_root_path . "config.$phpEx"; - - $db_config = array( - 'dbhost' => $dbhost, - 'dbport' => $dbport, - 'dbname' => $dbname, - 'dbuser' => $dbuser, - 'dbpasswd' => $dbpasswd, - 'dbms' => $dbms, - 'table_prefix' => 'phpbb_', - ); - self::recreate_database($db_config); + self::$config['table_prefix'] = 'phpbb_'; + self::recreate_database(self::$config); - rename($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "_config.$phpEx"); + if (file_exists($phpbb_root_path . "config.$phpEx")) + { + if (!file_exists($phpbb_root_path . "config_dev.$phpEx")) + { + rename($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_dev.$phpEx"); + } + else + { + unlink($phpbb_root_path . "config.$phpEx"); + } + } // begin data $data = array(); - $data = array_merge($data, $db_config); + $data = array_merge($data, self::$config); $data = array_merge($data, array( 'default_lang' => 'en', @@ -68,7 +67,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'board_email2' => 'nobody@example.com', )); - $parseURL = parse_url($_SERVER['PHPBB_FUNCTIONAL_URL']); + $parseURL = parse_url(self::$config['phpbb_functional_url']); $data = array_merge($data, array( 'email_enable' => false, @@ -89,16 +88,23 @@ class phpbb_functional_test_case extends phpbb_test_case $content = self::do_request('install'); self::assertContains('Welcome to Installation', $content); + self::do_request('create_table', $data); + self::do_request('config_file', $data); - rename($phpbb_root_path . "_config.$phpEx", $phpbb_root_path . "config.$phpEx"); + if (file_exists($phpbb_root_path . "config.$phpEx")) + { + copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); + } - self::do_request('create_table', $data); self::do_request('final', $data); } static public function tearDownAfterClass() { + global $phpbb_root_path, $phpEx; + + copy($phpbb_root_path . "config_dev.$phpEx", $phpbb_root_path . "config.$phpEx"); } static private function do_request($sub, $post_data = null) @@ -117,7 +123,7 @@ class phpbb_functional_test_case extends phpbb_test_case )); } - return file_get_contents($_SERVER['PHPBB_FUNCTIONAL_URL'] . 'install/index.php?mode=install&sub=' . $sub, false, $context); + return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context); } static private function recreate_database($config) -- cgit v1.2.1 From a3928bf82d7fd6a1da074716c08c547afc961346 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 14 Oct 2011 17:10:21 +0200 Subject: [feature/functional-tests] Generate config correctly and install only once PHPBB3-10414 --- .../test_framework/phpbb_functional_test_case.php | 65 ++++++++++++++-------- 1 file changed, 43 insertions(+), 22 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 02d51d71de..a8601f346c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -8,18 +8,25 @@ */ require_once __DIR__ . '/../../vendor/goutte.phar'; +require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; class phpbb_functional_test_case extends phpbb_test_case { protected $client; protected $root_url; - static protected $config; + static protected $config = array(); + static protected $already_installed = false; public function setUp() { + if (!isset(self::$config['phpbb_functional_url'])) + { + $this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); + } + $this->client = new Goutte\Client(); - $this->root_url = $_SERVER['PHPBB_FUNCTIONAL_URL']; + $this->root_url = self::$config['phpbb_functional_url']; } public function request($method, $path) @@ -27,7 +34,29 @@ class phpbb_functional_test_case extends phpbb_test_case return $this->client->request($method, $this->root_url . $path); } - static public function setUpBeforeClass() + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + parent::__construct($name, $data, $dataName); + + $this->backupStaticAttributesBlacklist += array( + 'PHP_CodeCoverage' => array('instance'), + 'PHP_CodeCoverage_Filter' => array('instance'), + 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'), + 'PHP_Timer' => array('startTimes',), + 'PHP_Token_Stream' => array('customTokens'), + 'PHP_Token_Stream_CachingFactory' => array('cache'), + + 'phpbb_functional_test_case' => array('config', 'already_installed'), + ); + + if (!self::$already_installed) + { + $this->install_board(); + self::$already_installed = true; + } + } + + protected function install_board() { global $phpbb_root_path, $phpEx; @@ -35,11 +64,11 @@ class phpbb_functional_test_case extends phpbb_test_case 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.'); + return; } self::$config['table_prefix'] = 'phpbb_'; - self::recreate_database(self::$config); + $this->recreate_database(self::$config); if (file_exists($phpbb_root_path . "config.$phpEx")) { @@ -85,29 +114,21 @@ class phpbb_functional_test_case extends phpbb_test_case )); // end data - $content = self::do_request('install'); - self::assertContains('Welcome to Installation', $content); + $content = $this->do_request('install'); + $this->assertContains('Welcome to Installation', $content); - self::do_request('create_table', $data); + $this->do_request('create_table', $data); - self::do_request('config_file', $data); + file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true)); - if (file_exists($phpbb_root_path . "config.$phpEx")) - { - copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); - } + $this->do_request('config_file', $data); - self::do_request('final', $data); - } - - static public function tearDownAfterClass() - { - global $phpbb_root_path, $phpEx; + copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); - copy($phpbb_root_path . "config_dev.$phpEx", $phpbb_root_path . "config.$phpEx"); + $this->do_request('final', $data); } - static private function do_request($sub, $post_data = null) + private function do_request($sub, $post_data = null) { $context = null; @@ -126,7 +147,7 @@ class phpbb_functional_test_case extends phpbb_test_case return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context); } - static private function recreate_database($config) + private function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); $db_conn_mgr->recreate_db(); -- cgit v1.2.1 From a8aa7fd6c094dcba20c45c6e81928c5a6942c48b Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Fri, 14 Oct 2011 17:18:33 +0200 Subject: [feature/functional-tests] Don't add elements to backup list twice PHPBB3-10414 --- tests/test_framework/phpbb_functional_test_case.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a8601f346c..18bf2a84a8 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -39,13 +39,6 @@ class phpbb_functional_test_case extends phpbb_test_case parent::__construct($name, $data, $dataName); $this->backupStaticAttributesBlacklist += array( - 'PHP_CodeCoverage' => array('instance'), - 'PHP_CodeCoverage_Filter' => array('instance'), - 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'), - 'PHP_Timer' => array('startTimes',), - 'PHP_Token_Stream' => array('customTokens'), - 'PHP_Token_Stream_CachingFactory' => array('cache'), - 'phpbb_functional_test_case' => array('config', 'already_installed'), ); -- cgit v1.2.1 From 66b0cfe221667e8776c2244f8748e3eba2632ff4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 14 Oct 2011 19:37:20 +0200 Subject: [feature/functional-tests] Make sure functional tests only install once The functional test setup bootstrapping should only be run once per class. PHPBB3-10414 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 18bf2a84a8..bae035e773 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -42,10 +42,10 @@ class phpbb_functional_test_case extends phpbb_test_case 'phpbb_functional_test_case' => array('config', 'already_installed'), ); - if (!self::$already_installed) + if (!static::$already_installed) { $this->install_board(); - self::$already_installed = true; + static::$already_installed = true; } } -- cgit v1.2.1 From d4189013ab3c6c9fca7fd79c3137888d169f1d60 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 14 Oct 2011 19:41:19 +0200 Subject: [feature/functional-tests] Introduce bootstrap method PHPBB3-10414 --- tests/test_framework/phpbb_functional_test_case.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index bae035e773..73dfe74e45 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -34,6 +34,13 @@ class phpbb_functional_test_case extends phpbb_test_case return $this->client->request($method, $this->root_url . $path); } + // bootstrap, called after board is set up + // once per test case class + // test cases can override this + protected function bootstrap() + { + } + public function __construct($name = NULL, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); @@ -45,6 +52,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (!static::$already_installed) { $this->install_board(); + $this->bootstrap(); static::$already_installed = true; } } -- cgit v1.2.1 From 44cab5696fb7cb60a97f4010c3ef75f88d879b6a Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 24 Nov 2011 03:26:51 -0500 Subject: [ticket/10481] Skip functional tests if phar extension is missing. PHPBB3-10481 --- tests/test_framework/phpbb_functional_test_case.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 18bf2a84a8..57cc0f8959 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -7,7 +7,6 @@ * */ -require_once __DIR__ . '/../../vendor/goutte.phar'; require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; class phpbb_functional_test_case extends phpbb_test_case @@ -18,6 +17,16 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $config = array(); static protected $already_installed = false; + static public function setUpBeforeClass() + { + if (!extension_loaded('phar')) + { + self::markTestSkipped('phar extension is not loaded'); + } + + require_once __DIR__ . '/../../vendor/goutte.phar'; + } + public function setUp() { if (!isset(self::$config['phpbb_functional_url'])) -- cgit v1.2.1 From ba1603a5f0e06d30a930170bec0773a3fbe68fc2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 24 Nov 2011 14:16:58 -0500 Subject: [ticket/10481] Use phar:// url for requiring goutte. It does not seem to work on my machine without phar:// even with phar extension installed. PHPBB3-10481 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 57cc0f8959..a1c642bf38 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -24,7 +24,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::markTestSkipped('phar extension is not loaded'); } - require_once __DIR__ . '/../../vendor/goutte.phar'; + require_once 'phar://' . __DIR__ . '/../../vendor/goutte.phar'; } public function setUp() -- cgit v1.2.1 From fc297a710e56d938afce83de401b103c72218a1b Mon Sep 17 00:00:00 2001 From: p Date: Fri, 23 Dec 2011 22:10:34 +0000 Subject: [ticket/10535] Delete email confirm from installer PHPBB3-10535 --- tests/test_framework/phpbb_functional_test_case.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 63b9d52bf0..9c9fa4fcee 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -102,8 +102,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'admin_name' => 'admin', 'admin_pass1' => 'admin', 'admin_pass2' => 'admin', - 'board_email1' => 'nobody@example.com', - 'board_email2' => 'nobody@example.com', + 'board_email' => 'nobody@example.com', )); $parseURL = parse_url(self::$config['phpbb_functional_url']); -- cgit v1.2.1 From 66c50f6b30400b729d3fea4fb06dad5eb559aa51 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 2 Jan 2012 17:14:00 +0000 Subject: [ticket/9916] Updating license in non-distributed files PHPBB3-9916 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 63b9d52bf0..ca52d24b7e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -3,7 +3,7 @@ * * @package testing * @copyright (c) 2011 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From a37a28b48546afc880446db7e4b2fd87c70a6cda Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 10:53:22 -0500 Subject: [ticket/10586] Now tests run, but fail. But here is what I have. PHPBB3-10586 --- tests/test_framework/phpbb_functional_test_case.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b5e6f7e377..b2ae215d91 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -66,6 +66,26 @@ class phpbb_functional_test_case extends phpbb_test_case } } + protected function get_db() + { + global $phpbb_root_path, $phpEx; + if (!class_exists('dbal_' . self::$config['dbms'])) + { + include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + } + $sql_db = 'dbal_' . self::$config['dbms']; + $db = new $sql_db(); + $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); + return $db; + } + + protected function get_ext_manager() + { + global $phpbb_root_path, $phpEx; + + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_null); + } + protected function install_board() { global $phpbb_root_path, $phpEx; -- cgit v1.2.1 From d235262bc21657f0693501ac1154e1443578d507 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 11:17:21 -0500 Subject: [ticket/10586] Adding the extensions used by the tests PHPBB3-10586 --- tests/test_framework/phpbb_functional_test_case.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b2ae215d91..9797ecfef8 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,6 +14,8 @@ class phpbb_functional_test_case extends phpbb_test_case protected $client; protected $root_url; + protected $db = null; + static protected $config = array(); static protected $already_installed = false; @@ -69,14 +71,18 @@ class phpbb_functional_test_case extends phpbb_test_case protected function get_db() { global $phpbb_root_path, $phpEx; - if (!class_exists('dbal_' . self::$config['dbms'])) + // so we don't reopen an open connection + if (!($this->db instanceof dbal)) { - include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + 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']); } - $sql_db = 'dbal_' . self::$config['dbms']; - $db = new $sql_db(); - $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); - return $db; + return $this->db; } protected function get_ext_manager() -- cgit v1.2.1 From 7d1e4bca334dc9fcef3eb6e62cb412226ebc7ca4 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 14:44:37 -0400 Subject: [ticket/10586] more work on getting tests to pass PHPBB3-10586 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9797ecfef8..b3376891bc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -89,7 +89,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_null); + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_file); } protected function install_board() -- cgit v1.2.1 From 76e61951942048e3e98dbe60a3683d5269a4fa0e Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 16:50:41 -0400 Subject: [ticket/10586] trying to get tests to work PHPBB3-10586 --- tests/test_framework/phpbb_functional_test_case.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b3376891bc..d569556d02 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,6 +14,7 @@ class phpbb_functional_test_case extends phpbb_test_case protected $client; protected $root_url; + protected $cache = null; protected $db = null; static protected $config = array(); @@ -88,8 +89,8 @@ class phpbb_functional_test_case extends phpbb_test_case protected function get_ext_manager() { global $phpbb_root_path, $phpEx; - - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_file); + $this->cache = ($this->cache instanceof phpbb_cache_driver_null) ? $this->cache : new phpbb_cache_driver_null; + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", $this->cache); } protected function install_board() -- cgit v1.2.1 From 1bbb32a5cffeff4875c4ed0566999cbee8919c86 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 18 Mar 2012 22:57:37 +0100 Subject: [ticket/10586] Correctly purge board cache and don't rename install directory PHPBB3-10586 --- .../test_framework/phpbb_functional_test_case.php | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d569556d02..69c62af297 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -16,6 +16,7 @@ class phpbb_functional_test_case extends phpbb_test_case protected $cache = null; protected $db = null; + protected $extension_manager = null; static protected $config = array(); static protected $already_installed = false; @@ -86,11 +87,41 @@ class phpbb_functional_test_case extends phpbb_test_case return $this->db; } - protected function get_ext_manager() + 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; - $this->cache = ($this->cache instanceof phpbb_cache_driver_null) ? $this->cache : new phpbb_cache_driver_null; - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", $this->cache); + + 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() -- cgit v1.2.1 From 90a957ad26f52e26c3979464c5ac15b1fd0fcc28 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 21 Jul 2012 17:43:43 +0200 Subject: [ticket/11015] Make DBAL classes autoloadable PHPBB3-11015 This allows us to just create the object without having to include the driver first. However, it also means that users must specify the full class name in config.php --- tests/test_framework/phpbb_functional_test_case.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c042d75811..ce0042d538 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -87,12 +87,8 @@ class phpbb_functional_test_case extends phpbb_test_case // 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(); + $dbms = self::$config['dbms']; + $this->db = new $dbms(); $this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); } return $this->db; -- cgit v1.2.1 From fd5ed30052a03d812cfdf95f4e86b0c997b5aa10 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 23 Jul 2012 20:34:47 -0500 Subject: [ticket/10631] Update tests PHPBB3-10631 --- tests/test_framework/phpbb_functional_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b953017d0a..a1deeb2b63 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -125,6 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->extension_manager = new phpbb_extension_manager( $this->get_db(), + new phpbb_config(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", -- cgit v1.2.1 From 36465c9a205c356b0662e45b4fded79c4b476547 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 29 Jul 2012 20:08:30 -0500 Subject: [ticket/10631] Functional acp_extensions test, cleanup PHPBB3-10631 --- .../test_framework/phpbb_functional_test_case.php | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a1deeb2b63..6b4c0b6883 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -252,6 +252,48 @@ class phpbb_functional_test_case extends phpbb_test_case } } + /** + * Login to the ACP + * You must run login() before calling this. + */ + protected function admin_login() + { + $this->add_lang('acp/common'); + + // Requires login first! + if (empty($this->sid)) + { + $this->fail('$this->sid is empty. Make sure you call login() before admin_login()'); + return; + } + + $crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text()); + + $form = $crawler->selectButton($this->lang('LOGIN'))->form(); + + foreach ($form->getValues() as $field => $value) + { + if (strpos($field, 'password_') === 0) + { + $login = $this->client->submit($form, array('username' => 'admin', $field => 'admin')); + + $cookies = $this->cookieJar->all(); + + // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie + foreach ($cookies as $cookie); + { + if (substr($cookie->getName(), -4) == '_sid') + { + $this->sid = $cookie->getValue(); + } + } + + break; + } + } + } + protected function add_lang($lang_file) { if (is_array($lang_file)) @@ -288,4 +330,16 @@ class phpbb_functional_test_case extends phpbb_test_case return call_user_func_array('sprintf', $args); } + + /** + * assertContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertContainsLang($needle, $haystack, $message = null) + { + $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } } -- cgit v1.2.1 From 195014867ae84fe04ec01c913e38bf1d435590f7 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 10 Nov 2012 11:25:22 +0100 Subject: [ticket/11183] Remove $load_extensions and weird dl() calls PHPBB3-11183 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d002615e8c..2d44bfc359 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -199,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->do_request('create_table', $data); $this->do_request('config_file', $data); - file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true)); + file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], true, true)); $this->do_request('final', $data); copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx"); -- cgit v1.2.1 From c73293d82673631da61acffeef31a93bcca139dd Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sat, 10 Nov 2012 13:46:40 +0000 Subject: [ticket/11187] Added a blank array to fix errors in functional tests PHPBB3-11187 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d002615e8c..d0bbf85960 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -125,7 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->extension_manager = new phpbb_extension_manager( $this->get_db(), - new phpbb_config(), + new phpbb_config(array()), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", -- cgit v1.2.1 From db0cc74af073ede415b1ff21556a31f01ecfbe8f Mon Sep 17 00:00:00 2001 From: Fyorl Date: Sun, 11 Nov 2012 10:51:53 +0000 Subject: [ticket/11190-develop] Functional tests purge cache before running. PHPBB3-11190 --- tests/test_framework/phpbb_functional_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 41edb3e6af..eb2b497708 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -51,6 +51,7 @@ class phpbb_functional_test_case extends phpbb_test_case // that were added in other tests are gone $this->lang = array(); $this->add_lang('common'); + $this->purge_cache(); } public function request($method, $path) -- cgit v1.2.1 From ec06d5c5d9f23b6419f048b885b689aa0ab4b351 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Nov 2012 08:18:55 -0500 Subject: [ticket/11204] Reindent. PHPBB3-11204 --- .../test_framework/phpbb_functional_test_case.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 8a329d43b1..16e1ccaff9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -332,17 +332,17 @@ class phpbb_functional_test_case extends phpbb_test_case return call_user_func_array('sprintf', $args); } - /** - * assertContains for language strings - * - * @param string $needle Search string - * @param string $haystack Search this - * @param string $message Optional failure message - */ - public function assertContainsLang($needle, $haystack, $message = null) - { - $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); - } + /** + * assertContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertContainsLang($needle, $haystack, $message = null) + { + $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } /** * Heuristic function to check that the response is success. -- cgit v1.2.1 From 74093d0fd383619ec8b58914ebe2edd68145e070 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Tue, 4 Dec 2012 04:32:37 -0500 Subject: [ticket/11015] Fix functional test case. PHPBB3-11015 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f9c1d64ff8..2a24e96a25 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -86,7 +86,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; // so we don't reopen an open connection - if (!($this->db instanceof dbal)) + if (!($this->db instanceof phpbb_db_driver)) { $dbms = self::$config['dbms']; $this->db = new $dbms(); -- cgit v1.2.1 From 4de07338efcd4f0d390df0f2d7fa883712d8c942 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 13 Dec 2012 07:28:01 -0500 Subject: [ticket/10975] Avoid rewriting global config twice. PHPBB3-10975 --- tests/test_framework/phpbb_functional_test_case.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9097854bd4..b6f8e5c44c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -251,16 +251,12 @@ class phpbb_functional_test_case extends phpbb_test_case // Required by unique_id global $config; - if (!is_array($config)) - { - $config = array(); - } - + $config = new phpbb_config(array()); $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; // Required by user_add - global $db, $cache, $config, $phpbb_dispatcher; + global $db, $cache, $phpbb_dispatcher; $db = $this->get_db(); if (!function_exists('phpbb_mock_null_cache')) { @@ -276,7 +272,6 @@ class phpbb_functional_test_case extends phpbb_test_case { require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - $config = new phpbb_config(array()); set_config(null, null, null, $config); set_config_count(null, null, null, $config); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); -- cgit v1.2.1 From 1774dd2af43e84f879813dedb0780f614810ad8a Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 13 Dec 2012 17:49:30 -0500 Subject: [ticket/11015] Installer still needs 3.0-style dbms name. PHPBB3-11015 --- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index db7fc4e6a3..67a5050892 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -202,6 +202,8 @@ class phpbb_functional_test_case extends phpbb_test_case self::assertNotSame(false, $content); self::assertContains('Welcome to Installation', $content); + // Installer uses 3.0-style dbms name + $data['dbms'] = str_replace('phpbb_db_driver_', '', $data['dbms']); $content = self::do_request('create_table', $data); self::assertNotSame(false, $content); self::assertContains('The database tables used by phpBB', $content); -- cgit v1.2.1 From ff83580af1af7623012843c56fba605ec2ad7df1 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 15 Dec 2012 13:45:33 -0500 Subject: [ticket/10758] Add a test for acp login. PHPBB3-10758 --- tests/test_framework/phpbb_functional_test_case.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 67a5050892..c599abcbcd 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -323,7 +323,7 @@ class phpbb_functional_test_case extends phpbb_test_case * Login to the ACP * You must run login() before calling this. */ - protected function admin_login() + protected function admin_login($username = 'admin') { $this->add_lang('acp/common'); @@ -343,7 +343,9 @@ class phpbb_functional_test_case extends phpbb_test_case { if (strpos($field, 'password_') === 0) { - $login = $this->client->submit($form, array('username' => 'admin', $field => 'admin')); + $crawler = $this->client->submit($form, array('username' => $username, $field => $username)); + $this->assert_response_success(); + $this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text()); $cookies = $this->cookieJar->all(); -- cgit v1.2.1 From b6f40f7c33a4cdb4a31af6374b2b1fd7c13deb08 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 20 Dec 2012 20:27:59 -0500 Subject: [ticket/10758-upload] Convert error to a failure. PHPBB3-10758 --- tests/test_framework/phpbb_functional_test_case.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 67a5050892..a051410d7b 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -424,4 +424,20 @@ class phpbb_functional_test_case extends phpbb_test_case $content = $this->client->getResponse()->getContent(); $this->assertNotContains('Fatal error:', $content); } + + public function assert_filter($crawler, $expr, $msg = null) + { + $nodes = $crawler->filter($expr); + if ($msg) + { + $msg .= "\n"; + } + else + { + $msg = ''; + } + $msg .= "`$expr` not found in DOM."; + $this->assertGreaterThan(0, count($nodes), $msg); + return $nodes; + } } -- cgit v1.2.1 From 0483971f7786b10c3359dfbe4912501de0d6c7de Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 2 Jan 2013 21:44:22 +0100 Subject: [ticket/11305] Mock container for cache driver in functional create_user() create_user has calls to fetch the cache driver from the container. This PR mocks the container and returns a null cache driver in that case. PHPBB3-11305 --- tests/test_framework/phpbb_functional_test_case.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 59979e035d..e346223a4b 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -262,7 +262,7 @@ class phpbb_functional_test_case extends phpbb_test_case $config['rand_seed_last_update'] = time() + 600; // Required by user_add - global $db, $cache, $phpbb_dispatcher; + global $db, $cache, $phpbb_dispatcher, $phpbb_container; $db = $this->get_db(); if (!function_exists('phpbb_mock_null_cache')) { @@ -270,6 +270,14 @@ class phpbb_functional_test_case extends phpbb_test_case } $cache = new phpbb_mock_null_cache; + $cache_driver = new phpbb_cache_driver_null(); + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container + ->expects($this->any()) + ->method('get') + ->with('cache.driver') + ->will($this->returnValue($cache_driver)); + if (!function_exists('utf_clean_string')) { require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); -- cgit v1.2.1 From 8d3a82a4fa8ced50fbc1d1019ef439d1d5c81e71 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Thu, 10 Jan 2013 19:32:39 -0600 Subject: [feature/migrations] Make the container available to extension installers This allows extensions to load and install migrations easily as per their needs. PHPBB3-11318 --- tests/test_framework/phpbb_functional_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e346223a4b..cb0a475278 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -137,6 +137,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (!$this->extension_manager) { $this->extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), $this->get_db(), new phpbb_config(array()), self::$config['table_prefix'] . 'ext', -- cgit v1.2.1 From 193a3beb8f75e17b09a0e66d2815bc2bf8d4dce4 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 13 Feb 2013 21:12:50 -0600 Subject: [feature/migrations] Fix failing tests (again) PHPBB3-11318 --- .../test_framework/phpbb_functional_test_case.php | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index cb0a475278..b570b464e6 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -134,20 +134,20 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - if (!$this->extension_manager) - { - $this->extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $this->get_db(), - new phpbb_config(array()), - self::$config['table_prefix'] . 'ext', - $phpbb_root_path, - ".$phpEx", - $this->get_cache_driver() - ); - } - - return $this->extension_manager; + $config = new phpbb_config(array()); + $db = $this->get_db(); + $db_tools = new phpbb_db_tools($db); + + return new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + new phpbb_db_migrator($config, $db, $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, self::$config['table_prefix'], array()), + self::$config['table_prefix'] . 'ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + $this->get_cache_driver() + ); } static protected function install_board() -- cgit v1.2.1 From 8415ae839cf699e043fe24ad91585dc419596ff8 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 2 Mar 2013 11:37:58 -0600 Subject: [ticket/11386] Update tests with new constructors for ext.manager/migrator PHPBB3-11386 --- tests/test_framework/phpbb_functional_test_case.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b570b464e6..ff358033b1 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -138,16 +138,29 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $db_tools = new phpbb_db_tools($db); - return new phpbb_extension_manager( + $extension_manager = new phpbb_extension_manager( new phpbb_mock_container_builder(), $db, $config, - new phpbb_db_migrator($config, $db, $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, self::$config['table_prefix'], array()), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', '.' . $php_ext, $this->get_cache_driver() ); + $migrator = new phpbb_db_migrator( + $config, + $db, + $db_tools, + $manager, + self::$config['table_prefix'] . 'migrations', + $phpbb_root_path, + $php_ext, + self::$config['table_prefix'], + array() + ); + $extension_manager->set_migrator($migrator); + + return $extension_manager; } static protected function install_board() -- cgit v1.2.1 From 91be99822312d9a83ae4f6849eef864dfd47e4a1 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sat, 2 Mar 2013 15:17:51 -0600 Subject: [ticket/11386] Fix failing tests from constructor changes PHPBB3-11386 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ff358033b1..3b9629b9f8 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -151,7 +151,6 @@ class phpbb_functional_test_case extends phpbb_test_case $config, $db, $db_tools, - $manager, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, $php_ext, @@ -159,6 +158,7 @@ class phpbb_functional_test_case extends phpbb_test_case array() ); $extension_manager->set_migrator($migrator); + $migrator->set_extension_manager($extension_manager); return $extension_manager; } -- cgit v1.2.1 From e4f782819968ec44f1dd207dc9de7ec703826d29 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Sun, 3 Mar 2013 19:54:22 -0600 Subject: [ticket/11386] Send list of migrations instead of using load_migrations Remove dependency of extension manager for migrator. Keeping load_migrations function for others to use if they desire but requiring the finder be sent to it in order to use it. PHPBB3-11386 --- tests/test_framework/phpbb_functional_test_case.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 3b9629b9f8..887dfea3b5 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -138,15 +138,6 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $db_tools = new phpbb_db_tools($db); - $extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), - $db, - $config, - self::$config['table_prefix'] . 'ext', - dirname(__FILE__) . '/', - '.' . $php_ext, - $this->get_cache_driver() - ); $migrator = new phpbb_db_migrator( $config, $db, @@ -157,8 +148,16 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'], array() ); - $extension_manager->set_migrator($migrator); - $migrator->set_extension_manager($extension_manager); + $extension_manager = new phpbb_extension_manager( + new phpbb_mock_container_builder(), + $db, + $config, + $migrator, + self::$config['table_prefix'] . 'ext', + dirname(__FILE__) . '/', + '.' . $php_ext, + $this->get_cache_driver() + ); return $extension_manager; } -- cgit v1.2.1 From 15aec0bbb24be10da850f78d85a3d10880c6f28a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 21 Mar 2013 03:07:50 +0100 Subject: [ticket/11460] Add methods for checkbox handling to phpbb_functional_test_case. PHPBB3-11460 --- .../test_framework/phpbb_functional_test_case.php | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 887dfea3b5..a62f5341ca 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -463,4 +463,68 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertGreaterThan(0, count($nodes), $msg); return $nodes; } + + /** + * Asserts that exactly one checkbox with name $name exists within the scope + * of $crawler and that the checkbox is checked. + * + * @param Symfony\Component\DomCrawler\Crawler $crawler + * @param string $name + * @param string $message + * + * @return null + */ + public function assert_checkbox_is_checked($crawler, $name, $message = '') + { + $this->assertSame( + 'checked', + $this->assert_find_one_checkbox($crawler, $name)->attr('checked'), + $message ?: "Failed asserting that checkbox $name is checked." + ); + } + + /** + * Asserts that exactly one checkbox with name $name exists within the scope + * of $crawler and that the checkbox is unchecked. + * + * @param Symfony\Component\DomCrawler\Crawler $crawler + * @param string $name + * @param string $message + * + * @return null + */ + public function assert_checkbox_is_unchecked($crawler, $name, $message = '') + { + $this->assertSame( + '', + $this->assert_find_one_checkbox($crawler, $name)->attr('checked'), + $message ?: "Failed asserting that checkbox $name is unchecked." + ); + } + + /** + * Searches for an input element of type checkbox with the name $name using + * $crawler. Contains an assertion that only one such checkbox exists within + * the scope of $crawler. + * + * @param Symfony\Component\DomCrawler\Crawler $crawler + * @param string $name + * @param string $message + * + * @return Symfony\Component\DomCrawler\Crawler + */ + public function assert_find_one_checkbox($crawler, $name, $message = '') + { + $query = sprintf('//input[@type="checkbox" and @name="%s"]', $name); + $result = $crawler->filterXPath($query); + + $this->assertEquals( + 1, + sizeof($result), + $message ?: 'Failed asserting that exactly one checkbox with name' . + " $name exists in crawler scope." + ); + + return $result; + } } -- cgit v1.2.1 From 02817158fc4209b57893eaba107f732274835fa7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Mar 2013 22:42:05 +0100 Subject: [ticket/11460] Configure functional test board email using dummy SMTP data. PHPBB3-11460 --- tests/test_framework/phpbb_functional_test_case.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a62f5341ca..a411d9c98a 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -196,12 +196,12 @@ class phpbb_functional_test_case extends phpbb_test_case $parseURL = parse_url(self::$config['phpbb_functional_url']); $data = array_merge($data, array( - 'email_enable' => false, - 'smtp_delivery' => false, - 'smtp_host' => '', - 'smtp_auth' => '', - 'smtp_user' => '', - 'smtp_pass' => '', + 'email_enable' => true, + 'smtp_delivery' => true, + 'smtp_host' => 'nxdomain.phpbb.com', + 'smtp_auth' => '', + 'smtp_user' => 'nxuser', + 'smtp_pass' => 'nxpass', 'cookie_secure' => false, 'force_server_vars' => false, 'server_protocol' => $parseURL['scheme'] . '://', -- cgit v1.2.1 From 60713c8a203b4d92db016f38cf8d78165d72b30a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Apr 2013 14:06:08 +0200 Subject: [ticket/11492] Add functional test for empty teampage PHPBB3-11492 --- .../test_framework/phpbb_functional_test_case.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a411d9c98a..283110a104 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -316,6 +316,46 @@ class phpbb_functional_test_case extends phpbb_test_case return user_add($user_row); } + protected function remove_user_group($group_name, $usernames) + { + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container; + + $config = new phpbb_config(array()); + $config['coppa_enable'] = 0; + + $db = $this->get_db(); + + $cache = new phpbb_mock_null_cache; + + $cache_driver = new phpbb_cache_driver_null(); + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container + ->expects($this->any()) + ->method('get') + ->with('cache.driver') + ->will($this->returnValue($cache_driver)); + + if (!function_exists('utf_clean_string')) + { + require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); + } + if (!function_exists('group_user_del')) + { + require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); + } + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $auth = $this->getMock('Observer', array('acl_clear_prefetch')); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = '" . $db->sql_escape($group_name) . "'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + return group_user_del($group_id, false, $usernames, $group_name); + } + protected function login($username = 'admin') { $this->add_lang('ucp'); -- cgit v1.2.1 From 59ad90b25c50f0a4062ae5e190b27811c4c0279b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Apr 2013 15:18:47 +0200 Subject: [ticket/11492] Add tests for removing/adding users PHPBB3-11492 --- .../test_framework/phpbb_functional_test_case.php | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 283110a104..3eba57caa7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -318,13 +318,18 @@ class phpbb_functional_test_case extends phpbb_test_case protected function remove_user_group($group_name, $usernames) { - global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_container; + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container; $config = new phpbb_config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); + $phpbb_log = $this->getMock('phpbb_log'); + $phpbb_log + ->expects($this->any()) + ->method('add') + ->will($this->returnValue(true)); $cache = new phpbb_mock_null_cache; $cache_driver = new phpbb_cache_driver_null(); @@ -356,6 +361,51 @@ class phpbb_functional_test_case extends phpbb_test_case return group_user_del($group_id, false, $usernames, $group_name); } + protected function add_user_group($group_name, $usernames) + { + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container; + + $config = new phpbb_config(array()); + $config['coppa_enable'] = 0; + + $db = $this->get_db(); + + $phpbb_log = $this->getMock('phpbb_log'); + $phpbb_log + ->expects($this->any()) + ->method('add') + ->will($this->returnValue(true)); + $cache = new phpbb_mock_null_cache; + + $cache_driver = new phpbb_cache_driver_null(); + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container + ->expects($this->any()) + ->method('get') + ->with('cache.driver') + ->will($this->returnValue($cache_driver)); + + if (!function_exists('utf_clean_string')) + { + require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php'); + } + if (!function_exists('group_user_del')) + { + require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); + } + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $auth = $this->getMock('Observer', array('acl_clear_prefetch')); + + $sql = 'SELECT group_id + FROM ' . GROUPS_TABLE . " + WHERE group_name = '" . $db->sql_escape($group_name) . "'"; + $result = $db->sql_query($sql); + $group_id = (int) $db->sql_fetchfield('group_id'); + $db->sql_freeresult($result); + + return group_user_add($group_id, false, $usernames, $group_name); + } + protected function login($username = 'admin') { $this->add_lang('ucp'); -- cgit v1.2.1 From 7f527e801221bf5638acf0d46a94c0e28ec03331 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Apr 2013 15:59:31 +0200 Subject: [ticket/11492] Fix issues with log object PHPBB3-11492 --- .../test_framework/phpbb_functional_test_case.php | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 3eba57caa7..db6a6066e4 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -318,18 +318,17 @@ class phpbb_functional_test_case extends phpbb_test_case protected function remove_user_group($group_name, $usernames) { - global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container; + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; $config = new phpbb_config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user = $this->getMock('phpbb_user'); + $auth = $this->getMock('phpbb_auth'); - $phpbb_log = $this->getMock('phpbb_log'); - $phpbb_log - ->expects($this->any()) - ->method('add') - ->will($this->returnValue(true)); + $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; $cache_driver = new phpbb_cache_driver_null(); @@ -348,8 +347,6 @@ class phpbb_functional_test_case extends phpbb_test_case { require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $auth = $this->getMock('Observer', array('acl_clear_prefetch')); $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " @@ -363,18 +360,17 @@ class phpbb_functional_test_case extends phpbb_test_case protected function add_user_group($group_name, $usernames) { - global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container; + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; $config = new phpbb_config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $user = $this->getMock('phpbb_user'); + $auth = $this->getMock('phpbb_auth'); - $phpbb_log = $this->getMock('phpbb_log'); - $phpbb_log - ->expects($this->any()) - ->method('add') - ->will($this->returnValue(true)); + $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; $cache_driver = new phpbb_cache_driver_null(); @@ -393,8 +389,6 @@ class phpbb_functional_test_case extends phpbb_test_case { require_once(__DIR__ . '/../../phpBB/includes/functions_user.php'); } - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $auth = $this->getMock('Observer', array('acl_clear_prefetch')); $sql = 'SELECT group_id FROM ' . GROUPS_TABLE . " -- cgit v1.2.1 From 423b310e2acbbc72814a4278a4cccf2900114f85 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 17 Apr 2013 18:43:19 +0200 Subject: [ticket/11362] Extension manager depends on filesystem PHPBB3-11362 --- tests/test_framework/phpbb_functional_test_case.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 887dfea3b5..891fe237b3 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -153,6 +153,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db, $config, $migrator, + new phpbb_filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', '.' . $php_ext, -- cgit v1.2.1 From f49993766e2bcf4efe346e29972f3721b1b1438a Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 24 Apr 2013 17:41:27 -0500 Subject: [ticket/11335] (more) Make php_ext 'php' not '.php' PHPBB3-11335 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b9647e4742..5534de89c9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -156,7 +156,7 @@ class phpbb_functional_test_case extends phpbb_test_case new phpbb_filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', - '.' . $php_ext, + $php_ext, $this->get_cache_driver() ); -- cgit v1.2.1 From 2fa5f9591e06e82ca76e7ac7e653d8ad4494eb67 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 25 Apr 2013 22:52:40 +0530 Subject: [ticket/10325] add logout function in functional_test_case PHPBB3-10325 --- tests/test_framework/phpbb_functional_test_case.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 5534de89c9..dae37f336d 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -425,6 +425,17 @@ class phpbb_functional_test_case extends phpbb_test_case } } + protected function logout() + { + $this->add_lang('ucp'); + + $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assert_response_success(); + $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); + unset($this->sid); + + } + /** * Login to the ACP * You must run login() before calling this. -- cgit v1.2.1 From 60e32728393d4258f92f7893f8275889278a995f Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Wed, 1 May 2013 14:09:08 -0500 Subject: [ticket/11415] Remove migrator dependency from extension manager PHPBB3-11415 --- tests/test_framework/phpbb_functional_test_case.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 5534de89c9..a11c0f72ca 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -148,8 +148,11 @@ class phpbb_functional_test_case extends phpbb_test_case self::$config['table_prefix'], array() ); + $container = new phpbb_mock_container_builder(); + $container->set('migrator', $migrator); + $extension_manager = new phpbb_extension_manager( - new phpbb_mock_container_builder(), + $container, $db, $config, $migrator, -- cgit v1.2.1 From 1b34ddb330d1a666185947ec2325732466f9ce4e Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 3 May 2013 09:02:50 -0500 Subject: [ticket/11415] Fix ext.manager constructor in tests PHPBB3-11415 --- tests/test_framework/phpbb_functional_test_case.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a11c0f72ca..0157706b12 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -155,7 +155,6 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - $migrator, new phpbb_filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', -- cgit v1.2.1 From 4f6b12ae1d4b9ac681efff0651a0007fed6942b6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 30 May 2013 10:49:13 +0200 Subject: [ticket/develop/11568] Remove php extension parameter We don't support that in 3.1 anymore PHPBB3-11568 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 42d38255f7..e5e08df5fc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -288,7 +288,7 @@ class phpbb_functional_test_case extends phpbb_test_case $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'], array(), true, true)); + 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); -- cgit v1.2.1 From 71deb4dde7f0d92905c13b79c92b5ccc6beeb3c3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 4 Jun 2013 17:16:22 +0200 Subject: [ticket/11538] Add admin as admins leader and moderator in memberlist_test Removing the admin user from the admin and moderator group in memberlist_test potentially breaks other tests, i.e. the ucp groups test. PHPBB3-11538 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 660234f3ed..923cb16d37 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -361,7 +361,7 @@ class phpbb_functional_test_case extends phpbb_test_case return group_user_del($group_id, false, $usernames, $group_name); } - protected function add_user_group($group_name, $usernames) + protected function add_user_group($group_name, $usernames, $default = false, $leader = false) { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; @@ -400,7 +400,7 @@ class phpbb_functional_test_case extends phpbb_test_case $group_id = (int) $db->sql_fetchfield('group_id'); $db->sql_freeresult($result); - return group_user_add($group_id, false, $usernames, $group_name); + return group_user_add($group_id, false, $usernames, $group_name, $default, $leader); } protected function login($username = 'admin') -- cgit v1.2.1 From 1f989c6be774d88ffff8a8d5ac1da58f442f6174 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Thu, 27 Jun 2013 00:57:34 +0530 Subject: [ticket/9341] Move create_topic and post into functional test case create_topic and create_post are moved into functional test case so that they can be used by other tests as well PHPBB3-9341 --- .../test_framework/phpbb_functional_test_case.php | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 97fe147d8e..ece42c5fff 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -703,4 +703,105 @@ class phpbb_functional_test_case extends phpbb_test_case return $result; } + + /** + * Creates a topic + * + * Be sure to login before creating + * + * @param int $forum_id + * @param string $subject + * @param string $message + * @param array $additional_form_data Any additional form data to be sent in the request + * @return array post_id, topic_id + */ + public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) + { + $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; + + $form_data = array_merge(array( + 'subject' => $subject, + 'message' => $message, + 'post' => true, + ), $additional_form_data); + + return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + } + + /** + * Creates a post + * + * Be sure to login before creating + * + * @param int $forum_id + * @param string $subject + * @param string $message + * @param array $additional_form_data Any additional form data to be sent in the request + * @return array post_id, topic_id + */ + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) + { + $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; + + $form_data = array_merge(array( + 'subject' => $subject, + 'message' => $message, + 'post' => true, + ), $additional_form_data); + + return self::submit_post($posting_url, 'POST_REPLY', $form_data); + } + + /** + * Helper for submitting posts + * + * @param string $posting_url + * @param string $posting_contains + * @param array $form_data + * @return array post_id, topic_id + */ + protected function submit_post($posting_url, $posting_contains, $form_data) + { + $this->add_lang('posting'); + + $crawler = self::request('GET', $posting_url); + $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); + + $hidden_fields = array( + $crawler->filter('[type="hidden"]')->each(function ($node, $i) { + return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value')); + }), + ); + + foreach ($hidden_fields as $fields) + { + foreach($fields as $field) + { + $form_data[$field['name']] = $field['value']; + } + } + + // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) + // is not at least 2 seconds before submission, cancel the form + $form_data['lastclick'] = 0; + + // 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) + // Instead, I send it as a request with the submit button "post" set to true. + $crawler = self::request('POST', $posting_url, $form_data); + $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + + $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); + + $matches = $topic_id = $post_id = false; + preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches); + + $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0; + $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0; + + return array( + 'topic_id' => $topic_id, + 'post_id' => $post_id, + ); + } } -- cgit v1.2.1 From 0297b88aafd3ef12217965f2879af9f9fd12d91f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 12 Jul 2013 15:41:52 -0400 Subject: [ticket/9657] Add unit tests for softdeleting and moving posts/topics PHPBB3-9657 --- .../test_framework/phpbb_functional_test_case.php | 48 ++++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7e2e750e30..d2d16a4bda 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -767,6 +767,7 @@ class phpbb_functional_test_case extends phpbb_test_case * Be sure to login before creating * * @param int $forum_id + * @param int $topic_id * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request @@ -823,18 +824,47 @@ class phpbb_functional_test_case extends phpbb_test_case // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); - $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); - $matches = $topic_id = $post_id = false; - preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches); - - $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0; - $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0; - return array( - 'topic_id' => $topic_id, - 'post_id' => $post_id, + 'topic_id' => $this->get_parameter_from_link($url, 't'), + 'post_id' => $this->get_parameter_from_link($url, 'p'), ); } + + /* + * Returns the requested parameter from a URL + * + * @param string $url + * @param string $parameter + * @return string Value of the parameter in the URL, null if not set + */ + public function get_parameter_from_link($url, $parameter) + { + if (strpos($url, '?') === false) + { + return null; + } + + $url_parts = explode('?', $url); + if (isset($url_parts[1])) + { + $url_parameters = $url_parts[1]; + if (strpos($url_parameters, '#') !== false) + { + $url_parameters = explode('#', $url_parameters); + $url_parameters = $url_parameters[0]; + } + + foreach (explode('&', $url_parameters) as $url_param) + { + list($param, $value) = explode('=', $url_param); + if ($param == $parameter) + { + return $value; + } + } + } + return null; + } } -- cgit v1.2.1 From 7d0c1d02ca428305f3cd4b57249c90d0d86bc3ae Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 12:02:49 -0400 Subject: [ticket/11684] Remove useless confirmation page after login and admin login PHPBB3-11684 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f27e339bb7..2f5de76c11 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -610,7 +610,7 @@ class phpbb_functional_test_case extends phpbb_test_case $form = $crawler->selectButton($this->lang('LOGIN'))->form(); $crawler = self::submit($form, array('username' => $username, 'password' => $username . $username)); - $this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text()); + $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); $cookies = self::$cookieJar->all(); @@ -659,7 +659,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (strpos($field, 'password_') === 0) { $crawler = self::submit($form, array('username' => $username, $field => $username . $username)); - $this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text()); + $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); $cookies = self::$cookieJar->all(); -- cgit v1.2.1 From 8f95ef55a65cbf58e74840957cf9acfaf9e16d31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 13 Jul 2013 12:27:00 -0400 Subject: [ticket/11685] Remove logout confirmation page PHPBB3-11685 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f27e339bb7..4e0a978839 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -629,7 +629,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->add_lang('ucp'); $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); + $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); unset($this->sid); } -- cgit v1.2.1 From 8dc8ee205a30e4f1813f2b85e0176cc47100f47b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 23 Jul 2013 00:58:03 +0200 Subject: [ticket/11733] Add browse test for feed.php PHPBB3-11733 --- tests/test_framework/phpbb_functional_test_case.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ed307c3ce2..de3611c4cc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -747,6 +747,27 @@ class phpbb_functional_test_case extends phpbb_test_case self::assertStringStartsWith('getResponse()->getContent(); + self::assertNotContains('[phpBB Debug]', $content); + self::assertStringStartsWith(' Date: Fri, 26 Jul 2013 14:11:42 -0500 Subject: [ticket/11744] Fix functional test case that's failing PHPBB3-11744 --- tests/test_framework/phpbb_functional_test_case.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index de3611c4cc..d1dab4c148 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -533,12 +533,9 @@ class phpbb_functional_test_case extends phpbb_test_case $cache = new phpbb_mock_null_cache; $cache_driver = new phpbb_cache_driver_null(); - $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $phpbb_container - ->expects($this->any()) - ->method('get') - ->with('cache.driver') - ->will($this->returnValue($cache_driver)); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', $cache_driver); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); if (!function_exists('utf_clean_string')) { -- cgit v1.2.1 From f30b87519e9ead41525e1979cbce874e8a84e2b8 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 9 Sep 2013 17:28:56 -0500 Subject: [ticket/11832] Inject dependencies for phpbb_get_web_root_path (also moving) Function moved from phpbb_get_web_root_path to filesystem::get_web_root_path PHPBB3-11832 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ce748bb9cf..dedaf4cd68 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -203,7 +203,7 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - new phpbb_filesystem(), + new phpbb_filesystem($phpbb_root_path), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $php_ext, -- cgit v1.2.1 From 21624e79fc512fd86177080010bb7d26c71ce3cb Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 13 Sep 2013 10:04:35 -0500 Subject: [ticket/11832] Fix constructions of phpbb_filesystem PHPBB3-11832 --- tests/test_framework/phpbb_functional_test_case.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 579e225ed9..48c5649281 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -203,7 +203,12 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - new phpbb_filesystem($phpbb_root_path), + new phpbb_filesystem( + new phpbb_symfony_request( + new phpbb_mock_request() + ), + $phpbb_root_path + ), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $php_ext, -- cgit v1.2.1 From b4a374dc73eda55db1c67b87bd65a73f79411ef5 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 13 Sep 2013 10:58:03 -0500 Subject: [ticket/11832] Fix INCLUDE(JS/CSS) PHPBB3-11832 --- tests/test_framework/phpbb_functional_test_case.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 48c5649281..00f166d4fe 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -207,7 +207,8 @@ class phpbb_functional_test_case extends phpbb_test_case new phpbb_symfony_request( new phpbb_mock_request() ), - $phpbb_root_path + $phpbb_root_path, + $php_ext ), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- .../test_framework/phpbb_functional_test_case.php | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index ed307c3ce2..8929e93cfb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -150,7 +150,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; // so we don't reopen an open connection - if (!($this->db instanceof phpbb_db_driver)) + if (!($this->db instanceof \phpbb\db\driver\driver)) { $dbms = self::$config['dbms']; $this->db = new $dbms(); @@ -163,7 +163,7 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { - $this->cache = new phpbb_cache_driver_file; + $this->cache = new \phpbb\cache\driver\file; } return $this->cache; @@ -182,11 +182,11 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new phpbb_db_tools($db); + $db_tools = new \phpbb\db\tools($db); - $migrator = new phpbb_db_migrator( + $migrator = new \phpbb\db\migrator( $config, $db, $db_tools, @@ -199,11 +199,11 @@ class phpbb_functional_test_case extends phpbb_test_case $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - $extension_manager = new phpbb_extension_manager( + $extension_manager = new \phpbb\extension\manager( $container, $db, $config, - new phpbb_filesystem(), + new \phpbb\filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $php_ext, @@ -471,7 +471,7 @@ class phpbb_functional_test_case extends phpbb_test_case // Required by unique_id global $config; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; @@ -484,7 +484,7 @@ class phpbb_functional_test_case extends phpbb_test_case } $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) @@ -521,18 +521,18 @@ class phpbb_functional_test_case extends phpbb_test_case { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) @@ -563,18 +563,18 @@ class phpbb_functional_test_case extends phpbb_test_case { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) -- cgit v1.2.1 From ccbb070652a188fd3b2354781d57af8847015eee Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 16 Sep 2013 04:19:52 +0200 Subject: [ticket/11700] The driver is namespaced now, so properly replace it PHPBB3-11700 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d5d3258b1b..8b59521dc0 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -265,7 +265,7 @@ class phpbb_functional_test_case extends phpbb_test_case 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']), + 'dbms' => str_replace('phpbb\db\driver\\', '', self::$config['dbms']), 'dbhost' => self::$config['dbhost'], 'dbport' => self::$config['dbport'], 'dbname' => self::$config['dbname'], -- cgit v1.2.1 From ee1c15fe7e1d0c823026d2b63ceab276eb878ab0 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 16 Sep 2013 04:47:39 +0200 Subject: [ticket/11700] Fix another case of non-namespaced classnames PHPBB3-11700 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 8b59521dc0..3b13d35f97 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -532,7 +532,7 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', $cache_driver); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); -- cgit v1.2.1 From 9d8ac2b0ceb24dd14df61d083505941afb1b52c4 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 17 Sep 2013 17:12:41 +0200 Subject: [ticket/11700] Fix unit tests after develop merge PHPBB3-11700 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f8ec125481..f87b3538a1 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -204,7 +204,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db, $config, new phpbb\filesystem( - new phpbb\symfony\request( + new phpbb\symfony_request( new phpbb_mock_request() ), $phpbb_root_path, -- cgit v1.2.1 From 7525c49d454e1ff4a156709ea9ecc1dc0b28dd6e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 26 Sep 2013 15:34:44 +0200 Subject: [ticket/11852] Split filesystem and path_helper into 2 classes PHPBB3-11852 --- tests/test_framework/phpbb_functional_test_case.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f87b3538a1..a0d186e0f2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -203,13 +203,7 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - new phpbb\filesystem( - new phpbb\symfony_request( - new phpbb_mock_request() - ), - $phpbb_root_path, - $php_ext - ), + new phpbb\filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $php_ext, -- cgit v1.2.1 From e7e11112b17d6a8d4811d28376f1cc545243c08c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Oct 2013 17:24:11 +0200 Subject: [feature/passwords] Fix tests after changes to phpBB hashing functions PHPBB3-11610 --- .../test_framework/phpbb_functional_test_case.php | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f87b3538a1..065227b050 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -509,6 +509,7 @@ class phpbb_functional_test_case extends phpbb_test_case set_config(null, null, null, $config); set_config_count(null, null, null, $config); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $passwords_manager = $this->get_passwords_manager(); $user_row = array( 'username' => $username, @@ -518,7 +519,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'user_lang' => 'en', 'user_timezone' => 0, 'user_dateformat' => '', - 'user_password' => phpbb_hash($username . $username), + 'user_password' => $passwords_manager->hash($username . $username), ); return user_add($user_row); } @@ -995,4 +996,34 @@ class phpbb_functional_test_case extends phpbb_test_case } return null; } + + /** + * Return a passwords manager instance + * + * @return phpbb\passwords\manager + */ + public function get_passwords_manager() + { + // Prepare dependencies for manager and driver + $config = new phpbb\config\config(array()); + $driver_helper = new phpbb\passwords\driver\helper($config); + + $passwords_drivers = array( + 'passwords.driver.bcrypt' => new phpbb\passwords\driver\bcrypt($config, $driver_helper), + 'passwords.driver.bcrypt_2y' => new phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), + 'passwords.driver.salted_md5' => new phpbb\passwords\driver\salted_md5($config, $driver_helper), + 'passwords.driver.phpass' => new phpbb\passwords\driver\phpass($config, $driver_helper), + ); + + foreach ($passwords_drivers as $key => $driver) + { + $driver->set_name($key); + } + + $passwords_helper = new phpbb\passwords\helper; + // Set up passwords manager + $manager = new phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, 'passwords.driver.bcrypt_2y'); + + return $manager; + } } -- cgit v1.2.1 From 93531e7fb0df7d9cd2de04ca06aa9eb6a847a1c4 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 2 Oct 2013 23:45:32 +0200 Subject: [feature/passwords] Add prepending backslash to class namespaces PHPBB3-11610 --- tests/test_framework/phpbb_functional_test_case.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 065227b050..e078b09082 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1005,14 +1005,14 @@ class phpbb_functional_test_case extends phpbb_test_case public function get_passwords_manager() { // Prepare dependencies for manager and driver - $config = new phpbb\config\config(array()); - $driver_helper = new phpbb\passwords\driver\helper($config); + $config = new \phpbb\config\config(array()); + $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( - 'passwords.driver.bcrypt' => new phpbb\passwords\driver\bcrypt($config, $driver_helper), - 'passwords.driver.bcrypt_2y' => new phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), - 'passwords.driver.salted_md5' => new phpbb\passwords\driver\salted_md5($config, $driver_helper), - 'passwords.driver.phpass' => new phpbb\passwords\driver\phpass($config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), ); foreach ($passwords_drivers as $key => $driver) @@ -1020,9 +1020,9 @@ class phpbb_functional_test_case extends phpbb_test_case $driver->set_name($key); } - $passwords_helper = new phpbb\passwords\helper; + $passwords_helper = new \phpbb\passwords\helper; // Set up passwords manager - $manager = new phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, 'passwords.driver.bcrypt_2y'); + $manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, 'passwords.driver.bcrypt_2y'); return $manager; } -- cgit v1.2.1 From 5193b3279cfcd4f7f5d656ec806b87e971c5523f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 27 Oct 2013 14:18:02 +0100 Subject: [feature/passwords] Pass list of default types to passwords manager This list is in the order of how the driver types would be used. If a driver is not supported we will try the subsequent one. PHPBB3-11610 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f5e2e2c77d..76487077c2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1003,8 +1003,8 @@ class phpbb_functional_test_case extends phpbb_test_case $driver_helper = new \phpbb\passwords\driver\helper($config); $passwords_drivers = array( - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), ); @@ -1016,7 +1016,7 @@ class phpbb_functional_test_case extends phpbb_test_case $passwords_helper = new \phpbb\passwords\helper; // Set up passwords manager - $manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, 'passwords.driver.bcrypt_2y'); + $manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); return $manager; } -- cgit v1.2.1 From 29d3b08d5097ad90a5ed2d26bfc981898732dbab Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 9 Nov 2013 20:33:01 +0100 Subject: [ticket/11896] Add ability to define expected message after posting This change will add the ability to define the expected message after a topic or post has been submitted with the methods create_post() and create_topic(). If the expected message is not 'POST_STORED', we will not try to get the topic and post id. PHPBB3-11896 --- .../test_framework/phpbb_functional_test_case.php | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a0d186e0f2..64c8406adb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -880,7 +881,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + } } /** @@ -893,9 +901,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -905,7 +914,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_REPLY', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data); + } } /** @@ -914,9 +930,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $posting_url * @param string $posting_contains * @param array $form_data - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ - protected function submit_post($posting_url, $posting_contains, $form_data) + protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') { $this->add_lang('posting'); @@ -945,7 +962,12 @@ class phpbb_functional_test_case extends phpbb_test_case // 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. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + $this->assertContains($this->lang($expected), $crawler->filter('html')->text()); + + if ($expected !== 'POST_STORED') + { + return; + } $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); return array( -- cgit v1.2.1 From 308329b5479d16e104c9eb7372222fee67ccdbf5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:09:49 +0100 Subject: [ticket/11896] Minor code improvements in phpbb_functional_test_case Use assertContainsLang() and get rid of unnecessary logic in create_post() and create_topic(). The docblocks were also slightly improved. PHPBB3-11896 --- .../test_framework/phpbb_functional_test_case.php | 28 ++++++---------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 64c8406adb..876e42a4c2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,10 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting + * @param string $expected Lang var of expected message after posting or null * @return array post_id, topic_id */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -881,14 +881,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - if ($expected !== '') - { - return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); - } - else - { - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); - } + return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); } /** @@ -901,10 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting + * @param string $expected Lang var of expected message after posting or null * @return array post_id, topic_id */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -914,14 +907,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - if ($expected !== '') - { - return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); - } - else - { - return self::submit_post($posting_url, 'POST_REPLY', $form_data); - } + return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); } /** @@ -962,7 +948,7 @@ class phpbb_functional_test_case extends phpbb_test_case // 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. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang($expected), $crawler->filter('html')->text()); + $this->assertContainsLang($expected, $crawler->filter('html')->text()); if ($expected !== 'POST_STORED') { -- cgit v1.2.1 From 7f10312bf21dba335a863fb1222db8b9ed64ef0e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Nov 2013 15:17:25 +0100 Subject: [ticket/11896] Correctly document return of null in docblocks Also got rid of previous incorrect comment in docblocks. PHPBB3-11896 --- tests/test_framework/phpbb_functional_test_case.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 876e42a4c2..eba5a2dfdf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,8 +868,8 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting or null - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { @@ -894,8 +894,8 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request - * @param string $expected Lang var of expected message after posting or null - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') { -- cgit v1.2.1 From 292961a2771c9237197b9770b23a2a14a981c329 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Feb 2014 14:09:09 +0100 Subject: [feature/passwords] Get rid of set_name/get_name methods for passwords drivers PHPBB3-11610 --- tests/test_framework/phpbb_functional_test_case.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b61fb25326..71d03746a9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1017,11 +1017,6 @@ class phpbb_functional_test_case extends phpbb_test_case 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper), ); - foreach ($passwords_drivers as $key => $driver) - { - $driver->set_name($key); - } - $passwords_helper = new \phpbb\passwords\helper; // Set up passwords manager $manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); -- cgit v1.2.1 From 38eb6b0e135293d51cc100937a6072b32e214c34 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 5 Feb 2014 09:57:36 -0600 Subject: [ticket/11880] Move get_schema_steps function to a migrator helper class PHPBB3-11880 --- tests/test_framework/phpbb_functional_test_case.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 71d03746a9..55f9cdb947 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -194,7 +194,8 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_root_path, $php_ext, self::$config['table_prefix'], - array() + array(), + new \phpbb\db\migration\helper() ); $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); -- cgit v1.2.1 From b5105363dbe59ccd42d8b9ff72c0ff0db202d543 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 10 Feb 2014 12:18:10 +0100 Subject: [ticket/12171] Add functionality to upload attachments to submit_post() method PHPBB3-12171 --- tests/test_framework/phpbb_functional_test_case.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 55f9cdb947..e40efdec03 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -928,6 +928,23 @@ class phpbb_functional_test_case extends phpbb_test_case $crawler = self::request('GET', $posting_url); $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); + if (!empty($form_data['upload_files'])) + { + for ($i = 0; $i < $form_data['upload_files']; $i++) + { + $file = array( + 'tmp_name' => __DIR__ . '/../functional/fixtures/files/valid.jpg', + 'name' => 'valid.jpg', + 'type' => 'image/jpeg', + 'size' => filesize(__DIR__ . '/../functional/fixtures/files/valid.jpg'), + 'error' => UPLOAD_ERR_OK, + ); + + $crawler = self::$client->request('POST', $posting_url, array('add_file' => $this->lang('ADD_FILE')), array('fileupload' => $file)); + } + unset($form_data['upload_files']); + } + $hidden_fields = array( $crawler->filter('[type="hidden"]')->each(function ($node, $i) { return array('name' => $node->attr('name'), 'value' => $node->attr('value')); -- cgit v1.2.1 From b5310e95652f009e98d720f0db92fd1cf2551fa8 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Fri, 8 Nov 2013 23:11:05 +0530 Subject: [ticket/11040] Add methods to delete post and topic in functional tests PHPBB3-11040 --- .../test_framework/phpbb_functional_test_case.php | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e40efdec03..85ff47a1f8 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -981,6 +981,50 @@ class phpbb_functional_test_case extends phpbb_test_case ); } + /** + * Deletes a topic + * + * Be sure to login before creating + * + * @param int $topic_id + * @return null + */ + public function delete_topic($topic_id) + { + $crawler = self::request('GET', "viewtopic.php?t={$topic_id}&sid={$this->sid}"); + + $this->add_lang('posting'); + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('delete_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); + } + + /** + * Deletes a post + * + * Be sure to login before creating + * + * @param int $forum_id + * @param int $topic_id + * @return null + */ + public function delete_post($forum_id, $post_id) + { + $this->add_lang('posting'); + $crawler = self::request('GET', "posting.php?mode=delete&f={$forum_id}&p={$post_id}&sid={$this->sid}"); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_DELETED', $crawler->text()); + } + /** * Returns the requested parameter from a URL * -- cgit v1.2.1 From 799c5759906245ee930d375ca58c041246f7f348 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 9 Mar 2014 23:26:08 +0530 Subject: [ticket/11040] Use hard delete in delete_topic PHPBB3-11040 --- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 85ff47a1f8..937192c58f 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1001,6 +1001,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->add_lang('mcp'); $form = $crawler->selectButton('Yes')->form(); + $form['delete_permanent'] = 1; $crawler = self::submit($form); $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); } @@ -1021,6 +1022,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $form = $crawler->selectButton('Yes')->form(); + $form['delete_permanent'] = 1; $crawler = self::submit($form); $this->assertContainsLang('POST_DELETED', $crawler->text()); } -- cgit v1.2.1 From 86a88751a843a800020aad5405a531c3753512e1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 13 Mar 2014 10:52:10 +0100 Subject: [ticket/12267] Replace $php_ext with $phpEx PHPBB3-12267 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 6a04dac691..411d97b590 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -192,7 +192,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db_tools, self::$config['table_prefix'] . 'migrations', $phpbb_root_path, - $php_ext, + $phpEx, self::$config['table_prefix'], array(), new \phpbb\db\migration\helper() @@ -207,7 +207,7 @@ class phpbb_functional_test_case extends phpbb_test_case new phpbb\filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', - $php_ext, + $phpEx, $this->get_cache_driver() ); -- cgit v1.2.1 From 6361d382b30f96758020d226d12b19e4f649b643 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 11 Mar 2014 11:09:39 +0100 Subject: [ticket/11581] Add assertNotContainsLang() for functional test cases PHPBB3-11581 --- tests/test_framework/phpbb_functional_test_case.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e40efdec03..3b4da690b4 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -716,15 +716,27 @@ class phpbb_functional_test_case extends phpbb_test_case /** * assertContains for language strings * - * @param string $needle Search string - * @param string $haystack Search this - * @param string $message Optional failure message + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message */ public function assertContainsLang($needle, $haystack, $message = null) { $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); } + /** + * assertNotContains for language strings + * + * @param string $needle Search string + * @param string $haystack Search this + * @param string $message Optional failure message + */ + public function assertNotContainsLang($needle, $haystack, $message = null) + { + $this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + } + /* * Perform some basic assertions for the page * -- cgit v1.2.1 From f0d9a008d33d7a420c7bd9ad605cbf0a13f310c7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 18 Mar 2014 10:58:26 +0100 Subject: [ticket/10590] Fix functional tests are post confirm message removal PHPBB3-10590 --- tests/test_framework/phpbb_functional_test_case.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d6eb4a632f..c0e58d1104 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -893,9 +893,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -919,9 +919,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED') + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -941,9 +941,9 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $posting_contains * @param array $form_data * @param string $expected Lang var of expected message after posting - * @return array|null post_id, topic_id if message is 'POST_STORED' + * @return array|null post_id, topic_id if message is empty */ - protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') + protected function submit_post($posting_url, $posting_contains, $form_data, $expected = '') { $this->add_lang('posting'); @@ -989,13 +989,13 @@ class phpbb_functional_test_case extends phpbb_test_case // 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. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContainsLang($expected, $crawler->filter('html')->text()); - if ($expected !== 'POST_STORED') + if ($expected !== '') { - return; + $this->assertContainsLang($expected, $crawler->filter('html')->text()); + return null; } - $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); + $url = $crawler->selectLink($form_data['subject'])->link()->getUri(); return array( 'topic_id' => $this->get_parameter_from_link($url, 't'), -- cgit v1.2.1 From 11a9104b8a50cbc62cba0c242dee554b5209a327 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 17 Mar 2014 13:29:35 +0100 Subject: [ticket/12282] Use interface for type hinting PHPBB3-12282 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c0e58d1104..daa8b802b5 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -150,7 +150,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; // so we don't reopen an open connection - if (!($this->db instanceof \phpbb\db\driver\driver)) + if (!($this->db instanceof \phpbb\db\driver\driver_interface)) { $dbms = self::$config['dbms']; $this->db = new $dbms(); -- cgit v1.2.1 From 22090dc3a3280d043ff5e77212ee7229b5eb0d24 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 10 Apr 2014 23:02:37 +0200 Subject: [ticket/12386] Add DEBUG_EXTRA again and use it for container creation We are currently creating a new compiled container on every page load when having DEBUG enabled. However, one might only have that enabled to be presented with errors or for getting the page load stats. This change will add the DEBUG_EXTRA constant again. It will be used for choosing whether the compiled container should be created on every page load - when defined as true - or just once after the cache is cleared. PHPBB3-12386 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index daa8b802b5..1f372fff0c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -300,7 +300,7 @@ class phpbb_functional_test_case extends phpbb_test_case // because that step will create a config.php file if phpBB has the // permission to do so. We have to create the config file on our own // in order to get the DEBUG constants defined. - $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, true); + $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) { -- cgit v1.2.1 From 067ab9e8001285648e2c73858345aacf192c5971 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sat, 19 Apr 2014 09:42:45 -0700 Subject: [ticket/12405] Valid timezone and dateformat for create_user() in tests PHPBB3-12405 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 1f372fff0c..95ed334ed0 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -522,8 +522,8 @@ class phpbb_functional_test_case extends phpbb_test_case 'user_email' => 'nobody@example.com', 'user_type' => 0, 'user_lang' => 'en', - 'user_timezone' => 0, - 'user_dateformat' => '', + 'user_timezone' => 'UTC', + 'user_dateformat' => 'r', 'user_password' => $passwords_manager->hash($username . $username), ); return user_add($user_row); -- cgit v1.2.1 From 69865852a0789289f17e41eb5ed77a4f1ef5d45a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 24 Apr 2014 13:16:50 +0200 Subject: [ticket/12436] Data passed to sql_multi_insert is expected to be multi-dim. PHPBB3-12436 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 95ed334ed0..3759097319 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -422,7 +422,7 @@ class phpbb_functional_test_case extends phpbb_test_case } else { - $db->sql_multi_insert(STYLES_TABLE, array( + $db->sql_multi_insert(STYLES_TABLE, array(array( 'style_id' => $style_id, 'style_name' => $style_path, 'style_copyright' => '', @@ -431,7 +431,7 @@ class phpbb_functional_test_case extends phpbb_test_case 'bbcode_bitfield' => 'kNg=', 'style_parent_id' => $parent_style_id, 'style_parent_tree' => $parent_style_path, - )); + ))); } } -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- tests/test_framework/phpbb_functional_test_case.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 3759097319..0bfdfa57ac 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ use Symfony\Component\BrowserKit\CookieJar; -- cgit v1.2.1 From 7f00c38c50dbd6689f80afaf324c1ee81173d15a Mon Sep 17 00:00:00 2001 From: n-aleha Date: Mon, 12 May 2014 02:31:52 +0300 Subject: [ticket/11467] Add user object to extension manager for tests PHPBB3-11467 --- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 0bfdfa57ac..182ffaaaf7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -203,12 +203,14 @@ class phpbb_functional_test_case extends phpbb_test_case ); $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); + $user = new \phpbb\user(); $extension_manager = new \phpbb\extension\manager( $container, $db, $config, new phpbb\filesystem(), + $user, self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $phpEx, -- cgit v1.2.1 From 65884bf2bd754343410a5b3d8b4eea2343dc42e9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Jun 2014 18:57:05 +0200 Subject: [ticket/11711] Reduce size of tests and also test topic titles PHPBB3-11711 --- tests/test_framework/phpbb_functional_test_case.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 182ffaaaf7..c0127c50c9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -996,11 +996,16 @@ class phpbb_functional_test_case extends phpbb_test_case // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); - if ($expected !== '') + if ($expected !== '' && isset($this->lang[$expected])) { $this->assertContainsLang($expected, $crawler->filter('html')->text()); return null; } + else if ($expected !== '') + { + $this->assertContains($expected, $crawler->filter('html')->text()); + return null; + } $url = $crawler->selectLink($form_data['subject'])->link()->getUri(); return array( -- cgit v1.2.1 From 5ee7f20f4ee110c2ae0b122e9efbd4fabf669581 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Jun 2014 15:51:25 +0200 Subject: [ticket/11711] Improve coding and comments of character check PHPBB3-11711 --- tests/test_framework/phpbb_functional_test_case.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index c0127c50c9..f2c2c8f181 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -996,16 +996,19 @@ class phpbb_functional_test_case extends phpbb_test_case // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); - if ($expected !== '' && isset($this->lang[$expected])) + if ($expected !== '') { - $this->assertContainsLang($expected, $crawler->filter('html')->text()); - return null; - } - else if ($expected !== '') - { - $this->assertContains($expected, $crawler->filter('html')->text()); + if (isset($this->lang[$expected])) + { + $this->assertContainsLang($expected, $crawler->filter('html')->text()); + } + else + { + $this->assertContains($expected, $crawler->filter('html')->text()); + } return null; } + $url = $crawler->selectLink($form_data['subject'])->link()->getUri(); return array( -- cgit v1.2.1 From 997028a0ecf1df761363b061acf6ae220dd3479f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 May 2014 01:17:51 +0200 Subject: [ticket/12483] Allow to setup extensions before database and functional tests PHPBB3-12483 --- .../test_framework/phpbb_functional_test_case.php | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 182ffaaaf7..110c84927c 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -64,6 +64,14 @@ class phpbb_functional_test_case extends phpbb_test_case } } + /** + * @return array List of extensions that should be set up + */ + static protected function setup_extensions() + { + return array(); + } + public function setUp() { parent::setUp(); @@ -81,6 +89,23 @@ class phpbb_functional_test_case extends phpbb_test_case $this->lang = array(); $this->add_lang('common'); $this->purge_cache(); + + $db = $this->get_db(); + + foreach (static::setup_extensions() as $extension) + { + $sql = 'SELECT ext_active + FROM ' . EXT_TABLE . " + WHERE ext_name = '" . $db->sql_escape($extension). "'"; + $result = $db->sql_query($sql); + $status = (bool) $db->sql_fetchfield('ext_active'); + $db->sql_freeresult($result); + + if (!$status) + { + $this->install_ext($extension); + } + } } /** @@ -358,6 +383,23 @@ class phpbb_functional_test_case extends phpbb_test_case copy($config_file, $config_file_test); } + public function install_ext($extension) + { + $this->login(); + $this->admin_login(); + + $ext_path = str_replace('/', '%2F', $extension); + + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); + $this->assertGreaterThan(0, $crawler->filter('div.errorbox')->count()); + + $form = $crawler->selectButton('Enable')->form(); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('div.successbox')->count()); + + $this->logout(); + } + static private function recreate_database($config) { $db_conn_mgr = new phpbb_database_test_connection_manager($config); @@ -714,6 +756,30 @@ class phpbb_functional_test_case extends phpbb_test_case $this->lang = array_merge($this->lang, $lang); } + protected function add_lang_ext($ext_name, $lang_file) + { + if (is_array($lang_file)) + { + foreach ($lang_file as $file) + { + $this->add_lang_ext($ext_name, $file); + } + + return; + } + + $lang_path = __DIR__ . "/../../phpBB/ext/{$ext_name}/language/en/$lang_file.php"; + + $lang = array(); + + if (file_exists($lang_path)) + { + include($lang_path); + } + + $this->lang = array_merge($this->lang, $lang); + } + protected function lang() { $args = func_get_args(); -- cgit v1.2.1 From 7b0b6a99c031bdcbf2bfdf0d7ebbf1784ecbbd59 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 4 May 2014 23:15:56 +0200 Subject: [ticket/12483] Close database connection when tearDown() is called Similar to phpbb_database_test_case::tearDown() PHPBB3-12483 --- tests/test_framework/phpbb_functional_test_case.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 110c84927c..36d577aed7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -108,6 +108,17 @@ class phpbb_functional_test_case extends phpbb_test_case } } + protected function tearDown() + { + parent::tearDown(); + + if ($this->db instanceof \phpbb\db\driver\driver_interface) + { + // Close the database connections again this test + $this->db->sql_close(); + } + } + /** * Perform a request to page * -- cgit v1.2.1 From 916db1a0b156a953b1917d74924f750864df4701 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 10 Jun 2014 20:04:03 +0200 Subject: [ticket/12483] Fix selectors for installing extensions in functional tests PHPBB3-12483 --- tests/test_framework/phpbb_functional_test_case.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 36d577aed7..e4504a5f8d 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -402,11 +402,12 @@ class phpbb_functional_test_case extends phpbb_test_case $ext_path = str_replace('/', '%2F', $extension); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); - $this->assertGreaterThan(0, $crawler->filter('div.errorbox')->count()); + $this->assertGreaterThan(0, $crawler->filter('.submit-buttons')->count()); $form = $crawler->selectButton('Enable')->form(); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('div.successbox')->count()); + $this->add_lang('acp/extensions'); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); $this->logout(); } -- cgit v1.2.1 From 01f350a61466f365eaa5d3bf9c4a69335d09d9df Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 14 Jun 2014 16:45:33 +0530 Subject: [ticket/11528] Refactor install_board() code into a new class PHPBB3-11528 --- .../test_framework/phpbb_functional_test_case.php | 150 +-------------------- 1 file changed, 1 insertion(+), 149 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index fde6a6a4ff..746dd34f70 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -12,13 +12,10 @@ */ use Symfony\Component\BrowserKit\CookieJar; -require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; - -class phpbb_functional_test_case extends phpbb_test_case +class phpbb_functional_test_case extends phpbb_mink_test_case { static protected $client; static protected $cookieJar; - static protected $root_url; protected $cache = null; protected $db = null; @@ -36,7 +33,6 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected $lang = array(); - static protected $config = array(); static protected $already_installed = false; static public function setUpBeforeClass() @@ -256,144 +252,6 @@ class phpbb_functional_test_case extends phpbb_test_case return $extension_manager; } - static protected 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); - } - } - - self::$cookieJar = new CookieJar; - 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, - ), - ))); - - // Reset the curl handle because it is 0 at this point and not a valid - // resource - self::$client->getClient()->getCurlMulti()->reset(true); - - $parseURL = parse_url(self::$config['phpbb_functional_url']); - - $crawler = self::request('GET', 'install/index.php?mode=install'); - self::assertContains('Welcome to Installation', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=requirements - $crawler = self::submit($form); - self::assertContains('Installation compatibility', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=database - $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'], - )); - - // install/index.php?mode=install&sub=database - $crawler = self::submit($form); - self::assertContains('Successful connection', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=administrator - $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', - )); - - // install/index.php?mode=install&sub=administrator - $crawler = self::submit($form); - self::assertContains('Tests passed', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // We have to skip install/index.php?mode=install&sub=config_file - // because that step will create a config.php file if phpBB has the - // permission to do so. We have to create the config file on 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."); - } - - // We also have to create a install lock that is normally created by - // the installer. The file will be removed by the final step of the - // installer. - $install_lock_file = $phpbb_root_path . 'cache/install_lock'; - $lock_created = file_put_contents($install_lock_file, '') !== false; - if (!$lock_created) - { - self::markTestSkipped("Could not create $lock_created file."); - } - @chmod($install_lock_file, 0666); - - // install/index.php?mode=install&sub=advanced - $form_data = $form->getValues(); - unset($form_data['submit']); - - $crawler = self::request('POST', 'install/index.php?mode=install&sub=advanced', $form_data); - 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, - 'smtp_delivery' => true, - 'smtp_host' => 'nxdomain.phpbb.com', - 'smtp_auth' => 'PLAIN', - 'smtp_user' => 'nxuser', - 'smtp_pass' => 'nxpass', - 'cookie_secure' => false, - 'force_server_vars' => false, - 'server_protocol' => $parseURL['scheme'] . '://', - 'server_name' => 'localhost', - 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80, - 'script_path' => $parseURL['path'], - )); - - // install/index.php?mode=install&sub=create_table - $crawler = self::submit($form); - self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text()); - self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text()); - $form = $crawler->selectButton('submit')->form(); - - // install/index.php?mode=install&sub=final - $crawler = self::submit($form); - self::assertContains('You have successfully installed', $crawler->text()); - - copy($config_file, $config_file_test); - } - public function install_ext($extension) { $this->login(); @@ -412,12 +270,6 @@ class phpbb_functional_test_case extends phpbb_test_case $this->logout(); } - static private function recreate_database($config) - { - $db_conn_mgr = new phpbb_database_test_connection_manager($config); - $db_conn_mgr->recreate_db(); - } - /** * Creates a new style * -- cgit v1.2.1 From 648cbbd9a0f5c01795d36293f43274a7a33d391e Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 14 Jun 2014 14:27:57 +0530 Subject: [ticket/11528] Instantiate $client, $driver from functional test case Make mink test case an abstract class, instantiate $driver, $client from its child class i.e. functional test case. PHPBB3-11528 --- .../test_framework/phpbb_functional_test_case.php | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 746dd34f70..6ce5d92ee1 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,7 +14,6 @@ use Symfony\Component\BrowserKit\CookieJar; class phpbb_functional_test_case extends phpbb_mink_test_case { - static protected $client; static protected $cookieJar; protected $cache = null; @@ -42,6 +41,24 @@ class phpbb_functional_test_case extends phpbb_mink_test_case self::$config = phpbb_test_case_helpers::get_test_config(); self::$root_url = self::$config['phpbb_functional_url']; + self::$cookieJar = new CookieJar; + self::$client = new \Behat\Mink\Driver\Goutte\Client(array(), null, self::$cookieJar); + + $client_options = array( + Guzzle\Http\Client::DISABLE_REDIRECTS => true, + 'curl.options' => array( + CURLOPT_TIMEOUT => 120, + ), + ); + + self::$client->setClient(new Guzzle\Http\Client('', $client_options)); + + // Reset the curl handle because it is 0 at this point and not a valid + // resource + self::$client->getClient()->getCurlMulti()->reset(true); + + self::$driver = new \Behat\Mink\Driver\GoutteDriver(self::$client); + // 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 @@ -74,12 +91,6 @@ class phpbb_functional_test_case extends phpbb_mink_test_case $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 $this->lang = array(); @@ -113,6 +124,8 @@ class phpbb_functional_test_case extends phpbb_mink_test_case // Close the database connections again this test $this->db->sql_close(); } + + self::$cookieJar->clear(); } /** -- cgit v1.2.1 From c26fa6a15b716dcf43d063b41ec5d646fc115e19 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 14 Jun 2014 17:46:35 +0530 Subject: [ticket/11528] Move parent::tearDown() to end of tearDown() PHPBB3-11528 --- tests/test_framework/phpbb_functional_test_case.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 6ce5d92ee1..5e1cf9b31f 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -117,8 +117,6 @@ class phpbb_functional_test_case extends phpbb_mink_test_case protected function tearDown() { - parent::tearDown(); - if ($this->db instanceof \phpbb\db\driver\driver_interface) { // Close the database connections again this test @@ -126,6 +124,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case } self::$cookieJar->clear(); + parent::tearDown(); } /** -- cgit v1.2.1 From 2d1a9980034ef40514fc310a065aa442c33b89a8 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 14 Jun 2014 18:59:38 +0530 Subject: [ticket/11528] Use 'use' keyword to import classes to current scope PHPBB3-11528 --- tests/test_framework/phpbb_functional_test_case.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 5e1cf9b31f..2f0b0a3db0 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -11,6 +11,8 @@ * */ use Symfony\Component\BrowserKit\CookieJar; +use \Behat\Mink\Driver\Goutte\Client; +use \Behat\Mink\Driver\GoutteDriver; class phpbb_functional_test_case extends phpbb_mink_test_case { @@ -42,7 +44,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case self::$root_url = self::$config['phpbb_functional_url']; self::$cookieJar = new CookieJar; - self::$client = new \Behat\Mink\Driver\Goutte\Client(array(), null, self::$cookieJar); + self::$client = new Client(array(), null, self::$cookieJar); $client_options = array( Guzzle\Http\Client::DISABLE_REDIRECTS => true, @@ -57,7 +59,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case // resource self::$client->getClient()->getCurlMulti()->reset(true); - self::$driver = new \Behat\Mink\Driver\GoutteDriver(self::$client); + self::$driver = new GoutteDriver(self::$client); // Important: this is used both for installation and by // test cases for querying the tables. -- cgit v1.2.1 From a92c1d1ec0a660f5e2758a9865592d7f7ed0b76e Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 18 Jun 2014 15:29:46 +0530 Subject: [ticket/11528] Fix spaces and slashes as per guidelines PHPBB3-11528 --- tests/test_framework/phpbb_functional_test_case.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 2f0b0a3db0..eef30fbcc7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -11,8 +11,8 @@ * */ use Symfony\Component\BrowserKit\CookieJar; -use \Behat\Mink\Driver\Goutte\Client; -use \Behat\Mink\Driver\GoutteDriver; +use Behat\Mink\Driver\Goutte\Client; +use Behat\Mink\Driver\GoutteDriver; class phpbb_functional_test_case extends phpbb_mink_test_case { -- cgit v1.2.1 From d95c97c3b4bd3f6efbdf3b457e6f9377fed640d3 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 14 Jun 2014 15:36:36 -0700 Subject: [ticket/12013] Fix functional tests and sniffer issue. PHPBB3-12013 --- .../test_framework/phpbb_functional_test_case.php | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index eef30fbcc7..07ef826abf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -971,12 +971,8 @@ class phpbb_functional_test_case extends phpbb_mink_test_case */ public function delete_topic($topic_id) { - $crawler = self::request('GET', "viewtopic.php?t={$topic_id}&sid={$this->sid}"); - $this->add_lang('posting'); - $form = $crawler->selectButton('Go')->eq(1)->form(); - $form['action']->select('delete_topic'); - $crawler = self::submit($form); + $crawler = $this->get_quickmod_page($topic_id, 'DELETE_TOPIC'); $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $this->add_lang('mcp'); @@ -1067,4 +1063,25 @@ class phpbb_functional_test_case extends phpbb_mink_test_case return $manager; } + + /** + * Get quickmod page + * + * @param int $topic_id + * @param string $action Language key for the quickmod action + * @param Symfony\Component\DomCrawler\Crawler Optional crawler object to use instead of creating new one. + * @return Symfony\Component\DomCrawler\Crawler + */ + public function get_quickmod_page($topic_id, $action, $crawler = false) + { + $this->add_lang('viewtopic'); + + if ($crawler === false) + { + $crawler = self::request('GET', "viewtopic.php?t={$topic_id}&sid={$this->sid}"); + } + $link = $crawler->filter('#quickmod')->selectLink($this->lang($action))->link()->getUri(); + + return self::request('GET', substr($link, strpos($link, 'mcp.'))); + } } -- cgit v1.2.1 From 67d19920c43ed037cc64029c4fc3468a2168f2e7 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 30 Jul 2014 23:20:43 +0200 Subject: [ticket/11480] Fix unit tests PHPBB3-11480 --- tests/test_framework/phpbb_functional_test_case.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index caaedb7de0..9bb4d69bf4 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -899,8 +899,6 @@ class phpbb_functional_test_case extends phpbb_mink_test_case $crawler = $this->submit_message($posting_url, $posting_contains, $form_data); - $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); - if ($expected !== '') { if (isset($this->lang[$expected])) -- cgit v1.2.1 From dd8adb5d6eca9b1bc359ff3a0ff72b0531dfb9cd Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 9 Aug 2014 17:18:33 +0200 Subject: [ticket/11528] Revert Mink changes PHPBB3-11528 --- .../test_framework/phpbb_functional_test_case.php | 182 ++++++++++++++++++--- 1 file changed, 158 insertions(+), 24 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9bb4d69bf4..80e6293ff9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -11,12 +11,14 @@ * */ use Symfony\Component\BrowserKit\CookieJar; -use Behat\Mink\Driver\Goutte\Client; -use Behat\Mink\Driver\GoutteDriver; -class phpbb_functional_test_case extends phpbb_mink_test_case +require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; + +class phpbb_functional_test_case extends phpbb_test_case { + static protected $client; static protected $cookieJar; + static protected $root_url; protected $cache = null; protected $db = null; @@ -34,6 +36,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case */ protected $lang = array(); + static protected $config = array(); static protected $already_installed = false; static public function setUpBeforeClass() @@ -43,24 +46,6 @@ class phpbb_functional_test_case extends phpbb_mink_test_case self::$config = phpbb_test_case_helpers::get_test_config(); self::$root_url = self::$config['phpbb_functional_url']; - self::$cookieJar = new CookieJar; - self::$client = new Client(array(), null, self::$cookieJar); - - $client_options = array( - Guzzle\Http\Client::DISABLE_REDIRECTS => true, - 'curl.options' => array( - CURLOPT_TIMEOUT => 120, - ), - ); - - self::$client->setClient(new Guzzle\Http\Client('', $client_options)); - - // Reset the curl handle because it is 0 at this point and not a valid - // resource - self::$client->getClient()->getCurlMulti()->reset(true); - - self::$driver = new GoutteDriver(self::$client); - // 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 @@ -93,6 +78,12 @@ class phpbb_functional_test_case extends phpbb_mink_test_case $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 $this->lang = array(); @@ -119,14 +110,13 @@ class phpbb_functional_test_case extends phpbb_mink_test_case protected function tearDown() { + parent::tearDown(); + if ($this->db instanceof \phpbb\db\driver\driver_interface) { // Close the database connections again this test $this->db->sql_close(); } - - self::$cookieJar->clear(); - parent::tearDown(); } /** @@ -266,6 +256,144 @@ class phpbb_functional_test_case extends phpbb_mink_test_case return $extension_manager; } + static protected 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); + } + } + + self::$cookieJar = new CookieJar; + 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, + ), + ))); + + // Reset the curl handle because it is 0 at this point and not a valid + // resource + self::$client->getClient()->getCurlMulti()->reset(true); + + $parseURL = parse_url(self::$config['phpbb_functional_url']); + + $crawler = self::request('GET', 'install/index.php?mode=install'); + self::assertContains('Welcome to Installation', $crawler->filter('#main')->text()); + $form = $crawler->selectButton('submit')->form(); + + // install/index.php?mode=install&sub=requirements + $crawler = self::submit($form); + self::assertContains('Installation compatibility', $crawler->filter('#main')->text()); + $form = $crawler->selectButton('submit')->form(); + + // install/index.php?mode=install&sub=database + $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'], + )); + + // install/index.php?mode=install&sub=database + $crawler = self::submit($form); + self::assertContains('Successful connection', $crawler->filter('#main')->text()); + $form = $crawler->selectButton('submit')->form(); + + // install/index.php?mode=install&sub=administrator + $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', + )); + + // install/index.php?mode=install&sub=administrator + $crawler = self::submit($form); + self::assertContains('Tests passed', $crawler->filter('#main')->text()); + $form = $crawler->selectButton('submit')->form(); + + // We have to skip install/index.php?mode=install&sub=config_file + // because that step will create a config.php file if phpBB has the + // permission to do so. We have to create the config file on 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."); + } + + // We also have to create a install lock that is normally created by + // the installer. The file will be removed by the final step of the + // installer. + $install_lock_file = $phpbb_root_path . 'cache/install_lock'; + $lock_created = file_put_contents($install_lock_file, '') !== false; + if (!$lock_created) + { + self::markTestSkipped("Could not create $lock_created file."); + } + @chmod($install_lock_file, 0666); + + // install/index.php?mode=install&sub=advanced + $form_data = $form->getValues(); + unset($form_data['submit']); + + $crawler = self::request('POST', 'install/index.php?mode=install&sub=advanced', $form_data); + 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, + 'smtp_delivery' => true, + 'smtp_host' => 'nxdomain.phpbb.com', + 'smtp_auth' => 'PLAIN', + 'smtp_user' => 'nxuser', + 'smtp_pass' => 'nxpass', + 'cookie_secure' => false, + 'force_server_vars' => false, + 'server_protocol' => $parseURL['scheme'] . '://', + 'server_name' => 'localhost', + 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80, + 'script_path' => $parseURL['path'], + )); + + // install/index.php?mode=install&sub=create_table + $crawler = self::submit($form); + self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text()); + self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text()); + $form = $crawler->selectButton('submit')->form(); + + // install/index.php?mode=install&sub=final + $crawler = self::submit($form); + self::assertContains('You have successfully installed', $crawler->text()); + + copy($config_file, $config_file_test); + } + public function install_ext($extension) { $this->login(); @@ -284,6 +412,12 @@ class phpbb_functional_test_case extends phpbb_mink_test_case $this->logout(); } + static private function recreate_database($config) + { + $db_conn_mgr = new phpbb_database_test_connection_manager($config); + $db_conn_mgr->recreate_db(); + } + /** * Creates a new style * -- cgit v1.2.1 From 8d99b4afe1557a6ec0e760c4876bb06a3b9991d3 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 10 Aug 2014 13:40:27 +0200 Subject: [ticket/12932] Fix tests and calls to create_datetime PHPBB3-12932 --- tests/test_framework/phpbb_functional_test_case.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 80e6293ff9..6000e0d316 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -239,7 +239,7 @@ class phpbb_functional_test_case extends phpbb_test_case ); $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - $user = new \phpbb\user(); + $user = new \phpbb\user('\phpbb\datetime'); $extension_manager = new \phpbb\extension\manager( $container, @@ -598,7 +598,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('\phpbb\user'); + $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); @@ -637,7 +637,7 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('\phpbb\user'); + $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); $auth = $this->getMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); -- cgit v1.2.1 From 0244a9b6a44d79d9db38b73994c2bfc375731378 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 10 Aug 2014 13:49:42 +0200 Subject: [ticket/12950] Force the installer to use language=en PHPBB3-12950 --- tests/test_framework/phpbb_functional_test_case.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 80e6293ff9..c131754d23 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -294,7 +294,7 @@ class phpbb_functional_test_case extends phpbb_test_case $parseURL = parse_url(self::$config['phpbb_functional_url']); - $crawler = self::request('GET', 'install/index.php?mode=install'); + $crawler = self::request('GET', 'install/index.php?mode=install&language=en'); self::assertContains('Welcome to Installation', $crawler->filter('#main')->text()); $form = $crawler->selectButton('submit')->form(); -- cgit v1.2.1 From 0dcb874c0987156b0c4bb2ef4e935ff6b6f2fd46 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 25 Oct 2014 16:16:25 -0700 Subject: [ticket/13207] Add notification manager mock to user_add method in tests PHPBB3-13207 --- tests/test_framework/phpbb_functional_test_case.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 49cc72363e..840ff981cb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -556,12 +556,10 @@ class phpbb_functional_test_case extends phpbb_test_case $cache = new phpbb_mock_null_cache; $cache_driver = new \phpbb\cache\driver\null(); - $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $phpbb_container - ->expects($this->any()) - ->method('get') - ->with('cache.driver') - ->will($this->returnValue($cache_driver)); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', $cache_driver); + $phpbb_notifications = new phpbb_mock_notification_manager(); + $phpbb_container->set('notification_manager', $phpbb_notifications); if (!function_exists('utf_clean_string')) { -- cgit v1.2.1 From e42202e794e970342f4fd31c1436c7f061656826 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Oct 2014 13:08:53 +0100 Subject: [ticket/13241] Sleep for 1 second when posting twice in the same second PHPBB3-13241 --- tests/test_framework/phpbb_functional_test_case.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 840ff981cb..51bae7a723 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -38,6 +38,7 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $config = array(); static protected $already_installed = false; + static protected $last_post_timestamp = 0; static public function setUpBeforeClass() { @@ -1098,6 +1099,12 @@ class phpbb_functional_test_case extends phpbb_test_case */ protected function submit_message($posting_url, $posting_contains, $form_data) { + if (time() == self::$last_post_timestamp) + { + // Travis is too fast, so we have to wait to not mix up the post/topic order + sleep(1); + } + self::$last_post_timestamp = time(); $crawler = self::request('GET', $posting_url); $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); -- cgit v1.2.1 From dab07283573689fcc6eb2c4e270ac37c3a573959 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 14 Jan 2015 12:32:47 +0100 Subject: [ticket/13489] Fix service configuration PHPBB3-13489 --- tests/test_framework/phpbb_functional_test_case.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 51bae7a723..6c045712ab 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -227,7 +227,9 @@ class phpbb_functional_test_case extends phpbb_test_case $db = $this->get_db(); $db_tools = new \phpbb\db\tools($db); + $container = new phpbb_mock_container_builder(); $migrator = new \phpbb\db\migrator( + $container, $config, $db, $db_tools, @@ -238,8 +240,8 @@ class phpbb_functional_test_case extends phpbb_test_case array(), new \phpbb\db\migration\helper() ); - $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); + $container->set('dispatcher', new phpbb_mock_event_dispatcher()); $user = new \phpbb\user('\phpbb\datetime'); $extension_manager = new \phpbb\extension\manager( -- cgit v1.2.1 From 8314ce6871c3e6f28c5bc374d1b73afc85f58b85 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 14 Feb 2015 15:59:29 +0100 Subject: [ticket/13612] Run meta refresh until extension is fully enabled PHPBB3-13612 --- tests/test_framework/phpbb_functional_test_case.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b6769f08d0..7479221263 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -410,7 +410,26 @@ class phpbb_functional_test_case extends phpbb_test_case $form = $crawler->selectButton('Enable')->form(); $crawler = self::submit($form); $this->add_lang('acp/extensions'); - $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); + + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + + // Wait for extension to be fully enabled + while (sizeof($meta_refresh)) + { + preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match); + $url = $match[1]; + $crawler = self::request('POST', $url); + $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); + } + + if (!empty($meta_refresh)) + { + $this->assertContainsLang('EXTENSIONS_ADMIN', $crawler->filter('.main > h1')->text()); + } + else + { + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); + } $this->logout(); } -- cgit v1.2.1 From 27cfda74fc5085bba8d5baf36450b3f52187dce9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 14 Feb 2015 23:32:17 +0100 Subject: [ticket/13612] Always display success message if extension was enabled An error will already be triggered if enable_step() is not successful. Redirecting for no obvious reason will just confuse users. PHPBB3-13612 --- tests/test_framework/phpbb_functional_test_case.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7479221263..844caa8f54 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -422,14 +422,7 @@ class phpbb_functional_test_case extends phpbb_test_case $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]'); } - if (!empty($meta_refresh)) - { - $this->assertContainsLang('EXTENSIONS_ADMIN', $crawler->filter('.main > h1')->text()); - } - else - { - $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); - } + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text()); $this->logout(); } -- cgit v1.2.1 From 2503723e2fff11c2a14bf62f6e261cebd9ffcf06 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 16 Jun 2015 11:10:22 +0200 Subject: [ticket/12952] Check obvious errors before status in functional tests This will change the output from just saying that the status did not match the expected one to actually showing any errors before complaining about a possible difference in the status code. PHPBB3-12952 --- tests/test_framework/phpbb_functional_test_case.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 844caa8f54..d403831626 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -854,15 +854,15 @@ class phpbb_functional_test_case extends phpbb_test_case */ 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::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith('getResponse()->getContent(); self::assertNotContains('[phpBB Debug]', $content); self::assertStringStartsWith(' Date: Thu, 7 Jan 2016 10:31:21 +0100 Subject: [ticket/14394] Only purge cache in functional tests if necessary PHPBB3-14394 --- tests/test_framework/phpbb_functional_test_case.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d403831626..04e8f71379 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -89,7 +89,6 @@ class phpbb_functional_test_case extends phpbb_test_case // that were added in other tests are gone $this->lang = array(); $this->add_lang('common'); - $this->purge_cache(); $db = $this->get_db(); -- cgit v1.2.1 From 99407755506324e7a9979d5b0614ab3966356876 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 25 Jan 2016 17:49:50 -0800 Subject: [ticket/14433] Purge cache setting up extension functional tests PHPBB3-14433 --- tests/test_framework/phpbb_functional_test_case.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/test_framework/phpbb_functional_test_case.php') diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 04e8f71379..8107e45dc7 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -94,6 +94,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). "'"; -- cgit v1.2.1