[ticket/16741] Fix tests

PHPBB3-16741
This commit is contained in:
Máté Bartus 2021-12-05 11:25:56 +01:00
parent a0584b8677
commit e93c914da3
2 changed files with 23 additions and 16 deletions

View file

@ -116,6 +116,11 @@ class container_builder
*/
private $env_parameters = [];
/**
* @var \phpbb\db\driver\driver_interface
*/
protected $dbal_connection = null;
/**
* Constructor
*
@ -568,20 +573,22 @@ class container_builder
$config_data = $this->config_php_file->get_all();
if (!empty($config_data))
{
$dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms'));
/** @var \phpbb\db\driver\driver_interface $dbal_connection */
$dbal_connection = new $dbal_driver_class();
$dbal_connection->sql_connect(
$this->config_php_file->get('dbhost'),
$this->config_php_file->get('dbuser'),
$this->config_php_file->get('dbpasswd'),
$this->config_php_file->get('dbname'),
$this->config_php_file->get('dbport'),
false,
defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK
);
//$this->dbal_connection_doctrine = connection_factory::get_connection($this->config_php_file);
$this->container->set('dbal.conn.driver', $dbal_connection);
if ($this->dbal_connection === null)
{
$dbal_driver_class = \phpbb\config_php_file::convert_30_dbms_to_31($this->config_php_file->get('dbms'));
/** @var \phpbb\db\driver\driver_interface $dbal_connection */
$this->dbal_connection = new $dbal_driver_class();
$this->dbal_connection->sql_connect(
$this->config_php_file->get('dbhost'),
$this->config_php_file->get('dbuser'),
$this->config_php_file->get('dbpasswd'),
$this->config_php_file->get('dbname'),
$this->config_php_file->get('dbport'),
false,
defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK
);
}
$this->container->set('dbal.conn.driver', $this->dbal_connection);
}
}

View file

@ -360,7 +360,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_perform_schema_changes_drop_tables()
{
$db_tools = $this->getMockBuilder('\phpbb\db\tools\doctrine')
->onlyMethods(array('sql_table_exists', '_schema_drop_table'))
->onlyMethods(array('sql_table_exists', 'schema_drop_table'))
->setConstructorArgs(array($this->doctrine_db))
->getMock();
@ -369,7 +369,7 @@ 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')
$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]