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
ecfa0eee
Commit
ecfa0eee
authored
Dec 04, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-169 - Added tests for case-handling which is necessary for Comparator
parent
0788cdf1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
2 deletions
+96
-2
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+2
-2
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+39
-0
SchemaTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
+27
-0
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+28
-0
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
ecfa0eee
...
...
@@ -196,14 +196,14 @@ class Table extends AbstractAsset
* @param string $columnName
* @param string $columnType
* @param array $options
* @return
Table
* @return
Column
*/
public
function
createColumn
(
$columnName
,
$typeName
,
array
$options
=
array
())
{
$column
=
new
Column
(
$columnName
,
Type
::
getType
(
$typeName
),
$options
);
$this
->
_addColumn
(
$column
);
return
$
this
;
return
$
column
;
}
/**
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
ecfa0eee
...
...
@@ -471,4 +471,43 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertType
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
changedForeignKeys
));
}
public
function
testTablesCaseInsensitive
()
{
$schemaA
=
new
Schema
();
$schemaA
->
createTable
(
'foo'
);
$schemaA
->
createTable
(
'bAr'
);
$schemaA
->
createTable
(
'BAZ'
);
$schemaA
->
createTable
(
'new'
);
$schemaB
=
new
Schema
();
$schemaB
->
createTable
(
'FOO'
);
$schemaB
->
createTable
(
'bar'
);
$schemaB
->
createTable
(
'Baz'
);
$schemaB
->
createTable
(
'old'
);
$c
=
new
Comparator
();
$diff
=
$c
->
compare
(
$schemaA
,
$schemaB
);
$this
->
assertSchemaTableChangeCount
(
$diff
,
1
,
0
,
1
);
}
public
function
testSequencesCaseInsenstive
()
{
}
/**
*
* @param SchemaDiff $diff
* @param int $newTableCount
* @param int $changeTableCount
* @param int $removeTableCount
*/
public
function
assertSchemaTableChangeCount
(
$diff
,
$newTableCount
=
0
,
$changeTableCount
=
0
,
$removeTableCount
=
0
)
{
$this
->
assertEquals
(
$newTableCount
,
count
(
$diff
->
newTables
));
$this
->
assertEquals
(
$changeTableCount
,
count
(
$diff
->
changedTables
));
$this
->
assertEquals
(
$removeTableCount
,
count
(
$diff
->
removedTables
));
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
View file @
ecfa0eee
...
...
@@ -26,6 +26,19 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$schema
->
hasTable
(
$tableName
));
}
public
function
testTableMatchingCaseInsenstive
()
{
$table
=
new
Table
(
"Foo"
);
$schema
=
new
Schema
(
array
(
$table
));
$this
->
assertTrue
(
$schema
->
hasTable
(
"foo"
));
$this
->
assertTrue
(
$schema
->
hasTable
(
"FOO"
));
$this
->
assertSame
(
$table
,
$schema
->
getTable
(
'FOO'
));
$this
->
assertSame
(
$table
,
$schema
->
getTable
(
'foo'
));
$this
->
assertSame
(
$table
,
$schema
->
getTable
(
'Foo'
));
}
public
function
testGetUnknownTableThrowsException
()
{
$this
->
setExpectedException
(
"Doctrine\DBAL\Schema\SchemaException"
);
...
...
@@ -97,6 +110,20 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$this
->
assertArrayHasKey
(
'a_seq'
,
$sequences
);
}
public
function
testSequenceAccessCaseInsensitive
()
{
$sequence
=
new
Sequence
(
"a_Seq"
);
$schema
=
new
Schema
(
array
(),
array
(
$sequence
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
'a_seq'
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
'a_Seq'
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
'A_SEQ'
));
$this
->
assertEquals
(
$sequence
,
$schema
->
getSequence
(
'a_seq'
));
$this
->
assertEquals
(
$sequence
,
$schema
->
getSequence
(
'a_Seq'
));
$this
->
assertEquals
(
$sequence
,
$schema
->
getSequence
(
'A_SEQ'
));
}
public
function
testGetUnknownSequenceThrowsException
()
{
$this
->
setExpectedException
(
"Doctrine\DBAL\Schema\SchemaException"
);
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
ecfa0eee
...
...
@@ -38,6 +38,20 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
2
,
count
(
$table
->
getColumns
()));
}
public
function
testColumnsCaseInsensitive
()
{
$table
=
new
Table
(
"foo"
);
$column
=
$table
->
createColumn
(
'Foo'
,
'integer'
);
$this
->
assertTrue
(
$table
->
hasColumn
(
'Foo'
));
$this
->
assertTrue
(
$table
->
hasColumn
(
'foo'
));
$this
->
assertTrue
(
$table
->
hasColumn
(
'FOO'
));
$this
->
assertSame
(
$column
,
$table
->
getColumn
(
'Foo'
));
$this
->
assertSame
(
$column
,
$table
->
getColumn
(
'foo'
));
$this
->
assertSame
(
$column
,
$table
->
getColumn
(
'FOO'
));
}
public
function
testCreateColumn
()
{
$type
=
Type
::
getType
(
'integer'
);
...
...
@@ -91,6 +105,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
$type
=
\Doctrine\DBAL\Types\Type
::
getType
(
'integer'
);
$columns
=
array
(
new
Column
(
"foo"
,
$type
),
new
Column
(
"bar"
,
$type
),
new
Column
(
"baz"
,
$type
));
$table
=
new
Table
(
"foo"
,
$columns
);
$table
->
addIndex
(
array
(
"foo"
,
"bar"
,
"baz"
));
$table
->
addUniqueIndex
(
array
(
"foo"
,
"bar"
,
"baz"
));
...
...
@@ -98,6 +113,19 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$table
->
hasIndex
(
"foo_bar_baz_uniq"
));
}
public
function
testIndexCaseInsensitive
()
{
$type
=
\Doctrine\DBAL\Types\Type
::
getType
(
'integer'
);
$columns
=
array
(
new
Column
(
"foo"
,
$type
),
new
Column
(
"bar"
,
$type
),
new
Column
(
"baz"
,
$type
));
$table
=
new
Table
(
"foo"
,
$columns
);
$table
->
addIndex
(
array
(
"foo"
,
"bar"
,
"baz"
),
"Foo_Idx"
);
$this
->
assertTrue
(
$table
->
hasIndex
(
'foo_idx'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'Foo_Idx'
));
$this
->
assertTrue
(
$table
->
hasIndex
(
'FOO_IDX'
));
}
public
function
testAddIndexes
()
{
$type
=
\Doctrine\DBAL\Types\Type
::
getType
(
'integer'
);
...
...
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