Skip to content

Commit

Permalink
[APIS-974] Conflict with php new TC & refactoring (#39)
Browse files Browse the repository at this point in the history
* Conflict with php new TC & refactoring

* default port
  • Loading branch information
sjkimxxx authored Sep 25, 2023
1 parent 4de8cf1 commit 802ee27
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 308 deletions.
21 changes: 12 additions & 9 deletions tests/pdo_042.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ PDO::cubrid_schema
if (!extension_loaded("pdo")) die("skip");
require_once 'pdo_test.inc';
PDOTest::skip();

if (!extension_loaded("pdo")) die("skip");
require_once 'pdo_synonym_test.inc';
PDOSynonymTest::skip();
?>
--FILE--
<?php

require_once 'pdo_synonym_test.inc';
$syn_db = PDOSynonymTest::factory();

require_once 'pdo_test.inc';
$db = PDOTest::factory();

$db->exec('CREATE USER u1');
$db->exec('CREATE TABLE u1.t1(col1 int, col2 varchar(10), col3 double)');
$db->exec('Grant SELECT ON u1.t1 TO dba;');
$db->exec('CREATE synonym dba.s1 for u1.t1');

$pk_list = $db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "s1", "col1");
var_dump($pk_list);

Expand All @@ -31,9 +29,14 @@ var_dump($pk_list);
$pk_list = $db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "dba.s%", "col1%");
var_dump($pk_list);

$u1_db = PDOSynonymTest::user_factory();
$u1_db = PDOTest::user_factory();
$pk_list = $u1_db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "s1", "col1");
var_dump($pk_list);
$u1_db = null;

$db->exec('drop synonym if exists dba.s1');
$db->exec('drop table if EXISTS u1.t1');
$db->exec('DROP USER u1');

?>
--EXPECTF--
Expand Down Expand Up @@ -201,4 +204,4 @@ array(3) {
array(0) {
}
array(0) {
}
}
93 changes: 0 additions & 93 deletions tests/pdo_synonym_test.inc

This file was deleted.

28 changes: 28 additions & 0 deletions tests/pdo_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,33 @@ class PDOTest {
}
return self::factory();
}

static function user_factory($classname = 'PDO', $drop_test_tables = true) {
$dsn = 'cubrid:host=localhost;port=33000;dbname=demodb';
$user = 'u1';
$pass = '';
$attr = NULL;

if (is_string($attr) && strlen($attr)) {
$attr = unserialize($attr);
} else {
$attr = null;
}

if ($user === false) $user = NULL;
if ($pass === false) $pass = NULL;

$db = new $classname($dsn, $user, $pass, $attr);

if (!$db) {
die("Could not create PDO object (DSN=$dsn, user=$user)\n");
}

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

return $db;
}
}
?>
21 changes: 12 additions & 9 deletions tests_7/pdo_042.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ PDO::cubrid_schema
if (!extension_loaded("pdo")) die("skip");
require_once 'pdo_test.inc';
PDOTest::skip();

if (!extension_loaded("pdo")) die("skip");
require_once 'pdo_synonym_test.inc';
PDOSynonymTest::skip();
?>
--FILE--
<?php

require_once 'pdo_synonym_test.inc';
$syn_db = PDOSynonymTest::factory();

require_once 'pdo_test.inc';
$db = PDOTest::factory();

$db->exec('CREATE USER u1');
$db->exec('CREATE TABLE u1.t1(col1 int, col2 varchar(10), col3 double)');
$db->exec('Grant SELECT ON u1.t1 TO dba;');
$db->exec('CREATE synonym dba.s1 for u1.t1');

$pk_list = $db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "s1", "col1");
var_dump($pk_list);

Expand All @@ -31,9 +29,14 @@ var_dump($pk_list);
$pk_list = $db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "dba.s%", "col1%");
var_dump($pk_list);

$u1_db = PDOSynonymTest::user_factory();
$u1_db = PDOTest::user_factory();
$pk_list = $u1_db->cubrid_schema(PDO::CUBRID_SCH_ATTR_WITH_SYNONYM, "s1", "col1");
var_dump($pk_list);
$u1_db = null;

$db->exec('drop synonym if exists dba.s1');
$db->exec('drop table if EXISTS u1.t1');
$db->exec('DROP USER u1');

?>
--EXPECTF--
Expand Down Expand Up @@ -201,4 +204,4 @@ array(3) {
array(0) {
}
array(0) {
}
}
94 changes: 0 additions & 94 deletions tests_7/pdo_synonym_test.inc

This file was deleted.

28 changes: 28 additions & 0 deletions tests_7/pdo_test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,33 @@ class PDOTest {
}
return self::factory();
}

static function user_factory($classname = 'PDO', $drop_test_tables = true) {
$dsn = 'cubrid:host=localhost;port=33000;dbname=demodb';
$user = 'u1';
$pass = '';
$attr = NULL;

if (is_string($attr) && strlen($attr)) {
$attr = unserialize($attr);
} else {
$attr = null;
}

if ($user === false) $user = NULL;
if ($pass === false) $pass = NULL;

$db = new $classname($dsn, $user, $pass, $attr);

if (!$db) {
die("Could not create PDO object (DSN=$dsn, user=$user)\n");
}

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

return $db;
}
}
?>
Loading

0 comments on commit 802ee27

Please sign in to comment.