test fixups
[m6w6/pq-gateway] / tests / setup.inc
index 38dff5a3202f8000bab1758803696d6c235127b4..47998cf7353c1c7b40c877f66285cd6f4a9945f1 100644 (file)
@@ -2,7 +2,7 @@
 
 const PQ_TEST_DSN = "";
 
-const PQ_TEST_TABLE_CREATE = <<<SQL
+const PQ_TEST_SETUP_SQL = <<<SQL
        drop table if exists test cascade;
        create table test (
                id serial primary key, 
@@ -10,26 +10,14 @@ const PQ_TEST_TABLE_CREATE = <<<SQL
                counter int, 
                number decimal, 
                data text
-       )
-SQL;
-
-const PQ_TEST_TABLE_DROP = <<<SQL
-       drop table if exists test cascade;
-SQL;
-
-const PQ_TEST_REFTABLE_CREATE = <<<SQL
+       );
+       
        drop table if exists reftest cascade;
        create table reftest (
                test_id integer not null references test on delete cascade,
                another_test_id integer not null references test on delete cascade
        );
-SQL;
-
-const PQ_TEST_REFTABLE_DROP = <<<SQL
-       drop table if exists reftest cascade;
-SQL;
-
-const PQ_TEST_DATA = <<<SQL
+       
        insert into test values (default, 'yesterday', -1, -1.1, 'yesterday');
        insert into test values (default, 'today', 0, 0, 'today');
        insert into test values (default, 'tomorrow', 1, 1.1, 'tomorrow');
@@ -39,9 +27,12 @@ const PQ_TEST_DATA = <<<SQL
        insert into reftest values (3,1);
 SQL;
 
-spl_autoload_register(function($c) {
-       if (substr($c,0,3) == "pq\\") return require_once sprintf("%s/../lib/%s.php", __DIR__, strtr($c, "\\", "/"));
-});
+const PQ_TEST_TEARDOWN_SQL = <<<SQL
+       drop table if exists test cascade;
+       drop table if exists reftest cascade;
+SQL;
+
+include_once __DIR__ . "/../lib/autoload.php";
 
 function executeInConcurrentTransaction(\pq\Query\ExecutorInterface $exec, $sql, array $params = null) {
        $conn = $exec->getConnection();