summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWes Baker <wes@wesbaker.com>2012-05-07 22:49:33 +0200
committerWes Baker <wes@wesbaker.com>2012-05-07 22:49:33 +0200
commitd348135ed2131e5fa41dfa0ea7254d2f6759f3e0 (patch)
tree14cfc61c47686b895acd9e49b45c559d311195cc /tests
parentbb2c83bddbf51c42815be3de60eab24fd87ae392 (diff)
parentd207c9218531afe666168c1f5f59abd1bc19a8aa (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop
Conflicts: system/core/Security.php
Diffstat (limited to 'tests')
-rw-r--r--tests/codeigniter/database/DB_driver_test.php36
-rw-r--r--tests/codeigniter/database/query_builder/.gitkeep0
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php53
-rw-r--r--tests/codeigniter/database/query_builder/insert_test.php67
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php95
-rw-r--r--tests/mocks/autoloader.php15
-rwxr-xr-xtests/mocks/database/ci_test.sqlitebin17408 -> 17408 bytes
-rw-r--r--tests/mocks/database/config/pdo/mysql.php37
-rw-r--r--tests/mocks/database/config/pdo/pgsql.php37
-rw-r--r--tests/mocks/database/config/pdo/sqlite.php37
-rw-r--r--tests/mocks/database/config/sqlite.php9
-rw-r--r--tests/mocks/database/db.php17
-rw-r--r--tests/mocks/database/db/driver.php36
-rw-r--r--tests/mocks/database/db/querybuilder.php10
-rw-r--r--tests/mocks/database/drivers/mysql.php16
-rw-r--r--tests/mocks/database/drivers/pdo.php16
-rw-r--r--tests/mocks/database/drivers/postgre.php16
-rw-r--r--tests/mocks/database/drivers/sqlite.php16
-rw-r--r--tests/mocks/database/schema/.gitkeep0
-rw-r--r--tests/mocks/database/schema/skeleton.php98
-rw-r--r--tests/travis/mysql.phpunit.xml5
-rw-r--r--tests/travis/pdo/mysql.phpunit.xml32
-rw-r--r--tests/travis/pdo/pgsql.phpunit.xml32
-rw-r--r--tests/travis/pdo/sqlite.phpunit.xml32
-rw-r--r--tests/travis/pgsql.phpunit.xml5
-rw-r--r--tests/travis/sqlite.phpunit.xml5
26 files changed, 691 insertions, 31 deletions
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
new file mode 100644
index 000000000..fb40f0608
--- /dev/null
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -0,0 +1,36 @@
+<?php
+
+class DB_driver_test extends CI_TestCase {
+
+ // ------------------------------------------------------------------------
+
+ public function test_initialize()
+ {
+ $config = Mock_Database_DB::config(DB_DRIVER);
+ $driver_name = current(explode('/', DB_DRIVER));
+ $driver = $this->$driver_name($config[DB_DRIVER]);
+
+ $this->assertTrue($driver->initialize());
+ }
+
+ protected function pdo($config)
+ {
+ return new Mock_Database_Drivers_PDO($config);
+ }
+
+ protected function mysql($config)
+ {
+ return new Mock_Database_Drivers_Mysql($config);
+ }
+
+ protected function sqlite($config)
+ {
+ return new Mock_Database_Drivers_Sqlite($config);
+ }
+
+ protected function pgsql($config)
+ {
+ return new Mock_Database_Drivers_Postgre($config);
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/.gitkeep b/tests/codeigniter/database/query_builder/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/codeigniter/database/query_builder/.gitkeep
+++ /dev/null
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
new file mode 100644
index 000000000..0751c9332
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/get_test.php
@@ -0,0 +1,53 @@
+<?php
+
+class Get_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ */
+ protected $db;
+
+ public function set_up()
+ {
+ $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_get_simple()
+ {
+ $jobs = $this->db->get('job')->result_array();
+
+ // Dummy jobs contain 4 rows
+ $this->assertCount(4, $jobs);
+
+ // Check rows item
+ $this->assertEquals('Developer', $jobs[0]['name']);
+ $this->assertEquals('Politician', $jobs[1]['name']);
+ $this->assertEquals('Accountant', $jobs[2]['name']);
+ $this->assertEquals('Musician', $jobs[3]['name']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_get_where()
+ {
+ $job1 = $this->db->get('job', array('id' => 1))->result_array();
+
+ // Dummy jobs contain 1 rows
+ $this->assertCount(1, $job1);
+
+ // Check rows item
+ $this->assertEquals('Developer', $job1[0]['name']);
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/insert_test.php b/tests/codeigniter/database/query_builder/insert_test.php
new file mode 100644
index 000000000..53ce23c19
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/insert_test.php
@@ -0,0 +1,67 @@
+<?php
+
+class Insert_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ * @see ./mocks/schema/skeleton.php
+ */
+ protected $db;
+
+ public function set_up()
+ {
+ $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+
+ // Truncate the current datas
+ $this->db->truncate('job');
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_insert()
+ {
+ $job_data = array('id' => 1, 'name' => 'Grocery Sales', 'description' => 'Discount!');
+
+ // Do normal insert
+ $this->assertTrue($this->db->insert('job', $job_data));
+
+ $jobs = $this->db->get('job')->result_array();
+ $job1 = $jobs[0];
+
+ // Check the result
+ $this->assertEquals('Grocery Sales', $job1['name']);
+
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_insert_batch()
+ {
+ $job_datas = array(
+ array('id' => 2, 'name' => 'Commedian', 'description' => 'Theres something in your teeth'),
+ array('id' => 3, 'name' => 'Cab Driver', 'description' => 'Iam yellow'),
+ );
+
+ // Do insert batch except for sqlite driver
+ if (strpos(DB_DRIVER, 'sqlite') === FALSE)
+ {
+ $this->assertTrue($this->db->insert_batch('job', $job_datas));
+
+ $job_2 = $this->db->where('id', 2)->get('job')->row();
+ $job_3 = $this->db->where('id', 3)->get('job')->row();
+
+ // Check the result
+ $this->assertEquals('Commedian', $job_2->name);
+ $this->assertEquals('Cab Driver', $job_3->name);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
new file mode 100644
index 000000000..dbf432a7c
--- /dev/null
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -0,0 +1,95 @@
+<?php
+
+class Select_test extends CI_TestCase {
+
+ /**
+ * @var object Database/Query Builder holder
+ */
+ protected $db;
+
+ public function set_up()
+ {
+ $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
+
+ Mock_Database_Schema_Skeleton::create_tables();
+ Mock_Database_Schema_Skeleton::create_data();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_only_one_collumn()
+ {
+ $jobs_name = $this->db->select('name')
+ ->get('job')
+ ->result_array();
+
+ // Check rows item
+ $this->assertArrayHasKey('name',$jobs_name[0]);
+ $this->assertFalse(array_key_exists('id', $jobs_name[0]));
+ $this->assertFalse(array_key_exists('description', $jobs_name[0]));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_min()
+ {
+ $job_min = $this->db->select_min('id')
+ ->get('job')
+ ->result_array();
+
+ // Minimum id was 1
+ $this->assertEquals('1', $job_min[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_max()
+ {
+ $job_max = $this->db->select_max('id')
+ ->get('job')
+ ->result_array();
+
+ // Maximum id was 4
+ $this->assertEquals('4', $job_max[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_avg()
+ {
+ $job_avg = $this->db->select_avg('id')
+ ->get('job')
+ ->result_array();
+
+ // Average should be 2.5
+ $this->assertEquals('2.5', $job_avg[0]['id']);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * @see ./mocks/schema/skeleton.php
+ */
+ public function test_select_sum()
+ {
+ $job_sum = $this->db->select_sum('id')
+ ->get('job')
+ ->result_array();
+
+ // Sum of ids should be 10
+ $this->assertEquals('10', $job_sum[0]['id']);
+ }
+
+} \ No newline at end of file
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index dd5929206..f1bdb5d6f 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -53,13 +53,24 @@ function autoload($class)
$dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR;
$class = $subclass;
}
+ elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3)
+ {
+ $driver_path = BASEPATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR;
+ $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR;
+ $file = $dir.$m[1].'_'.$m[2].'.php';
+ }
+ elseif (strpos($class, 'CI_DB') === 0)
+ {
+ $dir = BASEPATH.'database'.DIRECTORY_SEPARATOR;
+ $file = $dir.str_replace(array('CI_DB','active_record'), array('DB', 'active_rec'), $subclass).'.php';
+ }
else
{
$class = strtolower($class);
}
}
- $file = $dir.$class.'.php';
+ $file = (isset($file)) ? $file : $dir.$class.'.php';
if ( ! file_exists($file))
{
@@ -71,7 +82,7 @@ function autoload($class)
{
return FALSE;
}
-
+
throw new InvalidArgumentException("Unable to load $class.");
}
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 37ce4f870..86d868af2 100755
--- a/tests/mocks/database/ci_test.sqlite
+++ b/tests/mocks/database/ci_test.sqlite
Binary files differ
diff --git a/tests/mocks/database/config/pdo/mysql.php b/tests/mocks/database/config/pdo/mysql.php
new file mode 100644
index 000000000..cefb6b008
--- /dev/null
+++ b/tests/mocks/database/config/pdo/mysql.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+
+ // Typical Database configuration
+ 'pdo/mysql' => array(
+ 'dsn' => '',
+ 'hostname' => 'localhost',
+ 'username' => 'travis',
+ 'password' => '',
+ 'database' => 'ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'mysql',
+ ),
+
+ // Database configuration with failover
+ 'pdo/mysql_failover' => array(
+ 'dsn' => '',
+ 'hostname' => 'localhost',
+ 'username' => 'not_travis',
+ 'password' => 'wrong password',
+ 'database' => 'not_ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'mysql',
+ 'failover' => array(
+ array(
+ 'dsn' => '',
+ 'hostname' => 'localhost',
+ 'username' => 'travis',
+ 'password' => '',
+ 'database' => 'ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'mysql',
+ ),
+ ),
+ ),
+); \ No newline at end of file
diff --git a/tests/mocks/database/config/pdo/pgsql.php b/tests/mocks/database/config/pdo/pgsql.php
new file mode 100644
index 000000000..5196e9ad9
--- /dev/null
+++ b/tests/mocks/database/config/pdo/pgsql.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+
+ // Typical Database configuration
+ 'pdo/pgsql' => array(
+ 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
+ 'hostname' => 'localhost',
+ 'username' => 'postgres',
+ 'password' => '',
+ 'database' => 'ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'pgsql',
+ ),
+
+ // Database configuration with failover
+ 'pdo/pgsql_failover' => array(
+ 'dsn' => '',
+ 'hostname' => 'localhost',
+ 'username' => 'not_travis',
+ 'password' => 'wrong password',
+ 'database' => 'not_ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'pgsql',
+ 'failover' => array(
+ array(
+ 'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
+ 'hostname' => 'localhost',
+ 'username' => 'postgres',
+ 'password' => '',
+ 'database' => 'ci_test',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'pgsql',
+ ),
+ ),
+ ),
+); \ No newline at end of file
diff --git a/tests/mocks/database/config/pdo/sqlite.php b/tests/mocks/database/config/pdo/sqlite.php
new file mode 100644
index 000000000..c68b4b213
--- /dev/null
+++ b/tests/mocks/database/config/pdo/sqlite.php
@@ -0,0 +1,37 @@
+<?php
+
+return array(
+
+ // Typical Database configuration
+ 'pdo/sqlite' => array(
+ 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite',
+ 'hostname' => 'localhost',
+ 'username' => 'sqlite',
+ 'password' => 'sqlite',
+ 'database' => 'sqlite',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'sqlite',
+ ),
+
+ // Database configuration with failover
+ 'pdo/sqlite_failover' => array(
+ 'dsn' => 'sqlite:not_exists.sqlite',
+ 'hostname' => 'localhost',
+ 'username' => 'sqlite',
+ 'password' => 'sqlite',
+ 'database' => 'sqlite',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'sqlite',
+ 'failover' => array(
+ array(
+ 'dsn' => 'sqlite:/'.realpath(__DIR__.'/../..').'/ci_test.sqlite',
+ 'hostname' => 'localhost',
+ 'username' => 'sqlite',
+ 'password' => 'sqlite',
+ 'database' => 'sqlite',
+ 'dbdriver' => 'pdo',
+ 'pdodriver' => 'sqlite',
+ ),
+ ),
+ ),
+); \ No newline at end of file
diff --git a/tests/mocks/database/config/sqlite.php b/tests/mocks/database/config/sqlite.php
index 8665e208d..755ce2a3a 100644
--- a/tests/mocks/database/config/sqlite.php
+++ b/tests/mocks/database/config/sqlite.php
@@ -1,5 +1,4 @@
<?php
-$dbdriver = is_php('5.4') ? 'sqlite3' : 'sqlite';
return array(
@@ -10,7 +9,7 @@ return array(
'username' => 'sqlite',
'password' => 'sqlite',
'database' => realpath(__DIR__.'/..').'/ci_test.sqlite',
- 'dbdriver' => $dbdriver,
+ 'dbdriver' => 'sqlite3',
),
// Database configuration with failover
@@ -20,15 +19,15 @@ return array(
'username' => 'sqlite',
'password' => 'sqlite',
'database' => '../not_exists.sqlite',
- 'dbdriver' => $dbdriver,
+ 'dbdriver' => 'sqlite3',
'failover' => array(
array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'sqlite',
'password' => 'sqlite',
- 'database' => realpath(__DIR__.'/..').'/ci_testf.sqlite',
- 'dbdriver' => $dbdriver,
+ 'database' => realpath(__DIR__.'/..').'/ci_test.sqlite',
+ 'dbdriver' => 'sqlite3',
),
),
),
diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php
index 43a0d391f..59028ed9c 100644
--- a/tests/mocks/database/db.php
+++ b/tests/mocks/database/db.php
@@ -45,19 +45,18 @@ class Mock_Database_DB {
);
$config = array_merge($this->config[$group], $params);
+ $dsnstring = ( ! empty($config['dsn'])) ? $config['dsn'] : FALSE;
+ $pdodriver = ( ! empty($config['pdodriver'])) ? $config['pdodriver'] : FALSE;
+ $failover = ( ! empty($config['failover'])) ? $config['failover'] : FALSE;
- if ( ! empty($config['dsn']))
- {
- $dsn = $config['dsn'];
- }
- else
- {
- $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password']
+ $dsn = $config['dbdriver'].'://'.$config['username'].':'.$config['password']
.'@'.$config['hostname'].'/'.$config['database'];
- }
-
+ // Build the parameter
$other_params = array_slice($config, 6);
+ if ($dsnstring) $other_params['dsn'] = $dsnstring;
+ if ($pdodriver) $other_params['pdodriver'] = $pdodriver;
+ if ($failover) $other_params['failover'] = $failover;
return $dsn.'?'.http_build_query($other_params);
}
diff --git a/tests/mocks/database/db/driver.php b/tests/mocks/database/db/driver.php
new file mode 100644
index 000000000..cb1820277
--- /dev/null
+++ b/tests/mocks/database/db/driver.php
@@ -0,0 +1,36 @@
+<?php
+
+class Mock_Database_DB_Driver extends CI_DB_driver {
+
+ /**
+ * @var object The actual Driver
+ */
+ protected $ci_db_driver;
+
+ /**
+ * Instantiate the database driver
+ *
+ * @param string DB Driver class name
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($driver_class, $config = array())
+ {
+ if (is_string($driver_class)) $this->ci_db_driver = new $driver_class($config);
+ }
+
+ /**
+ * Overloading method, emulate the actual driver method (multiple inheritance workaround)
+ */
+ public function __call($method, $arguments)
+ {
+ if ( ! is_callable(array($this->ci_db_driver, $method)))
+ {
+ throw new BadMethodCallException($method. ' not exists or not implemented');
+ }
+
+ return call_user_func_array(array($this->ci_db_driver, $method), $arguments);
+ }
+}
+
+class CI_DB extends Mock_Database_DB_QueryBuilder {} \ No newline at end of file
diff --git a/tests/mocks/database/db/querybuilder.php b/tests/mocks/database/db/querybuilder.php
new file mode 100644
index 000000000..1b95c92af
--- /dev/null
+++ b/tests/mocks/database/db/querybuilder.php
@@ -0,0 +1,10 @@
+<?php
+
+if ( ! class_exists('CI_DB_query_builder'))
+{
+ class Mock_Database_DB_QueryBuilder extends CI_DB_active_record {}
+}
+else
+{
+ class Mock_Database_DB_QueryBuilder extends CI_DB_query_builder {}
+}
diff --git a/tests/mocks/database/drivers/mysql.php b/tests/mocks/database/drivers/mysql.php
new file mode 100644
index 000000000..34a74e2bf
--- /dev/null
+++ b/tests/mocks/database/drivers/mysql.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Mysql extends Mock_Database_DB_Driver {
+
+ /**
+ * Instantiate the database driver
+ *
+ * @param string DB Driver class name
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($config = array())
+ {
+ parent::__construct('CI_DB_mysql_driver', $config);
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/pdo.php b/tests/mocks/database/drivers/pdo.php
new file mode 100644
index 000000000..590e19552
--- /dev/null
+++ b/tests/mocks/database/drivers/pdo.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_PDO extends Mock_Database_DB_Driver {
+
+ /**
+ * Instantiate the database driver
+ *
+ * @param string DB Driver class name
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($config = array())
+ {
+ parent::__construct('CI_DB_pdo_driver', $config);
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/postgre.php b/tests/mocks/database/drivers/postgre.php
new file mode 100644
index 000000000..0df905963
--- /dev/null
+++ b/tests/mocks/database/drivers/postgre.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Postgre extends Mock_Database_DB_Driver {
+
+ /**
+ * Instantiate the database driver
+ *
+ * @param string DB Driver class name
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($config = array())
+ {
+ parent::__construct('CI_DB_postgre_driver', $config);
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php
new file mode 100644
index 000000000..76a182cbf
--- /dev/null
+++ b/tests/mocks/database/drivers/sqlite.php
@@ -0,0 +1,16 @@
+<?php
+
+class Mock_Database_Drivers_Sqlite extends Mock_Database_DB_Driver {
+
+ /**
+ * Instantiate the database driver
+ *
+ * @param string DB Driver class name
+ * @param array DB configuration to set
+ * @return void
+ */
+ public function __construct($config = array())
+ {
+ parent::__construct('CI_DB_sqlite3_driver', $config);
+ }
+} \ No newline at end of file
diff --git a/tests/mocks/database/schema/.gitkeep b/tests/mocks/database/schema/.gitkeep
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/mocks/database/schema/.gitkeep
+++ /dev/null
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
new file mode 100644
index 000000000..a3d5bac65
--- /dev/null
+++ b/tests/mocks/database/schema/skeleton.php
@@ -0,0 +1,98 @@
+<?php
+
+class Mock_Database_Schema_Skeleton {
+
+ /**
+ * @var object Database Holder
+ */
+ public static $db;
+
+ /**
+ * @var object Forge Holder
+ */
+ public static $forge;
+
+ /**
+ * @var object Driver Holder
+ */
+ public static $driver;
+
+ /**
+ * Initialize both database and forge components
+ */
+ public static function init($driver)
+ {
+ if (empty(static::$db) && empty(static::$forge))
+ {
+ $config = Mock_Database_DB::config($driver);
+ $connection = new Mock_Database_DB($config);
+ $db = Mock_Database_DB::DB($connection->set_dsn($driver), TRUE);
+
+ CI_TestCase::instance()->ci_instance_var('db', $db);
+
+ $loader = new Mock_Core_Loader();
+ $loader->dbforge();
+ $forge = CI_TestCase::instance()->ci_instance_var('dbforge');
+
+ static::$db = $db;
+ static::$forge = $forge;
+ static::$driver = $driver;
+ }
+
+ return static::$db;
+ }
+
+
+ /**
+ * Create the dummy tables
+ *
+ * @return void
+ */
+ public static function create_tables()
+ {
+ // Job Table
+ static::$forge->add_field(array(
+ 'id' => array(
+ 'type' => 'INTEGER',
+ 'constraint' => 3,
+ ),
+ 'name' => array(
+ 'type' => 'VARCHAR',
+ 'constraint' => 40,
+ ),
+ 'description' => array(
+ 'type' => 'TEXT',
+ ),
+ ));
+ static::$forge->add_key('id', TRUE);
+ static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE));
+ }
+
+ /**
+ * Create the dummy datas
+ *
+ * @return void
+ */
+ public static function create_data()
+ {
+ // Job Data
+ $data = array(
+ 'job' => array(
+ array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'),
+ array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'),
+ array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'),
+ array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'),
+ ),
+ );
+
+ foreach ($data as $table => $dummy_data)
+ {
+ static::$db->truncate($table);
+
+ foreach ($dummy_data as $single_dummy_data)
+ {
+ static::$db->insert($table, $single_dummy_data);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index 44d6d6ed9..e9556f758 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -28,10 +28,5 @@
<directory suffix=".php">PROJECT_BASE.'tests'</directory>
<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
</blacklist>
- <whitelist>
- <!--
- <directory suffix=".php">'../system/core'</directory>
- -->
- </whitelist>
</filters>
</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
new file mode 100644
index 000000000..69eece24f
--- /dev/null
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ bootstrap="../../Bootstrap.php"
+ colors="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false">
+ <php>
+ <const name="DB_DRIVER" value="pdo/mysql"/>
+ </php>
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <file>../../codeigniter/Setup_test.php</file>
+ <directory suffix="test.php">../../codeigniter/core</directory>
+ <directory suffix="test.php">../../codeigniter/helpers</directory>
+ <directory suffix="test.php">../../codeigniter/libraries</directory>
+ <directory suffix="test.php">../../codeigniter/database</directory>
+ </testsuite>
+ </testsuites>
+ <filters>
+ <blacklist>
+ <directory suffix=".php">PEAR_INSTALL_DIR</directory>
+ <directory suffix=".php">PHP_LIBDIR</directory>
+ <directory suffix=".php">PROJECT_BASE.'tests'</directory>
+ <directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+ </blacklist>
+ </filters>
+</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
new file mode 100644
index 000000000..e68c3e028
--- /dev/null
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ bootstrap="../../Bootstrap.php"
+ colors="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false">
+ <php>
+ <const name="DB_DRIVER" value="pdo/pgsql"/>
+ </php>
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <file>../../codeigniter/Setup_test.php</file>
+ <directory suffix="test.php">../../codeigniter/core</directory>
+ <directory suffix="test.php">../../codeigniter/helpers</directory>
+ <directory suffix="test.php">../../codeigniter/libraries</directory>
+ <directory suffix="test.php">../../codeigniter/database</directory>
+ </testsuite>
+ </testsuites>
+ <filters>
+ <blacklist>
+ <directory suffix=".php">PEAR_INSTALL_DIR</directory>
+ <directory suffix=".php">PHP_LIBDIR</directory>
+ <directory suffix=".php">PROJECT_BASE.'tests'</directory>
+ <directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+ </blacklist>
+ </filters>
+</phpunit> \ No newline at end of file
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
new file mode 100644
index 000000000..1871f6221
--- /dev/null
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ bootstrap="../../Bootstrap.php"
+ colors="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false">
+ <php>
+ <const name="DB_DRIVER" value="pdo/sqlite"/>
+ </php>
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <file>../../codeigniter/Setup_test.php</file>
+ <directory suffix="test.php">../../codeigniter/core</directory>
+ <directory suffix="test.php">../../codeigniter/helpers</directory>
+ <directory suffix="test.php">../../codeigniter/libraries</directory>
+ <directory suffix="test.php">../../codeigniter/database</directory>
+ </testsuite>
+ </testsuites>
+ <filters>
+ <blacklist>
+ <directory suffix=".php">PEAR_INSTALL_DIR</directory>
+ <directory suffix=".php">PHP_LIBDIR</directory>
+ <directory suffix=".php">PROJECT_BASE.'tests'</directory>
+ <directory suffix=".php">'../../../system/core/CodeIgniter.php'</directory>
+ </blacklist>
+ </filters>
+</phpunit> \ No newline at end of file
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index 9f52b40ae..ad8aeded2 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -28,10 +28,5 @@
<directory suffix=".php">PROJECT_BASE.'tests'</directory>
<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
</blacklist>
- <whitelist>
- <!--
- <directory suffix=".php">'../system/core'</directory>
- -->
- </whitelist>
</filters>
</phpunit> \ No newline at end of file
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 74ebb482b..628370e93 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -28,10 +28,5 @@
<directory suffix=".php">PROJECT_BASE.'tests'</directory>
<directory suffix=".php">'../../system/core/CodeIgniter.php'</directory>
</blacklist>
- <whitelist>
- <!--
- <directory suffix=".php">'../system/core'</directory>
- -->
- </whitelist>
</filters>
</phpunit> \ No newline at end of file