2012-12-04 16:29:37 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
2014-05-27 20:18:06 +02:00
|
|
|
* This file is part of the phpBB Forum Software package.
|
|
|
|
*
|
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see
|
|
|
|
* the docs/CREDITS.txt file.
|
2012-12-04 16:29:37 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class phpbb_dbal_connect_test extends phpbb_database_test_case
|
|
|
|
{
|
|
|
|
public function getDataSet()
|
|
|
|
{
|
|
|
|
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_failing_connect()
|
|
|
|
{
|
2015-03-12 00:25:00 +01:00
|
|
|
global $phpbb_root_path, $phpEx, $phpbb_filesystem;
|
|
|
|
|
|
|
|
$phpbb_filesystem = new phpbb\filesystem\filesystem();
|
2012-12-04 16:29:37 -05:00
|
|
|
|
|
|
|
$config = $this->get_database_config();
|
|
|
|
|
2012-12-13 08:09:32 -05:00
|
|
|
$db = new $config['dbms']();
|
2012-12-04 16:29:37 -05:00
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
|
|
|
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
|
|
|
|
$this->assertFalse(true);
|
2012-12-04 21:22:33 -05:00
|
|
|
}
|
|
|
|
catch (Exception $e)
|
2012-12-04 16:29:37 -05:00
|
|
|
{
|
|
|
|
// should have a legitimate message
|
|
|
|
$this->assertNotEmpty($e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|