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
46069b6b
Unverified
Commit
46069b6b
authored
Mar 31, 2018
by
Marco Pivetta
Committed by
GitHub
Mar 31, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2919 from Tobion/test-column-collation
Add tests for column collation to prove it works
parents
a4015c8b
116270db
Changes
4
Show 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 @
46069b6b
...
...
@@ -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 @
46069b6b
...
...
@@ -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 @
46069b6b
...
...
@@ -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 @
46069b6b
...
...
@@ -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