Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
4736f5ee
Commit
4736f5ee
authored
Dec 05, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-169 - Refactored Parts of the Platform Tests into an Abstract Test Case
parent
8bfde413
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
65 deletions
+41
-65
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+23
-0
MsSqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
+4
-15
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+4
-15
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+3
-19
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+2
-16
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+5
-0
No files found.
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
4736f5ee
...
...
@@ -88,4 +88,27 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
return
'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)'
;
}
abstract
public
function
getGenerateAlterTableSql
();
public
function
testGeneratesTableAlterationSqlForAddingAndRenaming
()
{
$expectedSql
=
$this
->
getGenerateAlterTableSql
();
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
\Doctrine\DBAL\Types\Type
::
getType
(
'integer'
),
'notnull'
=>
false
,
)
));
$sql
=
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
);
$this
->
assertEquals
(
count
(
$sql
),
count
(
$expectedSql
),
"Expecting the same number of sql queries for alter table failed."
);
for
(
$i
=
0
;
$i
<
count
(
$expectedSql
);
$i
++
)
{
$this
->
assertEquals
(
$expectedSql
[
$i
],
$sql
[
$i
],
$i
.
"th query of alter table does not match."
);
}
}
}
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
View file @
4736f5ee
...
...
@@ -19,21 +19,10 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
return
'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'
;
}
public
function
testGeneratesTableAlterationSql
()
{
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
),
'unsigned'
=>
1
)
));
$sql
=
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
);
$this
->
assertEquals
(
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL'
,
$sql
[
0
]
public
function
getGenerateAlterTableSql
()
{
return
array
(
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL'
,
);
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
4736f5ee
...
...
@@ -28,21 +28,10 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
return
'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB'
;
}
public
function
testGeneratesTableAlterationSql
()
{
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
),
'unsigned'
=>
1
)
));
$sql
=
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
);
$this
->
assertEquals
(
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL'
,
$sql
[
0
]
public
function
getGenerateAlterTableSql
()
{
return
array
(
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL'
,
);
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
4736f5ee
...
...
@@ -19,27 +19,11 @@ class OraclePlatformTest extends AbstractPlatformTestCase
return
'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL, PRIMARY KEY(id))'
;
}
public
function
testGeneratesTableAlterationSql
()
{
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
),
'unsigned'
=>
1
)
));
$sql
=
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
);
$this
->
assertEquals
(
public
function
getGenerateAlterTableSql
()
{
return
array
(
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)'
,
$sql
[
0
]
);
$this
->
assertEquals
(
'ALTER TABLE mytable RENAME TO userlist'
,
$sql
[
1
]
);
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
4736f5ee
...
...
@@ -20,25 +20,11 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
return
'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'
;
}
public
function
testGeneratesTableAlterationSqlForAddingAndRenaming
()
public
function
getGenerateAlterTableSql
()
{
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
)
)
));
$sql
=
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
);
$this
->
assertEquals
(
return
array
(
'ALTER TABLE mytable ADD quota INT DEFAULT NULL'
,
$sql
[
0
]
);
$this
->
assertEquals
(
'ALTER TABLE mytable RENAME TO userlist'
,
$sql
[
1
]
);
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
4736f5ee
...
...
@@ -101,4 +101,9 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
);
$this
->
assertEquals
(
'SELECT * FROM user LIMIT 10'
,
$sql
);
}
public
function
getGenerateAlterTableSql
()
{
$this
->
markTestSkipped
(
'SQlite does not support ALTER Table.'
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment