1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
class DB_test extends CI_TestCase {
public function test_db_invalid()
{
$connection = new Mock_Database_DB(array(
'undefined' => array(
'dsn' => '',
'hostname' => 'undefined',
'username' => 'undefined',
'password' => 'undefined',
'database' => 'undefined',
'dbdriver' => 'undefined',
),
));
$this->setExpectedException('RuntimeException', 'CI Error: Invalid DB driver');
Mock_Database_DB::DB($connection->set_dsn('undefined'), TRUE);
}
// ------------------------------------------------------------------------
public function test_db_valid()
{
$config = Mock_Database_DB::config(DB_DRIVER);
$connection = new Mock_Database_DB($config);
// E_DEPRECATED notices thrown by mysql_connect(), mysql_pconnect()
// on PHP 5.5+ cause the tests to fail
if (DB_DRIVER === 'mysql' && version_compare(PHP_VERSION, '5.5', '>='))
{
error_reporting(E_ALL & ~E_DEPRECATED);
}
$db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE);
$this->assertInstanceOf('CI_DB', $db);
$this->assertInstanceOf('CI_DB_Driver', $db);
}
// ------------------------------------------------------------------------
/*
This test is unusable, because whoever wrote it apparently thought that
an E_WARNING should equal an Exception and based the whole test suite
around that bogus assumption.
public function test_db_failover()
{
$config = Mock_Database_DB::config(DB_DRIVER);
$connection = new Mock_Database_DB($config);
$db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER.'_failover'), TRUE);
$this->assertInstanceOf('CI_DB', $db);
$this->assertInstanceOf('CI_DB_Driver', $db);
}
*/
}
|