Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117877718
DBPgsql.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
DBPgsql.php
View Options
<?php
/**
* Test class to test rcube_db_pgsql class
*
* @package Tests
* @group database
* @group postgres
*/
class
Framework_DBPgsql
extends
PHPUnit\Framework\TestCase
{
/**
* Class constructor
*/
function
test_class
()
{
$object
=
new
rcube_db_pgsql
(
'test'
);
$this
->
assertInstanceOf
(
'rcube_db_pgsql'
,
$object
,
"Class constructor"
);
}
/**
* Test script execution and table_prefix replacements when the prefix is a schema prefix
*/
function
test_exec_script_schema_prefix
()
{
$db
=
rcube_db
::
factory
(
'pgsql:test'
);
$db
->
set_option
(
'table_prefix'
,
'prefix.'
);
$script
=
[
"CREATE TABLE `xxx` (test int, INDEX xxx (test))"
,
"ALTER TABLE `xxx` CHANGE test test int"
,
"TRUNCATE xxx"
,
"TRUNCATE TABLE xxx"
,
"DROP TABLE `vvv`"
,
"CREATE TABLE `i` (test int CONSTRAINT `iii`
FOREIGN KEY (`test`) REFERENCES `xxx`(`test`) ON DELETE CASCADE ON UPDATE CASCADE)"
,
"CREATE TABLE `i` (`test` int, INDEX `testidx` (`test`))"
,
"CREATE TABLE `i` (`test` int, UNIQUE `testidx` (`test`))"
,
"CREATE TABLE `i` (`test` int, UNIQUE INDEX `testidx` (`test`))"
,
"INSERT INTO xxx test = 1"
,
"SELECT test FROM xxx"
,
"CREATE SEQUENCE users_seq INCREMENT BY 1"
,
"CREATE TABLE users ( user_id integer DEFAULT nextval('users_seq'::text) PRIMARY KEY )"
,
"ALTER SEQUENCE user_ids RENAME TO users_seq"
,
];
$output
=
[
"CREATE TABLE `prefix`.`xxx` (test int, INDEX xxx (test))"
,
"ALTER TABLE `prefix`.`xxx` CHANGE test test int"
,
"TRUNCATE prefix.xxx"
,
"TRUNCATE TABLE prefix.xxx"
,
"DROP TABLE `prefix`.`vvv`"
,
"CREATE TABLE `prefix`.`i` (test int CONSTRAINT `iii`
FOREIGN KEY (`test`) REFERENCES `prefix`.`xxx`(`test`) ON DELETE CASCADE ON UPDATE CASCADE)"
,
"CREATE TABLE `prefix`.`i` (`test` int, INDEX `testidx` (`test`))"
,
"CREATE TABLE `prefix`.`i` (`test` int, UNIQUE `testidx` (`test`))"
,
"CREATE TABLE `prefix`.`i` (`test` int, UNIQUE INDEX `testidx` (`test`))"
,
"INSERT INTO prefix.xxx test = 1"
,
"SELECT test FROM prefix.xxx"
,
"CREATE SEQUENCE prefix.users_seq INCREMENT BY 1"
,
"CREATE TABLE prefix.users ( user_id integer DEFAULT nextval('prefix.users_seq'::text) PRIMARY KEY )"
,
"ALTER SEQUENCE prefix.user_ids RENAME TO prefix.users_seq"
,
];
$method
=
new
ReflectionMethod
(
'rcube_db_pgsql'
,
'fix_table_names'
);
$method
->
setAccessible
(
true
);
foreach
(
$script
as
$idx
=>
$query
)
{
$res
=
$method
->
invoke
(
$db
,
$query
);
$this
->
assertSame
(
$output
[
$idx
],
$res
,
"Test case $idx"
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Apr 5, 9:37 PM (3 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1f/52/e187ce6412c21cef2a99ad8860a2
Default Alt Text
DBPgsql.php (2 KB)
Attached To
Mode
R113 roundcubemail
Attached
Detach File
Event Timeline