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
116270db
Commit
116270db
authored
Nov 18, 2017
by
Tobias Schultze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for column collation to prove it works
parent
a4015c8b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
6 deletions
+103
-6
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+29
-3
AbstractSQLServerPlatformTestCase.php
...ests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
+27
-1
PostgreSQL91PlatformTest.php
...octrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
+21
-2
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+26
-0
No files found.
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
116270db
...
...
@@ -474,7 +474,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
"ALTER TABLE mytable ADD PRIMARY KEY (foo)"
,
),
$sql
);
}
public
function
testAlterPrimaryKeyWithNewColumn
()
{
$table
=
new
Table
(
"yolo"
);
...
...
@@ -484,7 +484,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$comparator
=
new
Comparator
();
$diffTable
=
clone
$table
;
$diffTable
->
addColumn
(
'pkc2'
,
'integer'
);
$diffTable
->
dropPrimaryKey
();
$diffTable
->
setPrimaryKey
(
array
(
'pkc1'
,
'pkc2'
));
...
...
@@ -496,7 +496,7 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)'
,
),
$this
->
_platform
->
getAlterTableSQL
(
$comparator
->
diffTable
(
$table
,
$diffTable
))
);
);
}
public
function
testInitializesDoctrineTypeMappings
()
...
...
@@ -908,4 +908,30 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
self
::
assertContains
(
'bar'
,
$sql
);
self
::
assertNotContains
(
'DATABASE()'
,
$sql
);
}
public
function
testSupportsColumnCollation
()
:
void
{
self
::
assertTrue
(
$this
->
_platform
->
supportsColumnCollation
());
}
public
function
testColumnCollationDeclarationSQL
()
:
void
{
self
::
assertSame
(
'COLLATE ascii_general_ci'
,
$this
->
_platform
->
getColumnCollationDeclarationSQL
(
'ascii_general_ci'
)
);
}
public
function
testGetCreateTableSQLWithColumnCollation
()
:
void
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'no_collation'
,
'string'
);
$table
->
addColumn
(
'column_collation'
,
'string'
)
->
setPlatformOption
(
'collation'
,
'ascii_general_ci'
);
self
::
assertSame
(
[
'CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE ascii_general_ci) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
],
$this
->
_platform
->
getCreateTableSQL
(
$table
),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php
View file @
116270db
...
...
@@ -1487,7 +1487,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
$currentDateSql
=
$this
->
_platform
->
getCurrentDateSQL
();
foreach
([
'date'
,
'date_immutable'
]
as
$type
)
{
$field
=
[
'type'
=>
Type
::
getType
(
$type
),
'type'
=>
Type
::
getType
(
$type
),
'default'
=>
$currentDateSql
,
];
...
...
@@ -1498,6 +1498,32 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
}
}
public
function
testSupportsColumnCollation
()
:
void
{
self
::
assertTrue
(
$this
->
_platform
->
supportsColumnCollation
());
}
public
function
testColumnCollationDeclarationSQL
()
:
void
{
self
::
assertSame
(
'COLLATE Latin1_General_CS_AS_KS_WS'
,
$this
->
_platform
->
getColumnCollationDeclarationSQL
(
'Latin1_General_CS_AS_KS_WS'
)
);
}
public
function
testGetCreateTableSQLWithColumnCollation
()
:
void
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'no_collation'
,
'string'
);
$table
->
addColumn
(
'column_collation'
,
'string'
)
->
setPlatformOption
(
'collation'
,
'Latin1_General_CS_AS_KS_WS'
);
self
::
assertSame
(
[
'CREATE TABLE foo (no_collation NVARCHAR(255) NOT NULL, column_collation NVARCHAR(255) COLLATE Latin1_General_CS_AS_KS_WS NOT NULL)'
],
$this
->
_platform
->
getCreateTableSQL
(
$table
),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
private
function
expectCteWithMaxRowNum
(
string
$expectedSql
,
int
$expectedMax
,
string
$sql
)
:
void
{
$pattern
=
'WITH dctrn_cte AS (%s) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum <= %d ORDER BY doctrine_rownum ASC'
;
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php
View file @
116270db
...
...
@@ -3,6 +3,7 @@
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\PostgreSQL91Platform
;
use
Doctrine\DBAL\Schema\Table
;
class
PostgreSql91PlatformTest
extends
PostgreSqlPlatformTest
{
...
...
@@ -11,11 +12,29 @@ class PostgreSql91PlatformTest extends PostgreSqlPlatformTest
return
new
PostgreSQL91Platform
();
}
public
function
test
ColumnCollationDeclarationSQL
()
public
function
test
SupportsColumnCollation
()
:
void
{
self
::
assertEquals
(
self
::
assertTrue
(
$this
->
_platform
->
supportsColumnCollation
());
}
public
function
testColumnCollationDeclarationSQL
()
:
void
{
self
::
assertSame
(
'COLLATE "en_US.UTF-8"'
,
$this
->
_platform
->
getColumnCollationDeclarationSQL
(
'en_US.UTF-8'
)
);
}
public
function
testGetCreateTableSQLWithColumnCollation
()
:
void
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'no_collation'
,
'string'
);
$table
->
addColumn
(
'column_collation'
,
'string'
)
->
setPlatformOption
(
'collation'
,
'en_US.UTF-8'
);
self
::
assertSame
(
[
'CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE "en_US.UTF-8")'
],
$this
->
_platform
->
getCreateTableSQL
(
$table
),
'Column "no_collation" will use the default collation from the table/database and "column_collation" overwrites the collation on this column'
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
116270db
...
...
@@ -759,4 +759,30 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{
self
::
assertSame
(
"DATE(rentalBeginsOn,'+' || duration || ' DAY')"
,
$this
->
_platform
->
getDateAddDaysExpression
(
'rentalBeginsOn'
,
'duration'
));
}
public
function
testSupportsColumnCollation
()
:
void
{
self
::
assertTrue
(
$this
->
_platform
->
supportsColumnCollation
());
}
public
function
testColumnCollationDeclarationSQL
()
:
void
{
self
::
assertSame
(
'COLLATE NOCASE'
,
$this
->
_platform
->
getColumnCollationDeclarationSQL
(
'NOCASE'
)
);
}
public
function
testGetCreateTableSQLWithColumnCollation
()
:
void
{
$table
=
new
Table
(
'foo'
);
$table
->
addColumn
(
'no_collation'
,
'string'
);
$table
->
addColumn
(
'column_collation'
,
'string'
)
->
setPlatformOption
(
'collation'
,
'NOCASE'
);
self
::
assertSame
(
[
'CREATE TABLE foo (no_collation VARCHAR(255) NOT NULL, column_collation VARCHAR(255) NOT NULL COLLATE NOCASE)'
],
$this
->
_platform
->
getCreateTableSQL
(
$table
),
'Column "no_collation" will use the default collation (BINARY) and "column_collation" overwrites the collation on this column'
);
}
}
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