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
fce77af2
Commit
fce77af2
authored
Aug 21, 2014
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #664 from deeky666/DBAL-669
[DBAL-669] Make schema visit namespaces
parents
b6cd3238
14241911
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
0 deletions
+118
-0
Schema.php
lib/Doctrine/DBAL/Schema/Schema.php
+8
-0
SchemaTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
+110
-0
No files found.
lib/Doctrine/DBAL/Schema/Schema.php
View file @
fce77af2
...
...
@@ -21,6 +21,7 @@ namespace Doctrine\DBAL\Schema;
use
Doctrine\DBAL\Schema\Visitor\CreateSchemaSqlCollector
;
use
Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector
;
use
Doctrine\DBAL\Schema\Visitor\NamespaceVisitor
;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
...
...
@@ -477,9 +478,16 @@ class Schema extends AbstractAsset
{
$visitor
->
acceptSchema
(
$this
);
if
(
$visitor
instanceof
NamespaceVisitor
)
{
foreach
(
$this
->
namespaces
as
$namespace
)
{
$visitor
->
acceptNamespace
(
$namespace
);
}
}
foreach
(
$this
->
_tables
as
$table
)
{
$table
->
visit
(
$visitor
);
}
foreach
(
$this
->
_sequences
as
$sequence
)
{
$sequence
->
visit
(
$visitor
);
}
...
...
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
View file @
fce77af2
...
...
@@ -344,4 +344,114 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$schema
->
hasNamespace
(
'baz'
));
$this
->
assertFalse
(
$schema
->
hasNamespace
(
'moo'
));
}
/**
* @group DBAL-669
*/
public
function
testVisitsVisitor
()
{
$schema
=
new
Schema
();
$visitor
=
$this
->
getMock
(
'Doctrine\DBAL\Schema\Visitor\Visitor'
);
$schema
->
createNamespace
(
'foo'
);
$schema
->
createNamespace
(
'bar'
);
$schema
->
createTable
(
'baz'
);
$schema
->
createTable
(
'bla.bloo'
);
$schema
->
createSequence
(
'moo'
);
$schema
->
createSequence
(
'war'
);
$visitor
->
expects
(
$this
->
once
())
->
method
(
'acceptSchema'
)
->
with
(
$schema
);
$visitor
->
expects
(
$this
->
never
())
->
method
(
'acceptNamespace'
);
$visitor
->
expects
(
$this
->
at
(
1
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'baz'
));
$visitor
->
expects
(
$this
->
at
(
2
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'bla.bloo'
));
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptTable'
);
$visitor
->
expects
(
$this
->
at
(
3
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'moo'
));
$visitor
->
expects
(
$this
->
at
(
4
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'war'
));
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptSequence'
);
$this
->
assertNull
(
$schema
->
visit
(
$visitor
));
}
/**
* @group DBAL-669
*/
public
function
testVisitsNamespaceVisitor
()
{
$schema
=
new
Schema
();
$visitor
=
$this
->
getMock
(
'Doctrine\DBAL\Schema\Visitor\AbstractVisitor'
);
$schema
->
createNamespace
(
'foo'
);
$schema
->
createNamespace
(
'bar'
);
$schema
->
createTable
(
'baz'
);
$schema
->
createTable
(
'bla.bloo'
);
$schema
->
createSequence
(
'moo'
);
$schema
->
createSequence
(
'war'
);
$visitor
->
expects
(
$this
->
once
())
->
method
(
'acceptSchema'
)
->
with
(
$schema
);
$visitor
->
expects
(
$this
->
at
(
1
))
->
method
(
'acceptNamespace'
)
->
with
(
'foo'
);
$visitor
->
expects
(
$this
->
at
(
2
))
->
method
(
'acceptNamespace'
)
->
with
(
'bar'
);
$visitor
->
expects
(
$this
->
at
(
3
))
->
method
(
'acceptNamespace'
)
->
with
(
'bla'
);
$visitor
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'acceptNamespace'
);
$visitor
->
expects
(
$this
->
at
(
4
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'baz'
));
$visitor
->
expects
(
$this
->
at
(
5
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'bla.bloo'
));
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptTable'
);
$visitor
->
expects
(
$this
->
at
(
6
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'moo'
));
$visitor
->
expects
(
$this
->
at
(
7
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'war'
));
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptSequence'
);
$this
->
assertNull
(
$schema
->
visit
(
$visitor
));
}
}
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