Skip to content

Commit

Permalink
remove unused tests and make new tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
anovsiradj committed Apr 14, 2019
1 parent aa3ffcc commit b0636e3
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/vendor/
/composer.lock

/tests/*.db
27 changes: 8 additions & 19 deletions tests/cfg.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* There is no `$active_group` option, this library will choose first index (in this example, it was `mysql-1`).
* `$query_builder` option is always `true`, that was the purpose of this library.
*
* @return array
*
*/

return array(
Expand All @@ -31,33 +33,20 @@
'failover' => array(),
'save_queries' => TRUE
),
'firebird-1' => array(
'dsn' => '',
'firebirdsql' => array(
'hostname' => 'localhost',
'username' => 'sysdba',
'password' => 'masterkey',
'database' => '/var/www/database/firebird/ci3db_test.fdb',
'database' => 'employee',
'dbdriver' => 'ibase',
'dbprefix' => '',
'pconnect' => TRUE,
'db_debug' => true,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
)
'pconnect' => true,
),
);

/**
* default CodeIgniter3 database config file format.
* example CodeIgniter3 default database config file.
*
* @link https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/database.php
* @see https://github.com/bcit-ci/CodeIgniter/blob/develop/application/config/database.php
*
*/
$active_group = 'db-1';
Expand Down
20 changes: 0 additions & 20 deletions tests/connect-failed.php

This file was deleted.

19 changes: 0 additions & 19 deletions tests/connect.php

This file was deleted.

27 changes: 0 additions & 27 deletions tests/create.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/delete.php

This file was deleted.

52 changes: 52 additions & 0 deletions tests/firebirdsql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
define('BASEPATH', __DIR__ . '/../vendor/codeigniter/framework/system/'); // endslash!

/* LI-V3.0.4.33054 Firebird 3.0 (superserver) */

$ci3db =& anovsiradj\CI3DataBase::init();
$ci3db->set_db_config_file(__DIR__ . '/cfg.php');

$dsn = 'ibase://sysdba:masterkey@localhost/employee?pconnect=true';
$ci3db->set_db_config('firebirdsql-dsn', $dsn);

try {
// throw new Exception('${ibase_errmsg}', 1);

/**
* cannot using $db0 and $db1
* @see https://bugs.php.net/bug.php?id=72175
*/
$db =& $ci3db->db('firebirdsql');
// $db =& $ci3db->db('firebirdsql-dsn');

} catch (\Exception $e) {
echo 'can\'t firebirdsql.', PHP_EOL, $e->getMessage(), PHP_EOL;
die();
}

$db->trans_start();
if ($db->query('SELECT 1 FROM rdb$relations WHERE rdb$relation_name = UPPER(\'ci3db_tests\')')->num_rows() < 1) {
$db->query('
CREATE TABLE ci3db_tests(
k INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
v BLOB SUB_TYPE TEXT
)
');
}
$db->trans_complete();

$db->insert(strtoupper('ci3db_tests'), [strtoupper('v') => 'lorem ipsum']);
$db->insert(strtoupper('ci3db_tests'), [strtoupper('v') => 'anovsiradj']);
$db->insert(strtoupper('ci3db_tests'), [strtoupper('v') => 'foo bar']);

$q = $db->from(strtoupper('ci3db_tests'))->get();
dump(
$q->num_rows(),
$q->first_row(),
$q->last_row()
);

$db->simple_query('DROP TABLE ci3db_tests');

$db->close();
7 changes: 0 additions & 7 deletions tests/sqlite3-read-fake-table.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/sqlite3-read.php

This file was deleted.

43 changes: 43 additions & 0 deletions tests/sqlite3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
define('BASEPATH', __DIR__ . '/../vendor/codeigniter/framework/system/'); // endslash!

$ci3db =& \anovsiradj\CI3DataBase::init();
$ci3db->set_db_config('sqlite3', [
'dbdriver' => 'sqlite3',
'database' => (__DIR__ . '/sqlite3.db'),
]);

$dsn = 'sqlite3://whatever/' . __DIR__ . '/sqlite3.db';
$ci3db->set_db_config('sqlite3-dsn', $dsn);

try {
// throw new Exception('${sqlite_error_string}', 1);
$db0 =& $ci3db->db('sqlite3');
$db1 =& $ci3db->db('sqlite3-dsn');
} catch (\Exception $e) {
echo 'can\'t sqlite3.', PHP_EOL, $e->getMessage(), PHP_EOL;
die();
}

$db0->simple_query('CREATE TABLE IF NOT EXISTS ci3db_tests(k integer PRIMARY KEY AUTOINCREMENT, v TEXT)');

$db1->insert('ci3db_tests', ['v' => 'lorem ipsum']);
dump($db1->insert_id());

$db0->set('v', 'foo bar')->update('ci3db_tests');
dump($db0->affected_rows());

$q = $db1->from('ci3db_tests')->get();
dump(
$q->num_rows(),
$q->row()
);

$q = $db0->where('k !=', null)->delete('ci3db_tests');
dump( $q, $db0->affected_rows() );

$db1->simple_query('DROP TABLE ci3db_tests');

$db0->close();
$db1->close();
37 changes: 0 additions & 37 deletions tests/update.php

This file was deleted.

4 changes: 0 additions & 4 deletions tests/whoops.php

This file was deleted.

0 comments on commit b0636e3

Please sign in to comment.