mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-25 19:38:53 +00:00
[ticket/17535] Update PHPUnit to v.10
PHPBB-17535
This commit is contained in:
parent
30ee379576
commit
d7db296eab
56 changed files with 529 additions and 574 deletions
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
|
@ -249,7 +249,7 @@ jobs:
|
|||
DB: ${{steps.database-type.outputs.db}}
|
||||
if: ${{ matrix.SLOWTESTS != 1 && matrix.NOTESTS != 1 }}
|
||||
run: |
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --stop-on-error
|
||||
|
||||
- name: Slow tests
|
||||
env:
|
||||
|
@ -378,7 +378,7 @@ jobs:
|
|||
env:
|
||||
DB: ${{steps.database-type.outputs.db}}
|
||||
run: |
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --stop-on-error
|
||||
|
||||
# Other database types, namely sqlite3 and mssql
|
||||
other-tests:
|
||||
|
@ -491,7 +491,7 @@ jobs:
|
|||
env:
|
||||
DB: ${{steps.database-type.outputs.db}}
|
||||
run: |
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --display-all-issues --stop-on-error
|
||||
|
||||
# Test with IIS & PostgreSQL on Windows
|
||||
windows-tests:
|
||||
|
@ -606,8 +606,8 @@ jobs:
|
|||
- name: Run unit tests
|
||||
if: ${{ matrix.type == 'unit' }}
|
||||
run: |
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --exclude-group functional,slow
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --stop-on-error --exclude-group functional,slow
|
||||
- name: Run functional tests
|
||||
if: ${{ matrix.type == 'functional' }}
|
||||
run: |
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error --group functional
|
||||
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --stop-on-error --group functional
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
"laravel/homestead": "~14.4",
|
||||
"misantron/dbunit": "~5.0",
|
||||
"phing/phing": "~2.4",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"phpunit/phpunit": "^10.0",
|
||||
"squizlabs/php_codesniffer": "~3.4",
|
||||
"symfony/browser-kit": "^6.3",
|
||||
"symfony/css-selector": "^6.3",
|
||||
|
|
609
phpBB/composer.lock
generated
609
phpBB/composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -573,7 +573,7 @@ class container_builder
|
|||
}
|
||||
|
||||
$config_data = $this->config_php_file->get_all();
|
||||
if (!empty($config_data))
|
||||
if (!empty($config_data) && !empty($config_data['dbms']))
|
||||
{
|
||||
if ($this->dbal_connection === null)
|
||||
{
|
||||
|
@ -592,6 +592,10 @@ class container_builder
|
|||
}
|
||||
$this->container->set('dbal.conn.driver', $this->dbal_connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,15 +21,15 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
|
|||
{
|
||||
$this->delete = $this->getMockBuilder('\phpbb\attachment\delete')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['delete', 'unlink_attachment'])
|
||||
->onlyMethods(['delete', 'unlink_attachment'])
|
||||
->getMock();
|
||||
$this->resync = $this->getMockBuilder('\phpbb\attachment\resync')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['resync'])
|
||||
->onlyMethods(['resync'])
|
||||
->getMock();
|
||||
$this->upload = $this->getMockBuilder('\phpbb\attachment\upload')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['upload'])
|
||||
->onlyMethods(['upload'])
|
||||
->getMock();
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
|
|||
public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
|
||||
{
|
||||
$filespec = $this->getMockBuilder('\phpbb\files\filespec_storage')
|
||||
->setMethods(array(
|
||||
->onlyMethods(array(
|
||||
'init_error',
|
||||
'is_image',
|
||||
'move_file',
|
||||
|
|
|
@ -74,8 +74,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
|
|||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->exactly(2))
|
||||
->method('server')
|
||||
->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
|
||||
->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
|
||||
->willReturnCallback(fn(string $arg) => match(true) {
|
||||
$arg === 'PHP_AUTH_USER' => 'foobar',
|
||||
$arg === 'PHP_AUTH_PW' => 'example',
|
||||
});
|
||||
|
||||
$expected = array(
|
||||
'status' => LOGIN_SUCCESS,
|
||||
|
@ -102,8 +104,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
|
|||
->will($this->returnValue(true));
|
||||
$this->request->expects($this->exactly(2))
|
||||
->method('server')
|
||||
->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
|
||||
->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
|
||||
->willReturnCallback(fn(string $arg) => match(true) {
|
||||
$arg === 'PHP_AUTH_USER' => 'foobar',
|
||||
$arg === 'PHP_AUTH_PW' => 'example',
|
||||
});
|
||||
|
||||
$expected = array(
|
||||
'user_id' => 1,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
*/
|
||||
|
||||
require_once __DIR__ . '/driver/foobar.php';
|
||||
require_once __DIR__ . '/driver/barfoo.php';
|
||||
|
||||
class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
{
|
||||
|
@ -62,15 +63,15 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
|||
|
||||
// $this->avatar_foobar will be needed later on
|
||||
$this->avatar_foobar = $this->getMockBuilder('\phpbb\avatar\driver\foobar')
|
||||
->setMethods(array('get_name'))
|
||||
->onlyMethods(array('get_name'))
|
||||
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
|
||||
->getMock();
|
||||
$this->avatar_foobar->expects($this->any())
|
||||
->method('get_name')
|
||||
->will($this->returnValue('avatar.driver.foobar'));
|
||||
// barfoo driver can't be mocked with constructor arguments
|
||||
$this->avatar_barfoo = $this->getMockBuilder('\phpbb\avatar\driver\barfoo')
|
||||
->setMethods(array('get_name', 'get_config_name'))
|
||||
->onlyMethods(array('get_name', 'get_config_name'))
|
||||
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
|
||||
->getMock();
|
||||
$this->avatar_barfoo->expects($this->any())
|
||||
->method('get_name')
|
||||
|
@ -89,14 +90,14 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
|||
if ($driver !== 'upload')
|
||||
{
|
||||
$cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
|
||||
->setMethods(array('get_name'))
|
||||
->onlyMethods(array('get_name'))
|
||||
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
|
||||
->getMock();
|
||||
}
|
||||
else
|
||||
{
|
||||
$cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
|
||||
->setMethods(array('get_name'))
|
||||
->onlyMethods(array('get_name'))
|
||||
->setConstructorArgs(array($this->config, $phpbb_root_path, $phpEx, $storage, $path_helper, $routing_helper, $dispatcher, $files_factory, $php_ini))
|
||||
->getMock();
|
||||
}
|
||||
|
@ -302,7 +303,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
|||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$user = $this->getMockBuilder('\phpbb\user')
|
||||
->setMethods(array())
|
||||
->onlyMethods(['lang'])
|
||||
->setConstructorArgs(array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\phpbb\datetime'))
|
||||
->getMock();
|
||||
$lang_array = array(
|
||||
|
|
|
@ -14,13 +14,14 @@
|
|||
define('IN_PHPBB', true);
|
||||
define('PHPBB_ENVIRONMENT', 'test');
|
||||
|
||||
global $phpbb_class_loader, $phpbb_class_loader_mock, $phpbb_class_loader_ext, $phpbb_class_loader_tests;
|
||||
global $phpbb_root_path, $phpEx, $table_prefix;
|
||||
|
||||
$phpbb_root_path = 'phpBB/';
|
||||
$phpEx = 'php';
|
||||
|
||||
global $table_prefix;
|
||||
require_once $phpbb_root_path . 'includes/startup.php';
|
||||
|
||||
$table_prefix = 'phpbb_';
|
||||
|
||||
require_once $phpbb_root_path . 'includes/startup.php';
|
||||
require_once $phpbb_root_path . 'includes/constants.php';
|
||||
require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx;
|
||||
require_once $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
|
||||
|
|
|
@ -454,7 +454,7 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
|
|||
->expects($matcher)
|
||||
->method('assign_vars')
|
||||
->willReturnCallback(function ($template_data) use ($matcher, $expected) {
|
||||
$callNr = $matcher->getInvocationCount();
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
$this->assertEquals($expected[$callNr], $template_data);
|
||||
});
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
|
|||
));
|
||||
|
||||
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
|
||||
->setMethods(array('setContext', 'generate'))
|
||||
->onlyMethods(array('setContext', 'generate'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mock_router->method('setContext')
|
||||
|
|
|
@ -53,7 +53,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
|
|||
));
|
||||
|
||||
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
|
||||
->setMethods(array('setContext', 'generate'))
|
||||
->onlyMethods(array('setContext', 'generate'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mock_router->method('setContext')
|
||||
|
@ -132,7 +132,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
|
|||
));
|
||||
|
||||
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
|
||||
->setMethods(array('setContext', 'generate'))
|
||||
->onlyMethods(array('setContext', 'generate'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mock_router->method('setContext')
|
||||
|
@ -180,7 +180,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
|
|||
));
|
||||
|
||||
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
|
||||
->setMethods(array('setContext', 'generate'))
|
||||
->onlyMethods(array('setContext', 'generate'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mock_router->method('setContext')
|
||||
|
|
|
@ -62,7 +62,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
|
|||
return $response;
|
||||
};
|
||||
$helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\QuestionHelper')
|
||||
->setMethods(['ask'])
|
||||
->onlyMethods(['ask'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$helper->expects($this->any())
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
require_once __DIR__ . '/common_helper_route.php';
|
||||
|
||||
class phpbb_controller_helper_route_test extends phpbb_controller_common_helper_route
|
||||
class phpbb_controller_helper_route_root_test extends phpbb_controller_common_helper_route
|
||||
{
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
|
|
|
@ -84,7 +84,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case
|
|||
));
|
||||
|
||||
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
|
||||
->setMethods(array('setContext', 'generate'))
|
||||
->onlyMethods(array('setContext', 'generate'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$mock_router->method('setContext')
|
||||
|
|
|
@ -111,7 +111,8 @@ class phpbb_cron_wrapper_test extends phpbb_template_template_test_case
|
|||
{
|
||||
$this->task = $this->getMockBuilder(\phpbb\cron\task\task::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['get_name', 'run', 'is_runnable', 'should_run', 'some_method'])
|
||||
->onlyMethods(['get_name', 'run', 'is_runnable', 'should_run'])
|
||||
->addMethods(['some_method'])
|
||||
->getMock();
|
||||
$this->routing_helper = $this->createMock(\phpbb\routing\helper::class);
|
||||
|
||||
|
|
|
@ -31,15 +31,23 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
|
|||
// Failure to connect results in a trigger_error call in dbal.
|
||||
// phpunit converts triggered errors to exceptions.
|
||||
// In particular there should be no fatals here.
|
||||
try
|
||||
|
||||
|
||||
if ($db->get_sql_layer() === 'mysqli')
|
||||
{
|
||||
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
|
||||
$this->assertFalse(true);
|
||||
$this->setExpectedTriggerError(E_WARNING);
|
||||
}
|
||||
catch (Exception $e)
|
||||
else if ($db->get_sql_layer() !== 'sqlite3')
|
||||
{
|
||||
// should have a legitimate message
|
||||
$this->assertNotEmpty($e->getMessage());
|
||||
$this->setExpectedTriggerError(E_USER_ERROR);
|
||||
}
|
||||
|
||||
// For SQLite3, connection will be successful anyway as phpBB driver uses SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE flags
|
||||
$result = $db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
|
||||
|
||||
if ($db->get_sql_layer() === 'sqlite3')
|
||||
{
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,11 +404,19 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
|||
->will($this->returnValue(true));
|
||||
|
||||
// drop tables
|
||||
$db_tools->expects($this->exactly(2))->method('schema_drop_table')
|
||||
->withConsecutive(
|
||||
[$this->isInstanceOf(Schema::class), 'dropped_table_1', true],
|
||||
[$this->isInstanceOf(Schema::class), 'dropped_table_2', true]
|
||||
);
|
||||
$matcher = $this->exactly(2);
|
||||
$db_tools->expects($matcher)->method('schema_drop_table')
|
||||
->willReturnCallback(function() use ($matcher) {
|
||||
$args = func_get_args();
|
||||
$schema = array_shift($args);
|
||||
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
|
||||
match($matcher->numberOfInvocations())
|
||||
{
|
||||
1 => $this->assertEquals($args, ['dropped_table_1', true]),
|
||||
2 => $this->assertEquals($args, ['dropped_table_2', true]),
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
$db_tools->perform_schema_changes(array(
|
||||
'drop_tables' => array(
|
||||
|
@ -432,11 +440,18 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
|
|||
->will($this->returnValue(true));
|
||||
|
||||
// drop columns
|
||||
$db_tools->expects($this->exactly(2))->method('schema_column_remove')
|
||||
->withConsecutive(
|
||||
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_1', true],
|
||||
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_2', true]
|
||||
);
|
||||
$matcher = $this->exactly(2);
|
||||
$db_tools->expects($matcher)->method('schema_column_remove')
|
||||
->willReturnCallback(function() use ($matcher) {
|
||||
$args = func_get_args();
|
||||
$schema = array_shift($args);
|
||||
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
|
||||
match($matcher->numberOfInvocations()) {
|
||||
1 => $this->assertEquals($args, ['existing_table', 'dropped_column_1', true]),
|
||||
2 => $this->assertEquals($args, ['existing_table', 'dropped_column_2', true]),
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
$db_tools->perform_schema_changes(array(
|
||||
'drop_columns' => array(
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace
|
|||
{
|
||||
require_once __DIR__ . '/fixtures/ext/vendor/enabled_4/di/extension.php';
|
||||
|
||||
class phpbb_di_container_test extends \phpbb_test_case
|
||||
class phpbb_di_create_container_test extends \phpbb_test_case
|
||||
{
|
||||
protected $config_php;
|
||||
|
||||
|
@ -73,7 +73,8 @@ namespace
|
|||
|
||||
// Checks the construction of a dumped container
|
||||
$container = $this->builder->get_container();
|
||||
$this->assertInstanceOf('phpbb_cache_container', $container);
|
||||
$this->assertEquals('phpbb_cache_container', $container::class);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Container', $container);
|
||||
$this->assertTrue($container->isCompiled());
|
||||
}
|
||||
|
||||
|
@ -100,7 +101,8 @@ namespace
|
|||
|
||||
// Checks the construction of a dumped container
|
||||
$container = $this->builder->get_container();
|
||||
$this->assertNotInstanceOf('phpbb_cache_container', $container);
|
||||
$this->assertNotEquals('phpbb_cache_container', $container::class);
|
||||
$this->assertEquals('Symfony\Component\DependencyInjection\ContainerBuilder', $container::class);
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
|
||||
$this->assertTrue($container->isCompiled());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
// phpBB 3.1.x auto-generated configuration file
|
||||
// Do not change anything in this file!
|
||||
$dbms = 'mysql';
|
||||
$dbms = ''; // Set this to empty value to avoid failed connection attempt as this will produce unwanted error/exception
|
||||
$dbhost = '127.0.0.1';
|
||||
$dbport = '';
|
||||
$dbname = 'phpbb';
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class exception_listener extends phpbb_test_case
|
||||
class exception_listener_test extends phpbb_test_case
|
||||
{
|
||||
public function phpbb_exception_data()
|
||||
{
|
||||
|
|
|
@ -229,6 +229,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
|
|||
|
||||
if (!empty($data['forums']))
|
||||
{
|
||||
array_walk($data['forums'], function(&$value, $key)
|
||||
{
|
||||
$value = $this->db->sql_escape($value);
|
||||
}
|
||||
);
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_forums
|
||||
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
|
||||
|
@ -245,6 +250,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
|
|||
|
||||
if (!empty($data['topics']))
|
||||
{
|
||||
array_walk($data['topics'], function(&$value, $key)
|
||||
{
|
||||
$value = $this->db->sql_escape($value);
|
||||
}
|
||||
);
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_topics
|
||||
WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
|
||||
|
@ -262,6 +272,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
|
|||
$post_ids = array();
|
||||
if (!empty($data['posts']))
|
||||
{
|
||||
array_walk($data['posts'], function(&$value, $key)
|
||||
{
|
||||
$value = $this->db->sql_escape($value);
|
||||
}
|
||||
);
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_posts
|
||||
WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
|
||||
|
@ -276,7 +291,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
|
|||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
if (isset($data['attachments']))
|
||||
if (isset($data['attachments']) && !empty($post_ids))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_attachments
|
||||
|
|
|
@ -23,16 +23,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
|
|||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
||||
public function __construct($name = null, array $data = array(), $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
$this->setBackupStaticPropertiesExcludeList([
|
||||
'phpbb_functional_feed_test' => ['init_values'],
|
||||
];
|
||||
]);
|
||||
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case
|
|||
{
|
||||
protected static $data = array();
|
||||
|
||||
public function __construct()
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::__construct();
|
||||
parent::setUp();
|
||||
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
$this->setBackupStaticPropertiesExcludeList([
|
||||
'phpbb_functional_ucp_allow_pm_test' => ['data'],
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
// user A sends a PM to user B where B accepts PM
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
|
||||
class phpbb_functional_visibility_unapproved_posts_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $data = [];
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class phpbb_functions_parse_cfg_file extends phpbb_test_case
|
||||
class phpbb_functions_parse_cfg_file_test extends phpbb_test_case
|
||||
{
|
||||
public function parse_cfg_file_data()
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
|
|||
require_once __DIR__ . '/../mock/cache.php';
|
||||
require_once __DIR__ . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_data_test extends phpbb_database_test_case
|
||||
class phpbb_functions_validate_username_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $cache;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
require_once __DIR__ . '/../../phpBB/includes/functions_acp.php';
|
||||
|
||||
class phpbb_functions_acp_built_select_test extends phpbb_test_case
|
||||
class phpbb_functions_acp_build_select_test extends phpbb_test_case
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -124,97 +124,97 @@ class phpbb_functions_content_get_context_test extends TestCase
|
|||
public function data_get_context_unicode(): array
|
||||
{
|
||||
return [
|
||||
'text contains words and length greater than text' => [
|
||||
'text contains words and length greater than text unicode' => [
|
||||
'text' => 'Это пример текста, содержащего разнообразные слова, включая пример, текст и слова.',
|
||||
'words' => ['пример', 'слова'],
|
||||
'length' => 100,
|
||||
'expected' => 'Это пример текста, содержащего разнообразные слова, включая пример, текст и слова.',
|
||||
],
|
||||
'text contains words and length less than text' => [
|
||||
'text contains words and length less than text unicode' => [
|
||||
'text' => 'Это пример текста, содержащего разнообразные слова, включая шаблон, текст и слова.',
|
||||
'words' => ['пример', 'слова'],
|
||||
'length' => 50,
|
||||
'expected' => 'Это пример текста, содержащего разнообразные слова ...',
|
||||
],
|
||||
'text does not contain words' => [
|
||||
'text does not contain words unicode' => [
|
||||
'text' => 'Это пример текста, содержащего разнообразные слова, но ни одно из них не совпадает с искомыми.',
|
||||
'words' => ['nonexistent'],
|
||||
'length' => 50,
|
||||
'expected' => 'Это пример текста, содержащего разнообразные слова ...',
|
||||
],
|
||||
'desired length equal to text length' => [
|
||||
'desired length equal to text length unicode' => [
|
||||
'text' => 'Текст точной длины.',
|
||||
'words' => ['Текст', 'точной'],
|
||||
'length' => 19,
|
||||
'expected' => 'Текст точной длины.',
|
||||
],
|
||||
'text with html entities' => [
|
||||
'text with html entities unicode' => [
|
||||
'text' => 'Это пример текста, содержащего & и < и > лексемы.',
|
||||
'words' => ['пример', 'содержащего'],
|
||||
'length' => 40,
|
||||
'expected' => 'Это пример текста, содержащего & и < и ...',
|
||||
],
|
||||
'text with html entities and contains last word' => [
|
||||
'text with html entities and contains last word unicode' => [
|
||||
'text' => 'Это пример текста, содержащего & и < и > лексемы.',
|
||||
'words' => ['пример', 'лексемы'],
|
||||
'length' => 40,
|
||||
'expected' => 'Это пример текста ... и < и > лексемы.',
|
||||
],
|
||||
'text with multiple spaces and special characters' => [
|
||||
'text with multiple spaces and special characters unicode' => [
|
||||
'text' => 'Это пример текста, содержащего разнообразные слова.',
|
||||
'words' => ['пример', 'разнообразные'],
|
||||
'length' => 50,
|
||||
'expected' => 'Это пример текста, содержащего разнообразные слова.',
|
||||
],
|
||||
'empty text' => [
|
||||
'empty text unicode' => [
|
||||
'text' => '',
|
||||
'words' => ['пример', 'слова'],
|
||||
'length' => 50,
|
||||
'expected' => '',
|
||||
],
|
||||
'empty words array' => [
|
||||
'empty words array unicode' => [
|
||||
'text' => 'Это пример текста, содержащего разнообразные слова.',
|
||||
'words' => [],
|
||||
'length' => 50,
|
||||
'expected' => 'Это пример текста, содержащего разнообразные слова.',
|
||||
],
|
||||
'zero length' => [
|
||||
'zero length unicode' => [
|
||||
'text' => 'Это пример текста.',
|
||||
'words' => ['пример'],
|
||||
'length' => 0,
|
||||
'expected' => 'Это пример текста.',
|
||||
],
|
||||
'negative length' => [
|
||||
'negative length unicode' => [
|
||||
'text' => 'Это пример текста.',
|
||||
'words' => ['sample'],
|
||||
'length' => -10,
|
||||
'expected' => 'Это пример текста.',
|
||||
],
|
||||
'ellipses_beginning' => [
|
||||
'ellipses_beginning unicode' => [
|
||||
'text' => 'раз раз раз раз раз раз раз раз два',
|
||||
'words' => ['два'],
|
||||
'length' => 10,
|
||||
'expected' => '... раз раз два',
|
||||
],
|
||||
'ellipsis_end' => [
|
||||
'ellipsis_end unicode' => [
|
||||
'text' => 'два раз раз раз раз раз раз раз раз',
|
||||
'words' => ['два'],
|
||||
'length' => 10,
|
||||
'expected' => 'два раз раз ...',
|
||||
],
|
||||
'ellipsis_middle' => [
|
||||
'ellipsis_middle unicode' => [
|
||||
'text' => 'раз слово1 раз раз раз раз раз раз раз раз раз слово2 раз',
|
||||
'words' => ['слово1', 'слово2'],
|
||||
'length' => 15,
|
||||
'expected' => '... слово1 ... слово2 ...',
|
||||
],
|
||||
'ellipsis_middle2' => [
|
||||
'ellipsis_middle2 unicode' => [
|
||||
'text' => 'слово1 foo foo foo foo foo foo foo foo foo слово2',
|
||||
'words' => ['слово1', 'слово2'],
|
||||
'length' => 10,
|
||||
'expected' => 'слово1 ... слово2',
|
||||
],
|
||||
'fruits_spanish' => [
|
||||
'fruits_spanish unicode' => [
|
||||
'text' => 'Manzana,plátano,naranja,fresa,mango,uva,piña,pera,kiwi,cereza,sandía,melón,papaya,arándano,durazno',
|
||||
'words' => ['piña'],
|
||||
'length' => 20,
|
||||
|
|
|
@ -101,7 +101,7 @@ class phpbb_group_helper_test_case extends phpbb_test_case
|
|||
// Set up path helper
|
||||
$path_helper = $this->getMockBuilder('\phpbb\path_helper')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array())
|
||||
->onlyMethods(['get_phpbb_root_path', 'get_php_ext', 'update_web_root_path'])
|
||||
->getMock();
|
||||
$path_helper->method('get_phpbb_root_path')
|
||||
->willReturn($phpbb_root_path);
|
||||
|
|
|
@ -78,18 +78,20 @@ class phpbb_help_manager_test extends phpbb_test_case
|
|||
|
||||
$this->language->expects($this->exactly(count($questions)*2 + 1))
|
||||
->method('lang')
|
||||
->withConsecutive([$block_name], ...$question_ary)
|
||||
->will($this->onConsecutiveCalls(strtoupper($block_name), ...$question_ary_upper));
|
||||
->willReturnCallback(fn(string $arg) => strtoupper($arg));
|
||||
|
||||
$this->template->expects($this->exactly(count($questions) + 1))
|
||||
$matcher = $this->exactly(count($questions) + 1);
|
||||
$this->template->expects($matcher)
|
||||
->method('assign_block_vars')
|
||||
->withConsecutive(
|
||||
['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name),
|
||||
'SWITCH_COLUMN' => $switch_expected,
|
||||
]],
|
||||
...$template_call_args
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($matcher, $block_name, $switch_expected, $template_call_args) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
match (true) {
|
||||
$callNr == 1 => $this->assertEquals([$arg1, $arg2], ['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name),
|
||||
'SWITCH_COLUMN' => $switch_expected,
|
||||
]]),
|
||||
$callNr > 1 => $this->assertEquals([$arg1, $arg2], $template_call_args[$callNr - 2]),
|
||||
};});
|
||||
|
||||
$this->manager->add_block($block_name, $switch, $questions);
|
||||
|
||||
|
@ -114,11 +116,7 @@ class phpbb_help_manager_test extends phpbb_test_case
|
|||
{
|
||||
$this->language->expects($this->exactly(2))
|
||||
->method('lang')
|
||||
->withConsecutive(
|
||||
[$question],
|
||||
[$answer]
|
||||
)
|
||||
->will($this->onConsecutiveCalls(strtoupper($question), strtoupper($answer)));
|
||||
->willReturnCallback(fn(string $arg) => strtoupper($arg));
|
||||
|
||||
$this->template->expects($this->once())
|
||||
->method('assign_block_vars')
|
||||
|
@ -137,22 +135,23 @@ class phpbb_help_manager_test extends phpbb_test_case
|
|||
|
||||
$this->language->expects($this->exactly(2))
|
||||
->method('lang')
|
||||
->withConsecutive([$block_name[0]], [$block_name[1]])
|
||||
->will($this->onConsecutiveCalls(strtoupper($block_name[0]), strtoupper($block_name[1])));
|
||||
->willReturnCallback(fn(string $arg) => strtoupper($arg));
|
||||
|
||||
$this->template->expects($this->exactly(2))
|
||||
$matcher = $this->exactly(2);
|
||||
$this->template->expects($matcher)
|
||||
->method('assign_block_vars')
|
||||
->withConsecutive(
|
||||
['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name[0]),
|
||||
'SWITCH_COLUMN' => $switch_expected[0],
|
||||
]],
|
||||
['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name[1]),
|
||||
'SWITCH_COLUMN' => $switch_expected[1],
|
||||
]]
|
||||
|
||||
);
|
||||
->willReturnCallback(function ($arg1, $arg2) use ($matcher, $block_name, $switch_expected) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
match (true) {
|
||||
$callNr == 1 => $this->assertEquals([$arg1, $arg2], ['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name[0]),
|
||||
'SWITCH_COLUMN' => $switch_expected[0],
|
||||
]]),
|
||||
$callNr == 2 => $this->assertEquals([$arg1, $arg2], ['faq_block', [
|
||||
'BLOCK_TITLE' => strtoupper($block_name[1]),
|
||||
'SWITCH_COLUMN' => $switch_expected[1],
|
||||
]]),
|
||||
};});
|
||||
|
||||
$this->manager->add_block($block_name[0], true);
|
||||
$this->assertTrue($this->manager->switched_column());
|
||||
|
|
|
@ -57,7 +57,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case
|
|||
public function test_validate_table_prefix($expected, $test_string)
|
||||
{
|
||||
$db_helper_mock = $this->getMockBuilder('\phpbb\install\helper\database')
|
||||
->setMethods(array('get_available_dbms'))
|
||||
->onlyMethods(array('get_available_dbms'))
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class phpbb_installer_config_test extends phpbb_test_case
|
|||
$phpbb_root_path = __DIR__ . './../../phpBB/';
|
||||
$filesystem = $this->createMock('\phpbb\filesystem\filesystem');
|
||||
$php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')
|
||||
->setMethods(array('getInt', 'getBytes'))
|
||||
->onlyMethods(array('getNumeric', 'getBytes'))
|
||||
->getMock();
|
||||
$php_ini->method('getInt')
|
||||
$php_ini->method('getNumeric')
|
||||
->willReturn(-1);
|
||||
$php_ini->method('getBytes')
|
||||
->willReturn(-1);
|
||||
|
|
|
@ -546,13 +546,13 @@ class phpbb_mention_controller_test extends phpbb_database_test_case
|
|||
{
|
||||
$this->request->expects($this->atLeast(2))
|
||||
->method('variable')
|
||||
->withConsecutive(
|
||||
['keyword', '', true],
|
||||
['topic_id', 0])
|
||||
->willReturnOnConsecutiveCalls(
|
||||
$keyword,
|
||||
$topic_id
|
||||
);
|
||||
->willReturnCallback(function() use ($keyword, $topic_id) {
|
||||
$args = func_get_args();
|
||||
return match($args) {
|
||||
['keyword', '', true, \phpbb\request\request_interface::REQUEST] => $keyword,
|
||||
['topic_id', 0, false, \phpbb\request\request_interface::REQUEST] => $topic_id,
|
||||
};});
|
||||
|
||||
$data = json_decode($this->controller->handle()->getContent(), true);
|
||||
$this->assertEquals($expected_result, $data);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
|
|||
$phpbb_container->getParameter('tables.notification_emails'),
|
||||
$phpbb_container->get('messenger.method_collection')
|
||||
])
|
||||
->setMethods(['notify_using_messenger'])
|
||||
->onlyMethods(['notify_using_messenger'])
|
||||
->getMock();
|
||||
$notification_method_email = $this->notification_method_email;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
class phpbb_passwords_helper_test extends \phpbb_test_case
|
||||
class phpbb_passwords_drivers_test extends \phpbb_test_case
|
||||
{
|
||||
/** @var array */
|
||||
protected $passwords_drivers = [];
|
||||
|
|
|
@ -112,7 +112,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
'php',
|
||||
'adm/'
|
||||
])
|
||||
->setMethods(['get_web_root_path'])
|
||||
->onlyMethods(['get_web_root_path'])
|
||||
->getMock();
|
||||
$path_helper->method('get_web_root_path')
|
||||
->willReturn('/var/www/phpbb/app.php/');
|
||||
|
@ -257,7 +257,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
'php',
|
||||
'adm/'
|
||||
])
|
||||
->setMethods(['get_web_root_path'])
|
||||
->onlyMethods(['get_web_root_path'])
|
||||
->getMock();
|
||||
$path_helper->method('get_web_root_path')
|
||||
->willReturn('/var/www/phpbb/');
|
||||
|
@ -462,7 +462,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
{
|
||||
$symfony_request = $this->getMockBuilder('\phpbb\symfony_request')
|
||||
->setConstructorArgs([new phpbb_mock_request()])
|
||||
->setMethods(['get', 'getSchemeAndHttpHost', 'getBasePath', 'getPathInfo'])
|
||||
->onlyMethods(['get', 'getSchemeAndHttpHost', 'getBasePath', 'getPathInfo'])
|
||||
->getMock();
|
||||
$symfony_request->method('getSchemeAndHttpHost')
|
||||
->willReturn('http://www.phpbb.com');
|
||||
|
@ -630,7 +630,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
|||
{
|
||||
$symfony_request = $this->getMockBuilder('\phpbb\symfony_request')
|
||||
->setConstructorArgs([new phpbb_mock_request()])
|
||||
->setMethods(['getScriptName'])
|
||||
->onlyMethods(['getScriptName'])
|
||||
->getMock();
|
||||
$symfony_request->method('getScriptName')
|
||||
->willReturn($script_name);
|
||||
|
|
|
@ -113,7 +113,7 @@ class phpbb_plupload_test extends phpbb_test_case
|
|||
$config = new \phpbb\config\config([]);
|
||||
|
||||
$ini_wrapper = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')
|
||||
->setMethods(['getBytes'])
|
||||
->onlyMethods(['getBytes'])
|
||||
->getMock();
|
||||
$ini_wrapper->method('getBytes')
|
||||
->will($this->returnValueMap([
|
||||
|
|
|
@ -33,12 +33,12 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
|
|||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||
|
||||
$lang = $this->getMockBuilder('\phpbb\profilefields\lang_helper')
|
||||
->setMethods(array('get_options_lang', 'is_set', 'get'))
|
||||
->onlyMethods(array('load_option_lang', 'is_set', 'get'))
|
||||
->setConstructorArgs(array($db, LANG_TABLE))
|
||||
->getMock();
|
||||
|
||||
$lang->expects($this->any())
|
||||
->method('get_options_lang');
|
||||
->method('load_option_lang');
|
||||
|
||||
$lang->expects($this->any())
|
||||
->method('is_set')
|
||||
|
|
|
@ -35,12 +35,12 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
|
|||
$template = $this->createMock('\phpbb\template\template');
|
||||
|
||||
$lang = $this->getMockBuilder('\phpbb\profilefields\lang_helper')
|
||||
->setMethods(array('get_options_lang', 'is_set', 'get'))
|
||||
->onlyMethods(array('load_option_lang', 'is_set', 'get'))
|
||||
->setConstructorArgs(array($db, LANG_TABLE))
|
||||
->getMock();
|
||||
|
||||
$lang->expects($this->any())
|
||||
->method('get_options_lang');
|
||||
->method('load_option_lang');
|
||||
|
||||
$lang->expects($this->any())
|
||||
->method('is_set')
|
||||
|
|
|
@ -35,7 +35,7 @@ class phpbb_template_asset_test extends phpbb_test_case
|
|||
{
|
||||
$path_helper = $this->getMockBuilder('\phpbb\path_helper')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array())
|
||||
->onlyMethods(['get_phpbb_root_path'])
|
||||
->getMock();
|
||||
|
||||
$path_helper->method('get_phpbb_root_path')
|
||||
|
|
|
@ -38,7 +38,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
|
|||
$user->data['user_id'] = 2;
|
||||
$auth = $this->getMockBuilder('phpbb\auth\auth')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['acl_get'])
|
||||
->onlyMethods(['acl_get'])
|
||||
->getMock();
|
||||
$auth->method('acl_get')
|
||||
->willReturn(true);
|
||||
|
|
|
@ -34,25 +34,6 @@ abstract class phpbb_database_test_case extends TestCase
|
|||
*/
|
||||
private $db_connections_doctrine;
|
||||
|
||||
public function __construct($name = NULL, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
|
||||
'SebastianBergmann\Timer\Timer' => ['startTimes'],
|
||||
'PHP_Token_Stream' => ['customTokens'],
|
||||
'PHP_Token_Stream_CachingFactory' => ['cache'],
|
||||
|
||||
'phpbb_database_test_case' => ['already_connected'],
|
||||
];
|
||||
|
||||
$this->db_connections = [];
|
||||
$this->db_connections_doctrine = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array List of extensions that should be set up
|
||||
*/
|
||||
|
@ -135,6 +116,20 @@ abstract class phpbb_database_test_case extends TestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setBackupStaticPropertiesExcludeList([
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
|
||||
'SebastianBergmann\Timer\Timer' => ['startTimes'],
|
||||
'PHP_Token_Stream' => ['customTokens'],
|
||||
'PHP_Token_Stream_CachingFactory' => ['cache'],
|
||||
|
||||
'phpbb_database_test_case' => ['already_connected'],
|
||||
]);
|
||||
|
||||
$this->db_connections = [];
|
||||
$this->db_connections_doctrine = [];
|
||||
|
||||
// Resynchronise tables if a fixture was loaded
|
||||
if (isset($this->fixture_xml_data))
|
||||
{
|
||||
|
|
|
@ -87,6 +87,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setBackupStaticPropertiesExcludeList([
|
||||
'phpbb_functional_test_case' => ['config', 'already_installed'],
|
||||
]);
|
||||
|
||||
if (!self::$install_success)
|
||||
{
|
||||
$this->fail('Installing phpBB has failed.');
|
||||
|
@ -97,6 +101,9 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
self::$cookieJar = new CookieJar;
|
||||
// Force native client on windows platform
|
||||
self::$http_client = strtolower(substr(PHP_OS, 0, 3)) === 'win' ? new NativeHttpClient() : HttpClient::create();
|
||||
self::$http_client->withOptions([
|
||||
'timeout' => 60,
|
||||
]);
|
||||
self::$client = new HttpBrowser(self::$http_client, null, self::$cookieJar);
|
||||
|
||||
// Clear the language array so that things
|
||||
|
@ -216,15 +223,6 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
{
|
||||
}
|
||||
|
||||
public function __construct($name = NULL, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
'phpbb_functional_test_case' => ['config', 'already_installed'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \phpbb\db\driver\driver_interface
|
||||
*/
|
||||
|
@ -307,7 +305,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
$container->set('event_dispatcher', $phpbb_dispatcher);
|
||||
$cache = $this->getMockBuilder('\phpbb\cache\service')
|
||||
->setConstructorArgs([$this->get_cache_driver(), $config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx])
|
||||
->setMethods(['deferred_purge'])
|
||||
->onlyMethods(['deferred_purge'])
|
||||
->getMock();
|
||||
$cache->method('deferred_purge')
|
||||
->willReturnCallback([$cache, 'purge']);
|
||||
|
@ -550,7 +548,15 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
$iohandler->set_input('script_path', $parseURL['path']);
|
||||
$iohandler->set_input('submit_server', 'submit');
|
||||
|
||||
$installer->run();
|
||||
try
|
||||
{
|
||||
$installer->run();
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
// Do nothing but catch the exception as PHPUnit here throws
|
||||
// "PHPUnit\Event\Code\NoTestCaseObjectOnCallStackException: Cannot find TestCase object on call stack"
|
||||
}
|
||||
|
||||
copy($config_file, $config_file_test);
|
||||
|
||||
|
@ -568,7 +574,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
}
|
||||
|
||||
global $phpbb_container;
|
||||
$phpbb_container->reset();
|
||||
if (!empty($phpbb_container))
|
||||
{
|
||||
$phpbb_container->reset();
|
||||
}
|
||||
|
||||
// Purge cache to remove cached files
|
||||
$phpbb_container = new phpbb_mock_container_builder();
|
||||
|
|
|
@ -17,11 +17,9 @@ class phpbb_test_case extends TestCase
|
|||
{
|
||||
protected $test_case_helpers;
|
||||
|
||||
public function __construct($name = NULL, array $data = array(), $dataName = '')
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
|
||||
$this->backupStaticAttributesExcludeList += [
|
||||
$this->setBackupStaticPropertiesExcludeList([
|
||||
'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Filter' => ['instance'],
|
||||
'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'],
|
||||
|
@ -30,7 +28,7 @@ class phpbb_test_case extends TestCase
|
|||
'PHP_Token_Stream_CachingFactory' => ['cache'],
|
||||
|
||||
'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'],
|
||||
];
|
||||
]);
|
||||
}
|
||||
|
||||
public function get_test_case_helpers()
|
||||
|
|
|
@ -434,7 +434,7 @@ class phpbb_test_case_helpers
|
|||
->disallowMockingUnknownTypes()
|
||||
->getMock();
|
||||
$mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access');
|
||||
$mb->setMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles'));
|
||||
$mb->onlyMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles'));
|
||||
$mb->setConstructorArgs(array(
|
||||
$db_driver,
|
||||
'phpbb_bbcodes',
|
||||
|
@ -488,7 +488,7 @@ class phpbb_test_case_helpers
|
|||
{
|
||||
$path_helper = $this->test_case->getMockBuilder('phpbb\\path_helper')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(array('get_web_root_path'))
|
||||
->onlyMethods(array('get_web_root_path'))
|
||||
->getMock();
|
||||
$path_helper->expects($this->test_case->any())
|
||||
->method('get_web_root_path')
|
||||
|
@ -578,7 +578,7 @@ class phpbb_test_case_helpers
|
|||
|
||||
$user = $this->test_case->getMockBuilder('\phpbb\user')
|
||||
->setConstructorArgs(array($lang, '\phpbb\datetime'))
|
||||
->setMethods(array('format_date'))
|
||||
->onlyMethods(array('format_date'))
|
||||
->getMock();
|
||||
$user->expects($this->test_case->any())
|
||||
->method('format_date')
|
||||
|
|
|
@ -296,14 +296,19 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
|||
public function test_configure_events()
|
||||
{
|
||||
$this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
|
||||
$matcher = $this->exactly(2);
|
||||
$this->dispatcher
|
||||
->expects($this->exactly(2))
|
||||
->expects($matcher)
|
||||
->method('trigger_event')
|
||||
->withConsecutive(
|
||||
['core.text_formatter_s9e_configure_before', $this->callback(array($this, 'configure_event_callback'))],
|
||||
['core.text_formatter_s9e_configure_after', $this->callback(array($this, 'configure_event_callback'))]
|
||||
)
|
||||
->will($this->returnArgument(1));
|
||||
->willReturnCallback(function($event, $vars) use ($matcher) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
match($callNr) {
|
||||
1 => $this->assertEquals('core.text_formatter_s9e_configure_before', $event),
|
||||
2 => $this->assertEquals('core.text_formatter_s9e_configure_after', $event),
|
||||
};
|
||||
$this->assertTrue($this->configure_event_callback($vars));
|
||||
return $vars;
|
||||
});
|
||||
$this->get_factory()->get_configurator();
|
||||
}
|
||||
|
||||
|
|
|
@ -101,20 +101,19 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
|
|||
public function test_options($adapter_method, $adapter_arg, $concrete_method, $concrete_arg)
|
||||
{
|
||||
$mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser')
|
||||
->setMethods([$concrete_method])
|
||||
->onlyMethods([$concrete_method])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$concrete_args = (array) $concrete_arg;
|
||||
array_walk($concrete_args, function(&$value)
|
||||
{
|
||||
$value = (array) $value;
|
||||
}
|
||||
);
|
||||
$mock->expects($this->exactly(count($concrete_args)))
|
||||
$matcher = $this->exactly(count($concrete_args));
|
||||
$mock->expects($matcher)
|
||||
->method($concrete_method)
|
||||
->withConsecutive(...$concrete_args);
|
||||
|
||||
->willReturnCallback(function ($arg) use ($concrete_args, $matcher) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
$this->assertEquals($arg, $concrete_args[$callNr - 1]);
|
||||
});
|
||||
|
||||
$cache = new phpbb_mock_cache;
|
||||
$cache->put('_foo_parser', $mock);
|
||||
|
||||
|
@ -219,15 +218,22 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
|
|||
$dispatcher
|
||||
);
|
||||
|
||||
$matcher = $this->exactly(2);
|
||||
$dispatcher
|
||||
->expects($this->exactly(2))
|
||||
->expects($matcher)
|
||||
->method('trigger_event')
|
||||
->withConsecutive(
|
||||
['core.text_formatter_s9e_parse_before', $this->callback(array($this, 'parse_before_event_callback'))],
|
||||
['core.text_formatter_s9e_parse_after', $this->callback(array($this, 'parse_after_event_callback'))]
|
||||
)
|
||||
->will($this->returnArgument(1));
|
||||
|
||||
->willReturnCallback(function($event, $vars) use ($matcher) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
match($callNr) {
|
||||
1 => $this->assertEquals('core.text_formatter_s9e_parse_before', $event),
|
||||
2 => $this->assertEquals('core.text_formatter_s9e_parse_after', $event),
|
||||
};
|
||||
match($callNr) {
|
||||
1 => $this->assertTrue($this->parse_before_event_callback($vars)),
|
||||
2 => $this->assertTrue($this->parse_after_event_callback($vars)),
|
||||
};
|
||||
return $vars;
|
||||
});
|
||||
$parser->parse('...');
|
||||
}
|
||||
|
||||
|
|
|
@ -421,15 +421,22 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
|
|||
$dispatcher
|
||||
);
|
||||
|
||||
$matcher = $this->exactly(2);
|
||||
$dispatcher
|
||||
->expects($this->exactly(2))
|
||||
->expects($matcher)
|
||||
->method('trigger_event')
|
||||
->withConsecutive(
|
||||
['core.text_formatter_s9e_render_before', $this->callback(array($this, 'render_before_event_callback'))],
|
||||
['core.text_formatter_s9e_render_after', $this->callback(array($this, 'render_after_event_callback'))]
|
||||
)
|
||||
->will($this->returnArgument(1));
|
||||
|
||||
->willReturnCallback(function($event, $vars) use ($matcher) {
|
||||
$callNr = $matcher->numberOfInvocations();
|
||||
match($callNr) {
|
||||
1 => $this->assertEquals('core.text_formatter_s9e_render_before', $event),
|
||||
2 => $this->assertEquals('core.text_formatter_s9e_render_after', $event),
|
||||
};
|
||||
match($callNr) {
|
||||
1 => $this->assertTrue($this->render_before_event_callback($vars)),
|
||||
2 => $this->assertTrue($this->render_after_event_callback($vars)),
|
||||
};
|
||||
return $vars;
|
||||
});
|
||||
$renderer->render('<t>...</t>');
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/*
|
||||
* @group slow
|
||||
*/
|
||||
class phpbb_version_helper_fetch_test extends phpbb_test_case
|
||||
class phpbb_version_fetch_test extends phpbb_test_case
|
||||
{
|
||||
protected $cache, $version_helper;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class version_helper_remote_test extends \phpbb_test_case
|
|||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
$db = new \phpbb\db\driver\factory($container);
|
||||
$this->cache = $this->getMockBuilder('\phpbb\cache\service')
|
||||
->setMethods(array('get'))
|
||||
->addMethods(array('get'))
|
||||
->setConstructorArgs(array(new \phpbb\cache\driver\dummy(), $config, $db, $phpbb_dispatcher, '../../', 'php'))
|
||||
->getMock();
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ class phpbb_version_helper_test extends phpbb_test_case
|
|||
|
||||
$version_helper = $this
|
||||
->getMockBuilder('\phpbb\version_helper')
|
||||
->setMethods(array(
|
||||
->onlyMethods(array(
|
||||
'get_versions_matching_stability',
|
||||
))
|
||||
->setConstructorArgs(array(
|
||||
|
@ -324,7 +324,7 @@ class phpbb_version_helper_test extends phpbb_test_case
|
|||
|
||||
$version_helper = $this
|
||||
->getMockBuilder('\phpbb\version_helper')
|
||||
->setMethods(array(
|
||||
->onlyMethods(array(
|
||||
'get_versions_matching_stability',
|
||||
))
|
||||
->setConstructorArgs(array(
|
||||
|
@ -581,7 +581,7 @@ class phpbb_version_helper_test extends phpbb_test_case
|
|||
|
||||
$version_helper = $this
|
||||
->getMockBuilder('\phpbb\version_helper')
|
||||
->setMethods(array(
|
||||
->onlyMethods(array(
|
||||
'get_versions_matching_stability',
|
||||
))
|
||||
->setConstructorArgs(array(
|
||||
|
@ -958,7 +958,7 @@ class phpbb_version_helper_test extends phpbb_test_case
|
|||
|
||||
$version_helper = $this
|
||||
->getMockBuilder('\phpbb\version_helper')
|
||||
->setMethods(array(
|
||||
->onlyMethods(array(
|
||||
'get_versions_matching_stability',
|
||||
))
|
||||
->setConstructorArgs(array(
|
Loading…
Add table
Reference in a new issue