autoload; cache; tests;
[m6w6/pq-gateway] / tests / setup.inc
1 <?php
2
3 const PQ_TEST_DSN = "";
4
5 const PQ_TEST_TABLE_CREATE = <<<SQL
6 drop table if exists test cascade;
7 create table test (
8 id serial primary key,
9 created timestamp,
10 counter int,
11 number decimal,
12 data text
13 )
14 SQL;
15
16 const PQ_TEST_TABLE_DROP = <<<SQL
17 drop table if exists test cascade;
18 SQL;
19
20 const PQ_TEST_REFTABLE_CREATE = <<<SQL
21 drop table if exists reftest cascade;
22 create table reftest (
23 test_id integer not null references test on delete cascade,
24 another_test_id integer not null references test on delete cascade
25 );
26 SQL;
27
28 const PQ_TEST_REFTABLE_DROP = <<<SQL
29 drop table if exists reftest cascade;
30 SQL;
31
32 const PQ_TEST_DATA = <<<SQL
33 insert into test values (default, 'yesterday', -1, -1.1, 'yesterday');
34 insert into test values (default, 'today', 0, 0, 'today');
35 insert into test values (default, 'tomorrow', 1, 1.1, 'tomorrow');
36
37 insert into reftest values (1,3);
38 insert into reftest values (2,2);
39 insert into reftest values (3,1);
40 SQL;
41
42 spl_autoload_register(function($c) {
43 if (substr($c,0,3) == "pq\\") return require_once sprintf("%s/../lib/%s.php", __DIR__, strtr($c, "\\", "/"));
44 });