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
1946a1e1
Unverified
Commit
1946a1e1
authored
Aug 07, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework the usage of the deprecated at() matcher
parent
568bf0c0
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
105 additions
and
125 deletions
+105
-125
LoggingTest.php
tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php
+1
-1
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+6
-8
OCI8StatementTest.php
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
+5
-16
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+6
-18
SchemaTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
+14
-24
CreateSchemaSqlCollectorTest.php
...ests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
+21
-16
PoolingShardManagerTest.php
.../Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
+39
-37
SQLAzureShardManagerTest.php
...Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
+13
-5
No files found.
tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php
View file @
1946a1e1
...
...
@@ -54,7 +54,7 @@ final class LoggingTest extends TestCase
$logger
->
expects
(
$this
->
once
())
->
method
(
'startQuery'
)
->
with
(
$this
->
equalTo
(
$expectedSQL
),
$this
->
equalTo
([]));
$logger
->
expects
(
$this
->
at
(
1
))
$logger
->
expects
(
$this
->
once
(
))
->
method
(
'stopQuery'
);
$connection
=
new
Connection
([],
$driver
);
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
1946a1e1
...
...
@@ -152,7 +152,7 @@ class ConnectionTest extends DbalTestCase
$eventManager
->
addEventListener
([
Events
::
postConnect
],
$listenerMock
);
$driverMock
=
$this
->
createMock
(
Driver
::
class
);
$driverMock
->
expects
(
$this
->
at
(
0
))
$driverMock
->
expects
(
$this
->
once
(
))
->
method
(
'connect'
);
$conn
=
new
Connection
([],
$driverMock
,
new
Configuration
(),
$eventManager
);
...
...
@@ -846,13 +846,11 @@ EOF
$originalException
=
new
Exception
(
'Original exception'
);
$fallbackException
=
new
Exception
(
'Fallback exception'
);
$driverMock
->
expects
(
$this
->
at
(
0
))
->
method
(
'connect'
)
->
willThrowException
(
$originalException
);
$driverMock
->
expects
(
$this
->
at
(
1
))
->
method
(
'connect'
)
->
willThrowException
(
$fallbackException
);
$driverMock
->
method
(
'connect'
)
->
will
(
self
::
onConsecutiveCalls
(
self
::
throwException
(
$originalException
),
self
::
throwException
(
$fallbackException
)
));
$this
->
expectExceptionMessage
(
$originalException
->
getMessage
());
...
...
tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
View file @
1946a1e1
...
...
@@ -33,23 +33,12 @@ class OCI8StatementTest extends DbalTestCase
->
disableOriginalConstructor
()
->
getMock
();
$statement
->
expects
(
$this
->
at
(
0
))
$statement
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'bindValue'
)
->
with
(
$this
->
equalTo
(
1
),
$this
->
equalTo
(
$params
[
0
])
);
$statement
->
expects
(
$this
->
at
(
1
))
->
method
(
'bindValue'
)
->
with
(
$this
->
equalTo
(
2
),
$this
->
equalTo
(
$params
[
1
])
);
$statement
->
expects
(
$this
->
at
(
2
))
->
method
(
'bindValue'
)
->
with
(
$this
->
equalTo
(
3
),
$this
->
equalTo
(
$params
[
2
])
->
withConsecutive
(
[
1
,
$params
[
0
]],
[
2
,
$params
[
1
]],
[
3
,
$params
[
2
]],
);
// the return value is irrelevant to the test
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
1946a1e1
...
...
@@ -1174,29 +1174,17 @@ class ComparatorTest extends TestCase
->
method
(
'getNamespaces'
)
->
will
(
$this
->
returnValue
([
'foo'
,
'bar'
]));
$fromSchema
->
expects
(
$this
->
at
(
0
))
->
method
(
'hasNamespace'
)
->
with
(
'bar'
)
->
will
(
$this
->
returnValue
(
true
));
$fromSchema
->
expects
(
$this
->
at
(
1
))
->
method
(
'hasNamespace'
)
->
with
(
'baz'
)
->
will
(
$this
->
returnValue
(
false
));
$fromSchema
->
method
(
'hasNamespace'
)
->
withConsecutive
([
'bar'
],
[
'baz'
])
->
willReturnOnConsecutiveCalls
(
true
,
false
);
$toSchema
->
expects
(
$this
->
once
())
->
method
(
'getNamespaces'
)
->
will
(
$this
->
returnValue
([
'bar'
,
'baz'
]));
$toSchema
->
expects
(
$this
->
at
(
1
))
->
method
(
'hasNamespace'
)
->
with
(
'foo'
)
->
will
(
$this
->
returnValue
(
false
));
$toSchema
->
expects
(
$this
->
at
(
2
))
->
method
(
'hasNamespace'
)
->
with
(
'bar'
)
->
will
(
$this
->
returnValue
(
true
));
$toSchema
->
method
(
'hasNamespace'
)
->
withConsecutive
([
'foo'
],
[
'bar'
])
->
willReturnOnConsecutiveCalls
(
false
,
true
);
$expected
=
new
SchemaDiff
();
$expected
->
fromSchema
=
$fromSchema
;
...
...
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
View file @
1946a1e1
...
...
@@ -371,7 +371,7 @@ class SchemaTest extends TestCase
[
$schema
->
getSequence
(
'war'
)]
);
self
::
assertNull
(
$schema
->
visit
(
$visitor
)
);
$schema
->
visit
(
$visitor
);
}
public
function
testVisitsNamespaceVisitor
()
:
void
...
...
@@ -392,34 +392,24 @@ class SchemaTest extends TestCase
->
method
(
'acceptSchema'
)
->
with
(
$schema
);
$visitor
->
expects
(
$this
->
at
(
1
))
$visitor
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'acceptNamespace'
)
->
with
(
'foo'
);
->
with
Consecutive
([
'foo'
],
[
'bar'
],
[
'bla'
]
);
$visitor
->
expects
(
$this
->
at
(
2
))
->
method
(
'acceptNamespace'
)
->
with
(
'bar'
);
$visitor
->
expects
(
$this
->
at
(
3
))
->
method
(
'acceptNamespace'
)
->
with
(
'bla'
);
$visitor
->
expects
(
$this
->
at
(
4
))
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'baz'
));
$visitor
->
expects
(
$this
->
at
(
5
))
->
method
(
'acceptTable'
)
->
with
(
$schema
->
getTable
(
'bla.bloo'
));
$visitor
->
expects
(
$this
->
at
(
6
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'moo'
));
->
withConsecutive
(
[
$schema
->
getTable
(
'baz'
)],
[
$schema
->
getTable
(
'bla.bloo'
)]
);
$visitor
->
expects
(
$this
->
at
(
7
))
$visitor
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'acceptSequence'
)
->
with
(
$schema
->
getSequence
(
'war'
));
->
withConsecutive
(
[
$schema
->
getSequence
(
'moo'
)],
[
$schema
->
getSequence
(
'war'
)]
);
self
::
assertNull
(
$schema
->
visit
(
$visitor
)
);
$schema
->
visit
(
$visitor
);
}
}
tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php
View file @
1946a1e1
...
...
@@ -45,19 +45,20 @@ class CreateSchemaSqlCollectorTest extends TestCase
->
willReturn
([
'foo'
]);
}
public
function
testAcceptsNamespace
()
:
void
public
function
testAcceptsNamespace
DoesNotSupportSchemas
()
:
void
{
$this
->
platformMock
->
expects
(
$this
->
at
(
0
))
->
method
(
'supportsSchemas'
)
->
will
(
$this
->
returnValue
(
false
));
$this
->
platformMock
->
expects
(
$this
->
at
(
1
))
->
method
(
'supportsSchemas'
)
->
will
(
$this
->
returnValue
(
true
));
$this
->
platformMock
->
method
(
'supportsSchemas'
)
->
willReturn
(
false
);
$this
->
visitor
->
acceptNamespace
(
'foo'
);
self
::
assertEmpty
(
$this
->
visitor
->
getQueries
());
}
public
function
testAcceptsNamespaceSupportsSchemas
()
:
void
{
$this
->
platformMock
->
method
(
'supportsSchemas'
)
->
willReturn
(
true
);
$this
->
visitor
->
acceptNamespace
(
'foo'
);
...
...
@@ -73,15 +74,10 @@ class CreateSchemaSqlCollectorTest extends TestCase
self
::
assertSame
([
'foo'
],
$this
->
visitor
->
getQueries
());
}
public
function
testAcceptsForeignKey
()
:
void
public
function
testAcceptsForeignKey
DoesNotSupportCreateDropForeignKeyConstraints
()
:
void
{
$this
->
platformMock
->
expects
(
$this
->
at
(
0
))
->
method
(
'supportsCreateDropForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
false
));
$this
->
platformMock
->
expects
(
$this
->
at
(
1
))
->
method
(
'supportsCreateDropForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
true
));
$this
->
platformMock
->
method
(
'supportsCreateDropForeignKeyConstraints'
)
->
willReturn
(
false
);
$table
=
$this
->
createTableMock
();
$foreignKey
=
$this
->
createForeignKeyConstraintMock
();
...
...
@@ -89,6 +85,15 @@ class CreateSchemaSqlCollectorTest extends TestCase
$this
->
visitor
->
acceptForeignKey
(
$table
,
$foreignKey
);
self
::
assertEmpty
(
$this
->
visitor
->
getQueries
());
}
public
function
testAcceptsForeignKeySupportsCreateDropForeignKeyConstraints
()
:
void
{
$this
->
platformMock
->
method
(
'supportsCreateDropForeignKeyConstraints'
)
->
willReturn
(
true
);
$table
=
$this
->
createTableMock
();
$foreignKey
=
$this
->
createForeignKeyConstraintMock
();
$this
->
visitor
->
acceptForeignKey
(
$table
,
$foreignKey
);
...
...
tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php
View file @
1946a1e1
...
...
@@ -63,13 +63,11 @@ class PoolingShardManagerTest extends TestCase
$shardId
=
10
;
$conn
=
$this
->
createConnectionMock
();
$conn
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParams'
)
$conn
->
method
(
'getParams'
)
->
willReturn
([
'shardChoser'
=>
$this
->
createPassthroughShardChoser
()]);
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'connect'
)
->
with
(
$this
->
equalTo
(
$shardId
));
$conn
->
method
(
'connect'
)
->
with
(
$shardId
);
$shardManager
=
new
PoolingShardManager
(
$conn
);
$shardManager
->
selectShard
(
$shardId
);
...
...
@@ -99,22 +97,24 @@ class PoolingShardManagerTest extends TestCase
$types
=
[
1
];
$conn
=
$this
->
createConnectionMock
();
$conn
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
[
'shards'
=>
[[
'id'
=>
1
],
[
'id'
=>
2
]],
'shardChoser'
=>
$this
->
createPassthroughShardChoser
()]
));
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
[
'shards'
=>
[[
'id'
=>
1
],
[
'id'
=>
2
]],
'shardChoser'
=>
$this
->
createPassthroughShardChoser
()]
));
$conn
->
expects
(
$this
->
at
(
2
))
->
method
(
'connect'
)
->
with
(
$this
->
equalTo
(
1
));
$conn
->
expects
(
$this
->
at
(
3
))
->
method
(
'fetchAllAssociative'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$params
),
$this
->
equalTo
(
$types
))
->
will
(
$this
->
returnValue
([[
'id'
=>
1
]]));
$conn
->
expects
(
$this
->
at
(
4
))
->
method
(
'connect'
)
->
with
(
$this
->
equalTo
(
2
));
$conn
->
expects
(
$this
->
at
(
5
))
->
method
(
'fetchAllAssociative'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$params
),
$this
->
equalTo
(
$types
))
->
will
(
$this
->
returnValue
([[
'id'
=>
2
]]));
$conn
->
method
(
'getParams'
)
->
willReturn
([
'shards'
=>
[
[
'id'
=>
1
],
[
'id'
=>
2
],
],
'shardChoser'
=>
$this
->
createPassthroughShardChoser
(),
]);
$conn
->
method
(
'connect'
)
->
withConsecutive
([
1
],
[
2
]);
$conn
->
method
(
'fetchAllAssociative'
)
->
with
(
$sql
,
$params
,
$types
)
->
willReturnOnConsecutiveCalls
(
[[
'id'
=>
1
]],
[[
'id'
=>
2
]],
);
$shardManager
=
new
PoolingShardManager
(
$conn
);
$result
=
$shardManager
->
queryAll
(
$sql
,
$params
,
$types
);
...
...
@@ -129,22 +129,24 @@ class PoolingShardManagerTest extends TestCase
$types
=
[
1
];
$conn
=
$this
->
createConnectionMock
();
$conn
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
[
'shards'
=>
[[
'id'
=>
1
],
[
'id'
=>
2
]],
'shardChoser'
=>
$this
->
createStaticShardChooser
()]
));
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
[
'shards'
=>
[[
'id'
=>
1
],
[
'id'
=>
2
]],
'shardChoser'
=>
$this
->
createStaticShardChooser
()]
));
$conn
->
expects
(
$this
->
at
(
2
))
->
method
(
'connect'
)
->
with
(
$this
->
equalTo
(
1
));
$conn
->
expects
(
$this
->
at
(
3
))
->
method
(
'fetchAllAssociative'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$params
),
$this
->
equalTo
(
$types
))
->
will
(
$this
->
returnValue
([[
'id'
=>
1
]]));
$conn
->
expects
(
$this
->
at
(
4
))
->
method
(
'connect'
)
->
with
(
$this
->
equalTo
(
2
));
$conn
->
expects
(
$this
->
at
(
5
))
->
method
(
'fetchAllAssociative'
)
->
with
(
$this
->
equalTo
(
$sql
),
$this
->
equalTo
(
$params
),
$this
->
equalTo
(
$types
))
->
will
(
$this
->
returnValue
([[
'id'
=>
2
]]));
$conn
->
method
(
'getParams'
)
->
willReturn
([
'shards'
=>
[
[
'id'
=>
1
],
[
'id'
=>
2
],
],
'shardChoser'
=>
$this
->
createStaticShardChooser
(),
]);
$conn
->
method
(
'connect'
)
->
withConsecutive
([
1
],
[
2
]);
$conn
->
method
(
'fetchAllAssociative'
)
->
with
(
$sql
,
$params
,
$types
)
->
willReturnOnConsecutiveCalls
(
[[
'id'
=>
1
]],
[[
'id'
=>
2
]],
);
$shardManager
=
new
PoolingShardManager
(
$conn
);
$result
=
$shardManager
->
queryAll
(
$sql
,
$params
,
$types
);
...
...
tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php
View file @
1946a1e1
...
...
@@ -60,7 +60,8 @@ class SQLAzureShardManagerTest extends TestCase
],
]);
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'isTransactionActive'
)
->
will
(
$this
->
returnValue
(
true
));
$conn
->
method
(
'isTransactionActive'
)
->
willReturn
(
true
);
$this
->
expectException
(
ShardingException
::
class
);
$this
->
expectExceptionMessage
(
'Cannot switch shard during an active transaction.'
);
...
...
@@ -79,8 +80,12 @@ class SQLAzureShardManagerTest extends TestCase
],
]);
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'isTransactionActive'
)
->
will
(
$this
->
returnValue
(
false
));
$conn
->
expects
(
$this
->
at
(
2
))
->
method
(
'exec'
)
->
with
(
$this
->
equalTo
(
'USE FEDERATION ROOT WITH RESET'
));
$conn
->
method
(
'isTransactionActive'
)
->
willReturn
(
false
);
$conn
->
expects
(
$this
->
once
())
->
method
(
'exec'
)
->
with
(
'USE FEDERATION ROOT WITH RESET'
);
$sm
=
new
SQLAzureShardManager
(
$conn
);
$sm
->
selectGlobal
();
...
...
@@ -96,7 +101,8 @@ class SQLAzureShardManagerTest extends TestCase
],
]);
$conn
->
expects
(
$this
->
at
(
1
))
->
method
(
'isTransactionActive'
)
->
will
(
$this
->
returnValue
(
true
));
$conn
->
method
(
'isTransactionActive'
)
->
willReturn
(
true
);
$this
->
expectException
(
ShardingException
::
class
);
$this
->
expectExceptionMessage
(
'Cannot switch shard during an active transaction.'
);
...
...
@@ -118,7 +124,9 @@ class SQLAzureShardManagerTest extends TestCase
->
onlyMethods
([
'getParams'
,
'exec'
,
'isTransactionActive'
])
->
disableOriginalConstructor
()
->
getMock
();
$conn
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParams'
)
->
will
(
$this
->
returnValue
(
$params
));
$conn
->
method
(
'getParams'
)
->
willReturn
(
$params
);
return
$conn
;
}
...
...
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