Skip to content

Commit

Permalink
Merge pull request #99 from frankmayer/improvements_4
Browse files Browse the repository at this point in the history
Improvements #4
  • Loading branch information
mbabker committed Jun 27, 2017
2 parents 6e8bd95 + 3dc5dde commit 99169d1
Show file tree
Hide file tree
Showing 25 changed files with 270 additions and 268 deletions.
2 changes: 1 addition & 1 deletion Tests/DriverMysqliTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ public function testExecutePreparedStatement()
/** @var \Joomla\Database\Mysqli\MysqliQuery $query */
$query = self::$driver->getQuery(true);
$query->setQuery(
"REPLACE INTO `jos_dbtest` SET `id` = ?, `title` = ?, `start_date` = ?, `description` = ?"
'REPLACE INTO `jos_dbtest` SET `id` = ?, `title` = ?, `start_date` = ?, `description` = ?'
);
$query->bind(1, $id, 'i');
$query->bind(2, $title);
Expand Down
59 changes: 30 additions & 29 deletions Tests/DriverPgsqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,29 +402,30 @@ public function testGetTableSequences()
public function testGetTableList()
{
$expected = array(
"0" => "jos_assets",
"1" => "jos_categories",
"2" => "jos_content",
"3" => "jos_core_log_searches",
"4" => "jos_dbtest",
"5" => "jos_extensions",
"6" => "jos_languages",
"7" => "jos_log_entries",
"8" => "jos_menu",
"9" => "jos_menu_types",
"10" => "jos_modules",
"11" => "jos_modules_menu",
"12" => "jos_schemas",
"13" => "jos_session",
"14" => "jos_update_categories",
"15" => "jos_update_sites",
"16" => "jos_update_sites_extensions",
"17" => "jos_updates",
"18" => "jos_user_profiles",
"19" => "jos_user_usergroup_map",
"20" => "jos_usergroups",
"21" => "jos_users",
"22" => "jos_viewlevels");
'0' => 'jos_assets',
'1' => 'jos_categories',
'2' => 'jos_content',
'3' => 'jos_core_log_searches',
'4' => 'jos_dbtest',
'5' => 'jos_extensions',
'6' => 'jos_languages',
'7' => 'jos_log_entries',
'8' => 'jos_menu',
'9' => 'jos_menu_types',
'10' => 'jos_modules',
'11' => 'jos_modules_menu',
'12' => 'jos_schemas',
'13' => 'jos_session',
'14' => 'jos_update_categories',
'15' => 'jos_update_sites',
'16' => 'jos_update_sites_extensions',
'17' => 'jos_updates',
'18' => 'jos_user_profiles',
'19' => 'jos_user_usergroup_map',
'20' => 'jos_usergroups',
'21' => 'jos_users',
'22' => 'jos_viewlevels'
);

$result = self::$driver->getTableList();

Expand Down Expand Up @@ -491,9 +492,9 @@ public function testInsertObject()
self::$driver->setQuery('TRUNCATE TABLE "jos_dbtest"')->execute();

$tst = new \stdClass;
$tst->title = "PostgreSQL test insertObject";
$tst->title = 'PostgreSQL test insertObject';
$tst->start_date = '2012-04-07 15:00:00';
$tst->description = "Test insertObject";
$tst->description = 'Test insertObject';

// Insert object without retrieving key
$ret = self::$driver->insertObject('#__dbtest', $tst);
Expand All @@ -511,9 +512,9 @@ public function testInsertObject()

// Insert object retrieving the key
$tstK = new \stdClass;
$tstK->title = "PostgreSQL test insertObject with key";
$tstK->title = 'PostgreSQL test insertObject with key';
$tstK->start_date = '2012-04-07 15:00:00';
$tstK->description = "Test insertObject with key";
$tstK->description = 'Test insertObject with key';
$retK = self::$driver->insertObject('#__dbtest', $tstK, 'id');

$this->assertThat($tstK->id, $this->equalTo(2), __LINE__);
Expand Down Expand Up @@ -821,10 +822,10 @@ public function testSqlValue()
// Object containing fields of integer, character varying, timestamp and text type
$tst = new \stdClass;
$tst->id = '5';
$tst->charVar = "PostgreSQL test insertObject";
$tst->charVar = 'PostgreSQL test insertObject';
$tst->timeStamp = '2012-04-07 15:00:00';
$tst->nullDate = null;
$tst->txt = "Test insertObject";
$tst->txt = 'Test insertObject';
$tst->boolTrue = true;
$tst->boolFalse = false;
$tst->num = '43.2';
Expand Down
59 changes: 30 additions & 29 deletions Tests/DriverPostgresqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,29 +402,30 @@ public function testGetTableSequences()
public function testGetTableList()
{
$expected = array(
"0" => "jos_assets",
"1" => "jos_categories",
"2" => "jos_content",
"3" => "jos_core_log_searches",
"4" => "jos_dbtest",
"5" => "jos_extensions",
"6" => "jos_languages",
"7" => "jos_log_entries",
"8" => "jos_menu",
"9" => "jos_menu_types",
"10" => "jos_modules",
"11" => "jos_modules_menu",
"12" => "jos_schemas",
"13" => "jos_session",
"14" => "jos_update_categories",
"15" => "jos_update_sites",
"16" => "jos_update_sites_extensions",
"17" => "jos_updates",
"18" => "jos_user_profiles",
"19" => "jos_user_usergroup_map",
"20" => "jos_usergroups",
"21" => "jos_users",
"22" => "jos_viewlevels");
'0' => 'jos_assets',
'1' => 'jos_categories',
'2' => 'jos_content',
'3' => 'jos_core_log_searches',
'4' => 'jos_dbtest',
'5' => 'jos_extensions',
'6' => 'jos_languages',
'7' => 'jos_log_entries',
'8' => 'jos_menu',
'9' => 'jos_menu_types',
'10' => 'jos_modules',
'11' => 'jos_modules_menu',
'12' => 'jos_schemas',
'13' => 'jos_session',
'14' => 'jos_update_categories',
'15' => 'jos_update_sites',
'16' => 'jos_update_sites_extensions',
'17' => 'jos_updates',
'18' => 'jos_user_profiles',
'19' => 'jos_user_usergroup_map',
'20' => 'jos_usergroups',
'21' => 'jos_users',
'22' => 'jos_viewlevels'
);

$result = self::$driver->getTableList();

Expand Down Expand Up @@ -521,9 +522,9 @@ public function testInsertObject()
self::$driver->setQuery('TRUNCATE TABLE "jos_dbtest"')->execute();

$tst = new \stdClass;
$tst->title = "PostgreSQL test insertObject";
$tst->title = 'PostgreSQL test insertObject';
$tst->start_date = '2012-04-07 15:00:00';
$tst->description = "Test insertObject";
$tst->description = 'Test insertObject';

// Insert object without retrieving key
$ret = self::$driver->insertObject('#__dbtest', $tst);
Expand All @@ -541,9 +542,9 @@ public function testInsertObject()

// Insert object retrieving the key
$tstK = new \stdClass;
$tstK->title = "PostgreSQL test insertObject with key";
$tstK->title = 'PostgreSQL test insertObject with key';
$tstK->start_date = '2012-04-07 15:00:00';
$tstK->description = "Test insertObject with key";
$tstK->description = 'Test insertObject with key';
$retK = self::$driver->insertObject('#__dbtest', $tstK, 'id');

$this->assertThat($tstK->id, $this->equalTo(2), __LINE__);
Expand Down Expand Up @@ -851,10 +852,10 @@ public function testSqlValue()
// Object containing fields of integer, character varying, timestamp and text type
$tst = new \stdClass;
$tst->id = '5';
$tst->charVar = "PostgreSQL test insertObject";
$tst->charVar = 'PostgreSQL test insertObject';
$tst->timeStamp = '2012-04-07 15:00:00';
$tst->nullDate = null;
$tst->txt = "Test insertObject";
$tst->txt = 'Test insertObject';
$tst->boolTrue = 't';
$tst->boolFalse = 'f';
$tst->num = '43.2';
Expand Down
18 changes: 9 additions & 9 deletions Tests/ImporterMySqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,21 @@ public function dataGetAlterTableSql()
array(
new \SimpleXmlElement('<table_structure name="#__test">' . $f1 . $f2 . $k1 . $k2 . '</table_structure>'),
array(
"ALTER TABLE `jos_test` ADD UNIQUE KEY `idx_title` (`title`)",
'ALTER TABLE `jos_test` ADD UNIQUE KEY `idx_title` (`title`)',
),
'getAlterTableSQL should add the new key.'
),
array(
new \SimpleXmlElement('<table_structure name="#__test">' . $f1 . $k1 . '</table_structure>'),
array(
"ALTER TABLE `jos_test` DROP COLUMN `title`",
'ALTER TABLE `jos_test` DROP COLUMN `title`',
),
'getAlterTableSQL should remove the title column.'
),
array(
new \SimpleXmlElement('<table_structure name="#__test">' . $f1 . $f2 . '</table_structure>'),
array(
"ALTER TABLE `jos_test` DROP PRIMARY KEY",
'ALTER TABLE `jos_test` DROP PRIMARY KEY',
),
'getAlterTableSQL should drop the old primary key.'
),
Expand Down Expand Up @@ -318,7 +318,7 @@ public function dataGetColumnSql()
new \SimpleXmlElement(
$this->sample['xml-body-field']
),
"`body` mediumtext NOT NULL",
'`body` mediumtext NOT NULL',
'Typical blob field',
),
);
Expand All @@ -341,7 +341,7 @@ public function dataGetKeySql()
$this->sample['xml-primary-key']
),
),
"primary key (`id`)",
'primary key (`id`)',
'Typical primary key index',
),
);
Expand Down Expand Up @@ -540,7 +540,7 @@ public function testGetAddKeySql()
)
),
$this->equalTo(
"ALTER TABLE `jos_test` ADD PRIMARY KEY (`id`)"
'ALTER TABLE `jos_test` ADD PRIMARY KEY (`id`)'
),
'testGetAddKeySQL did not yield the expected result.'
);
Expand Down Expand Up @@ -642,7 +642,7 @@ public function testGetDropColumnSql()
'title'
),
$this->equalTo(
"ALTER TABLE `jos_test` DROP COLUMN `title`"
'ALTER TABLE `jos_test` DROP COLUMN `title`'
),
'getDropColumnSQL did not yield the expected result.'
);
Expand All @@ -666,7 +666,7 @@ public function testGetDropKeySql()
'idx_title'
),
$this->equalTo(
"ALTER TABLE `jos_test` DROP KEY `idx_title`"
'ALTER TABLE `jos_test` DROP KEY `idx_title`'
),
'getDropKeySQL did not yield the expected result.'
);
Expand All @@ -689,7 +689,7 @@ public function testGetDropPrimaryKeySql()
'jos_test'
),
$this->equalTo(
"ALTER TABLE `jos_test` DROP PRIMARY KEY"
'ALTER TABLE `jos_test` DROP PRIMARY KEY'
),
'getDropPrimaryKeySQL did not yield the expected result.'
);
Expand Down
16 changes: 8 additions & 8 deletions Tests/ImporterPgsqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ public function dataGetAlterTableSql()

$addSequence = 'CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 ' .
'NO CYCLE OWNED BY "public.jos_dbtest.title"';
$changeCol = "ALTER TABLE \"jos_test\" ALTER COLUMN \"title\" TYPE character " .
$changeCol = 'ALTER TABLE "jos_test" ALTER COLUMN "title" TYPE character ' .
"varying(50),\nALTER COLUMN \"title\" SET NOT NULL,\nALTER COLUMN \"title\" SET DEFAULT 'add default'";
$changeSeq = "CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 " .
"START 1 NO CYCLE OWNED BY \"public.jos_dbtest.title\"";
$changeSeq = 'CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 ' .
'START 1 NO CYCLE OWNED BY "public.jos_dbtest.title"';

return array(
array(
Expand Down Expand Up @@ -350,7 +350,7 @@ public function dataGetAlterTableSql()
// Drop idx
new \SimpleXmlElement('<table_structure name="#__test">' . $s1 . $f1 . $f2 . $k1 . '</table_structure>'),
array(
"DROP INDEX \"jos_dbtest_idx_name\""
'DROP INDEX "jos_dbtest_idx_name"'
),
'getAlterTableSQL should change sequence.'
),
Expand Down Expand Up @@ -381,14 +381,14 @@ public function dataGetAlterTableSql()
new \SimpleXmlElement('<table_structure name="#__test">' . $s2 . $f1 . $f2 . $k1 . $k2 . '</table_structure>'),
array(
$changeSeq,
"DROP SEQUENCE \"jos_dbtest_id_seq\"",),
'DROP SEQUENCE "jos_dbtest_id_seq"',),
'getAlterTableSQL should change sequence.'
),
array(
// Change idx
new \SimpleXmlElement('<table_structure name="#__test">' . $s1 . $f1 . $f2 . $k1 . $k3 . '</table_structure>'),
array(
"CREATE INDEX jos_dbtest_idx_title ON jos_dbtest USING btree (title)",
'CREATE INDEX jos_dbtest_idx_title ON jos_dbtest USING btree (title)',
'DROP INDEX "jos_dbtest_idx_name"'
),
'getAlterTableSQL should change index.'
Expand Down Expand Up @@ -700,7 +700,7 @@ public function testGetAddIndexSql()
new \SimpleXmlElement($xmlIndex)
),
$this->equalTo(
"CREATE INDEX jos_dbtest_idx_name ON jos_dbtest USING btree (name)"
'CREATE INDEX jos_dbtest_idx_name ON jos_dbtest USING btree (name)'
),
'testGetAddIndexSQL did not yield the expected result.'
);
Expand All @@ -710,7 +710,7 @@ public function testGetAddIndexSql()
new \SimpleXmlElement($xmlPrimaryKey)
),
$this->equalTo(
"ALTER TABLE jos_dbtest ADD PRIMARY KEY (id)"
'ALTER TABLE jos_dbtest ADD PRIMARY KEY (id)'
),
'testGetAddIndexSQL did not yield the expected result.'
);
Expand Down
16 changes: 8 additions & 8 deletions Tests/ImporterPostgresqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ public function dataGetAlterTableSql()

$addSequence = 'CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 ' .
'NO CYCLE OWNED BY "public.jos_dbtest.title"';
$changeCol = "ALTER TABLE \"jos_test\" ALTER COLUMN \"title\" TYPE character " .
$changeCol = 'ALTER TABLE "jos_test" ALTER COLUMN "title" TYPE character ' .
"varying(50),\nALTER COLUMN \"title\" SET NOT NULL,\nALTER COLUMN \"title\" SET DEFAULT 'add default'";
$changeSeq = "CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 " .
"START 1 NO CYCLE OWNED BY \"public.jos_dbtest.title\"";
$changeSeq = 'CREATE SEQUENCE jos_dbtest_title_seq INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 ' .
'START 1 NO CYCLE OWNED BY "public.jos_dbtest.title"';

return array(
array(
Expand Down Expand Up @@ -350,7 +350,7 @@ public function dataGetAlterTableSql()
// Drop idx
new \SimpleXmlElement('<table_structure name="#__test">' . $s1 . $f1 . $f2 . $k1 . '</table_structure>'),
array(
"DROP INDEX \"jos_dbtest_idx_name\""
'DROP INDEX "jos_dbtest_idx_name"'
),
'getAlterTableSQL should change sequence.'
),
Expand Down Expand Up @@ -381,14 +381,14 @@ public function dataGetAlterTableSql()
new \SimpleXmlElement('<table_structure name="#__test">' . $s2 . $f1 . $f2 . $k1 . $k2 . '</table_structure>'),
array(
$changeSeq,
"DROP SEQUENCE \"jos_dbtest_id_seq\"",),
'DROP SEQUENCE "jos_dbtest_id_seq"',),
'getAlterTableSQL should change sequence.'
),
array(
// Change idx
new \SimpleXmlElement('<table_structure name="#__test">' . $s1 . $f1 . $f2 . $k1 . $k3 . '</table_structure>'),
array(
"CREATE INDEX jos_dbtest_idx_title ON jos_dbtest USING btree (title)",
'CREATE INDEX jos_dbtest_idx_title ON jos_dbtest USING btree (title)',
'DROP INDEX "jos_dbtest_idx_name"'
),
'getAlterTableSQL should change index.'
Expand Down Expand Up @@ -700,7 +700,7 @@ public function testGetAddIndexSql()
new \SimpleXmlElement($xmlIndex)
),
$this->equalTo(
"CREATE INDEX jos_dbtest_idx_name ON jos_dbtest USING btree (name)"
'CREATE INDEX jos_dbtest_idx_name ON jos_dbtest USING btree (name)'
),
'testGetAddIndexSQL did not yield the expected result.'
);
Expand All @@ -710,7 +710,7 @@ public function testGetAddIndexSql()
new \SimpleXmlElement($xmlPrimaryKey)
),
$this->equalTo(
"ALTER TABLE jos_dbtest ADD PRIMARY KEY (id)"
'ALTER TABLE jos_dbtest ADD PRIMARY KEY (id)'
),
'testGetAddIndexSQL did not yield the expected result.'
);
Expand Down

0 comments on commit 99169d1

Please sign in to comment.