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
5d74b25a
Commit
5d74b25a
authored
Jan 03, 2015
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for MySQL decimal/float unsigned declaration
parent
9830694c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
0 deletions
+122
-0
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+42
-0
AbstractMySQLPlatformTestCase.php
...ne/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
+30
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+50
-0
No files found.
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
5d74b25a
...
...
@@ -279,4 +279,46 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
"No differences should be detected with the offline vs online schema."
);
}
/**
* @group DBAL-1082
*/
public
function
testListDecimalTypeColumns
()
{
$tableName
=
'test_list_decimal_columns'
;
$table
=
new
Table
(
$tableName
);
$table
->
addColumn
(
'col'
,
'decimal'
);
$table
->
addColumn
(
'col_unsigned'
,
'decimal'
,
array
(
'unsigned'
=>
true
));
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$columns
=
$this
->
_sm
->
listTableColumns
(
$tableName
);
$this
->
assertArrayHasKey
(
'col'
,
$columns
);
$this
->
assertArrayHasKey
(
'col_unsigned'
,
$columns
);
$this
->
assertFalse
(
$columns
[
'col'
]
->
getUnsigned
());
$this
->
assertTrue
(
$columns
[
'col_unsigned'
]
->
getUnsigned
());
}
/**
* @group DBAL-1082
*/
public
function
testListFloatTypeColumns
()
{
$tableName
=
'test_list_float_columns'
;
$table
=
new
Table
(
$tableName
);
$table
->
addColumn
(
'col'
,
'float'
);
$table
->
addColumn
(
'col_unsigned'
,
'float'
,
array
(
'unsigned'
=>
true
));
$this
->
_sm
->
dropAndCreateTable
(
$table
);
$columns
=
$this
->
_sm
->
listTableColumns
(
$tableName
);
$this
->
assertArrayHasKey
(
'col'
,
$columns
);
$this
->
assertArrayHasKey
(
'col_unsigned'
,
$columns
);
$this
->
assertFalse
(
$columns
[
'col'
]
->
getUnsigned
());
$this
->
assertTrue
(
$columns
[
'col_unsigned'
]
->
getUnsigned
());
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php
View file @
5d74b25a
...
...
@@ -680,4 +680,34 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
'ALTER TABLE mytable ADD CONSTRAINT fk_foo FOREIGN KEY (foo) REFERENCES foreign_table (id)'
,
);
}
/**
* {@inheritdoc}
*/
public
function
getGeneratesDecimalTypeDeclarationSQL
()
{
return
array
(
array
(
array
(),
'NUMERIC(10, 0)'
),
array
(
array
(
'unsigned'
=>
true
),
'NUMERIC(10, 0) UNSIGNED'
),
array
(
array
(
'unsigned'
=>
false
),
'NUMERIC(10, 0)'
),
array
(
array
(
'precision'
=>
5
),
'NUMERIC(5, 0)'
),
array
(
array
(
'scale'
=>
5
),
'NUMERIC(10, 5)'
),
array
(
array
(
'precision'
=>
8
,
'scale'
=>
2
),
'NUMERIC(8, 2)'
),
);
}
/**
* {@inheritdoc}
*/
public
function
getGeneratesFloatDeclarationSQL
()
{
return
array
(
array
(
array
(),
'DOUBLE PRECISION'
),
array
(
array
(
'unsigned'
=>
true
),
'DOUBLE PRECISION UNSIGNED'
),
array
(
array
(
'unsigned'
=>
false
),
'DOUBLE PRECISION'
),
array
(
array
(
'precision'
=>
5
),
'DOUBLE PRECISION'
),
array
(
array
(
'scale'
=>
5
),
'DOUBLE PRECISION'
),
array
(
array
(
'precision'
=>
8
,
'scale'
=>
2
),
'DOUBLE PRECISION'
),
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
5d74b25a
...
...
@@ -1192,4 +1192,54 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
* @return array
*/
abstract
protected
function
getGeneratesAlterTableRenameIndexUsedByForeignKeySQL
();
/**
* @group DBAL-1082
*
* @dataProvider getGeneratesDecimalTypeDeclarationSQL
*/
public
function
testGeneratesDecimalTypeDeclarationSQL
(
array
$column
,
$expectedSql
)
{
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getDecimalTypeDeclarationSQL
(
$column
));
}
/**
* @return array
*/
public
function
getGeneratesDecimalTypeDeclarationSQL
()
{
return
array
(
array
(
array
(),
'NUMERIC(10, 0)'
),
array
(
array
(
'unsigned'
=>
true
),
'NUMERIC(10, 0)'
),
array
(
array
(
'unsigned'
=>
false
),
'NUMERIC(10, 0)'
),
array
(
array
(
'precision'
=>
5
),
'NUMERIC(5, 0)'
),
array
(
array
(
'scale'
=>
5
),
'NUMERIC(10, 5)'
),
array
(
array
(
'precision'
=>
8
,
'scale'
=>
2
),
'NUMERIC(8, 2)'
),
);
}
/**
* @group DBAL-1082
*
* @dataProvider getGeneratesFloatDeclarationSQL
*/
public
function
testGeneratesFloatDeclarationSQL
(
array
$column
,
$expectedSql
)
{
$this
->
assertSame
(
$expectedSql
,
$this
->
_platform
->
getFloatDeclarationSQL
(
$column
));
}
/**
* @return array
*/
public
function
getGeneratesFloatDeclarationSQL
()
{
return
array
(
array
(
array
(),
'DOUBLE PRECISION'
),
array
(
array
(
'unsigned'
=>
true
),
'DOUBLE PRECISION'
),
array
(
array
(
'unsigned'
=>
false
),
'DOUBLE PRECISION'
),
array
(
array
(
'precision'
=>
5
),
'DOUBLE PRECISION'
),
array
(
array
(
'scale'
=>
5
),
'DOUBLE PRECISION'
),
array
(
array
(
'precision'
=>
8
,
'scale'
=>
2
),
'DOUBLE PRECISION'
),
);
}
}
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