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
9f9629c0
Unverified
Commit
9f9629c0
authored
May 27, 2020
by
Grégoire Paris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid mocking inexistent classes
It confuses both Psalm and PHPStan, and involves complicated mocking.
parent
b00a2e3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
27 deletions
+46
-27
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+6
-3
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+12
-7
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+28
-17
No files found.
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
9f9629c0
...
@@ -144,9 +144,7 @@ class ConnectionTest extends DbalTestCase
...
@@ -144,9 +144,7 @@ class ConnectionTest extends DbalTestCase
public
function
testConnectDispatchEvent
()
:
void
public
function
testConnectDispatchEvent
()
:
void
{
{
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'ConnectDispatchEventListener'
))
$listenerMock
=
$this
->
createMock
(
ConnectDispatchEventListener
::
class
);
->
addMethods
([
'postConnect'
])
->
getMock
();
$listenerMock
->
expects
(
$this
->
once
())
->
method
(
'postConnect'
);
$listenerMock
->
expects
(
$this
->
once
())
->
method
(
'postConnect'
);
$eventManager
=
new
EventManager
();
$eventManager
=
new
EventManager
();
...
@@ -948,3 +946,8 @@ class ConnectionTest extends DbalTestCase
...
@@ -948,3 +946,8 @@ class ConnectionTest extends DbalTestCase
$connection
->
executeCacheQuery
(
$query
,
[],
[],
$queryCacheProfile
);
$connection
->
executeCacheQuery
(
$query
,
[],
[],
$queryCacheProfile
);
}
}
}
}
interface
ConnectDispatchEventListener
{
public
function
postConnect
()
:
void
;
}
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
9f9629c0
...
@@ -369,10 +369,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
...
@@ -369,10 +369,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'ListTableColumnsDispatchEventListener'
))
$listenerMock
=
$this
->
createMock
(
ListTableColumnsDispatchEventListener
::
class
);
->
addMethods
([
'onSchemaColumnDefinition'
])
->
getMock
();
$listenerMock
$listenerMock
->
expects
(
$this
->
exactly
(
7
))
->
expects
(
$this
->
exactly
(
7
))
->
method
(
'onSchemaColumnDefinition'
);
->
method
(
'onSchemaColumnDefinition'
);
...
@@ -397,9 +394,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
...
@@ -397,9 +394,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'ListTableIndexesDispatchEventListener'
))
$listenerMock
=
$this
->
createMock
(
ListTableIndexesDispatchEventListener
::
class
);
->
addMethods
([
'onSchemaIndexDefinition'
])
->
getMock
();
$listenerMock
$listenerMock
->
expects
(
$this
->
exactly
(
3
))
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'onSchemaIndexDefinition'
);
->
method
(
'onSchemaIndexDefinition'
);
...
@@ -1653,3 +1648,13 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
...
@@ -1653,3 +1648,13 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
}
}
}
}
}
}
interface
ListTableColumnsDispatchEventListener
{
public
function
onSchemaColumnDefinition
()
:
void
;
}
interface
ListTableIndexesDispatchEventListener
{
public
function
onSchemaIndexDefinition
()
:
void
;
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
9f9629c0
...
@@ -372,9 +372,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
...
@@ -372,9 +372,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public
function
testGetCreateTableSqlDispatchEvent
()
:
void
public
function
testGetCreateTableSqlDispatchEvent
()
:
void
{
{
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'GetCreateTableSqlDispatchEvenListener'
))
$listenerMock
=
$this
->
createMock
(
GetCreateTableSqlDispatchEventListener
::
class
);
->
addMethods
([
'onSchemaCreateTable'
,
'onSchemaCreateTableColumn'
])
->
getMock
();
$listenerMock
$listenerMock
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'onSchemaCreateTable'
);
->
method
(
'onSchemaCreateTable'
);
...
@@ -396,9 +394,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
...
@@ -396,9 +394,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public
function
testGetDropTableSqlDispatchEvent
()
:
void
public
function
testGetDropTableSqlDispatchEvent
()
:
void
{
{
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'GetDropTableSqlDispatchEventListener'
))
$listenerMock
=
$this
->
createMock
(
GetDropTableSqlDispatchEventListener
::
class
);
->
addMethods
([
'onSchemaDropTable'
])
->
getMock
();
$listenerMock
$listenerMock
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'onSchemaDropTable'
);
->
method
(
'onSchemaDropTable'
);
...
@@ -413,17 +409,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
...
@@ -413,17 +409,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public
function
testGetAlterTableSqlDispatchEvent
()
:
void
public
function
testGetAlterTableSqlDispatchEvent
()
:
void
{
{
$events
=
[
$listenerMock
=
$this
->
createMock
(
GetAlterTableSqlDispatchEventListener
::
class
);
'onSchemaAlterTable'
,
'onSchemaAlterTableAddColumn'
,
'onSchemaAlterTableRemoveColumn'
,
'onSchemaAlterTableChangeColumn'
,
'onSchemaAlterTableRenameColumn'
,
];
$listenerMock
=
$this
->
getMockBuilder
(
$this
->
getMockClass
(
'GetAlterTableSqlDispatchEvenListener'
))
->
addMethods
(
$events
)
->
getMock
();
$listenerMock
$listenerMock
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'onSchemaAlterTable'
);
->
method
(
'onSchemaAlterTable'
);
...
@@ -1532,3 +1518,28 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
...
@@ -1532,3 +1518,28 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
);
);
}
}
}
}
interface
GetCreateTableSqlDispatchEventListener
{
public
function
onSchemaCreateTable
()
:
void
;
public
function
onSchemaCreateTableColumn
()
:
void
;
}
interface
GetAlterTableSqlDispatchEventListener
{
public
function
onSchemaAlterTable
()
:
void
;
public
function
onSchemaAlterTableAddColumn
()
:
void
;
public
function
onSchemaAlterTableRemoveColumn
()
:
void
;
public
function
onSchemaAlterTableChangeColumn
()
:
void
;
public
function
onSchemaAlterTableRenameColumn
()
:
void
;
}
interface
GetDropTableSqlDispatchEventListener
{
public
function
onSchemaDropTable
()
:
void
;
}
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