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
d3d09e29
Unverified
Commit
d3d09e29
authored
Feb 26, 2019
by
Sergei Morozov
Committed by
GitHub
Feb 26, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3470 from morozov/remove-mock-platform
Replaced MockPlatform with the ones generated by PHPUnit
parents
8cba2b09
d4be62fb
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
160 additions
and
204 deletions
+160
-204
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+18
-14
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+5
-5
MockPlatform.php
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
+0
-100
SchemaDiffTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
+9
-3
TableDiffTest.php
tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
+14
-6
StatementTest.php
tests/Doctrine/Tests/DBAL/StatementTest.php
+6
-10
ArrayTest.php
tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
+5
-4
BaseDateTypeTestCase.php
tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
+4
-3
BinaryTest.php
tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
+9
-4
BlobTest.php
tests/Doctrine/Tests/DBAL/Types/BlobTest.php
+4
-3
BooleanTest.php
tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
+6
-4
DateIntervalTest.php
tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
+4
-3
DecimalTest.php
tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
+6
-4
FloatTest.php
tests/Doctrine/Tests/DBAL/Types/FloatTest.php
+6
-4
GuidTypeTest.php
tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
+8
-8
IntegerTest.php
tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
+6
-4
JsonArrayTest.php
tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
+9
-4
JsonTest.php
tests/Doctrine/Tests/DBAL/Types/JsonTest.php
+9
-4
ObjectTest.php
tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
+6
-4
SmallIntTest.php
tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
+6
-4
StringTest.php
tests/Doctrine/Tests/DBAL/Types/StringTest.php
+15
-5
VarDateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
+5
-4
No files found.
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
d3d09e29
...
...
@@ -53,7 +53,10 @@ class ConnectionTest extends DbalTestCase
$this
->
connection
=
DriverManager
::
getConnection
(
$this
->
params
);
}
public
function
getExecuteUpdateMockConnection
()
/**
* @return Connection|MockObject
*/
private
function
getExecuteUpdateMockConnection
()
{
$driverMock
=
$this
->
createMock
(
Driver
::
class
);
...
...
@@ -63,9 +66,11 @@ class ConnectionTest extends DbalTestCase
$this
->
createMock
(
DriverConnection
::
class
)
));
$platform
=
$this
->
getMockForAbstractClass
(
AbstractPlatform
::
class
);
return
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeUpdate'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
])
->
getMock
();
}
...
...
@@ -153,9 +158,8 @@ class ConnectionTest extends DbalTestCase
$driverMock
=
$this
->
createMock
(
Driver
::
class
);
$driverMock
->
expects
(
$this
->
at
(
0
))
->
method
(
'connect'
);
$platform
=
new
Mocks\MockPlatform
();
$conn
=
new
Connection
([
'platform'
=>
$platform
],
$driverMock
,
new
Configuration
(),
$eventManager
);
$conn
=
new
Connection
([],
$driverMock
,
new
Configuration
(),
$eventManager
);
$conn
->
connect
();
}
...
...
@@ -249,7 +253,7 @@ class ConnectionTest extends DbalTestCase
->
will
(
$this
->
returnValue
(
$this
->
createMock
(
DriverConnection
::
class
)
));
$conn
=
new
Connection
([
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
);
$conn
=
new
Connection
([],
$driverMock
);
$conn
->
setAutoCommit
(
false
);
...
...
@@ -271,7 +275,7 @@ class ConnectionTest extends DbalTestCase
->
will
(
$this
->
returnValue
(
$this
->
createMock
(
DriverConnection
::
class
)
));
$conn
=
new
Connection
([
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
);
$conn
=
new
Connection
([],
$driverMock
);
$conn
->
setAutoCommit
(
false
);
$conn
->
connect
();
...
...
@@ -291,7 +295,7 @@ class ConnectionTest extends DbalTestCase
->
will
(
$this
->
returnValue
(
$this
->
createMock
(
DriverConnection
::
class
)
));
$conn
=
new
Connection
([
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
);
$conn
=
new
Connection
([],
$driverMock
);
$conn
->
setAutoCommit
(
false
);
$conn
->
connect
();
...
...
@@ -311,7 +315,7 @@ class ConnectionTest extends DbalTestCase
->
will
(
$this
->
returnValue
(
$this
->
createMock
(
DriverConnection
::
class
)
));
$conn
=
new
Connection
([
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
);
$conn
=
new
Connection
([],
$driverMock
);
$conn
->
connect
();
$conn
->
beginTransaction
();
...
...
@@ -520,7 +524,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */
$conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeQuery'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
])
->
setConstructorArgs
([[],
$driverMock
])
->
getMock
();
$conn
->
expects
(
$this
->
once
())
...
...
@@ -556,7 +560,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */
$conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeQuery'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
])
->
setConstructorArgs
([[],
$driverMock
])
->
getMock
();
$conn
->
expects
(
$this
->
once
())
...
...
@@ -593,7 +597,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */
$conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeQuery'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
])
->
setConstructorArgs
([[],
$driverMock
])
->
getMock
();
$conn
->
expects
(
$this
->
once
())
...
...
@@ -628,7 +632,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */
$conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setMethods
([
'executeQuery'
])
->
setConstructorArgs
([[
'platform'
=>
new
Mocks\MockPlatform
()
],
$driverMock
])
->
setConstructorArgs
([[],
$driverMock
])
->
getMock
();
$conn
->
expects
(
$this
->
once
())
...
...
@@ -694,8 +698,8 @@ class ConnectionTest extends DbalTestCase
public
function
testCallConnectOnce
(
$method
,
$params
)
{
$driverMock
=
$this
->
createMock
(
Driver
::
class
);
$pdoMock
=
$this
->
createMock
(
\Doctrine\DBAL\Driver\
Connection
::
class
);
$platformMock
=
new
Mocks\MockPlatform
(
);
$pdoMock
=
$this
->
createMock
(
Connection
::
class
);
$platformMock
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$stmtMock
=
$this
->
createMock
(
Statement
::
class
);
$pdoMock
->
expects
(
$this
->
any
())
...
...
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
d3d09e29
...
...
@@ -9,9 +9,9 @@ use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver;
use
Doctrine\DBAL\Driver\PDOSqlite\Driver
as
PDOSqliteDriver
;
use
Doctrine\DBAL\Driver\SQLSrv\Driver
as
SQLSrvDriver
;
use
Doctrine\DBAL\DriverManager
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Sharding\PoolingShardConnection
;
use
Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
Doctrine\Tests\Mocks\ConnectionMock
;
use
Doctrine\Tests\Mocks\DriverMock
;
...
...
@@ -77,14 +77,14 @@ class DriverManagerTest extends DbalTestCase
*/
public
function
testCustomPlatform
()
{
$
mockPlatform
=
new
MockPlatform
(
);
$options
=
[
$
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$options
=
[
'pdo'
=>
new
PDO
(
'sqlite::memory:'
),
'platform'
=>
$
mockP
latform
,
'platform'
=>
$
p
latform
,
];
$conn
=
DriverManager
::
getConnection
(
$options
);
self
::
assertSame
(
$
mockP
latform
,
$conn
->
getDatabasePlatform
());
self
::
assertSame
(
$
p
latform
,
$conn
->
getDatabasePlatform
());
}
/**
...
...
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
deleted
100644 → 0
View file @
8cba2b09
<?php
namespace
Doctrine\Tests\DBAL\Mocks
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
class
MockPlatform
extends
AbstractPlatform
{
/**
* {@inheritDoc}
*/
public
function
getBlobTypeDeclarationSQL
(
array
$field
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* {@inheritDoc}
*/
public
function
getBooleanTypeDeclarationSQL
(
array
$columnDef
)
{
}
/**
* {@inheritDoc}
*/
public
function
getIntegerTypeDeclarationSQL
(
array
$columnDef
)
{
}
/**
* {@inheritDoc}
*/
public
function
getBigIntTypeDeclarationSQL
(
array
$columnDef
)
{
}
/**
* {@inheritDoc}
*/
public
function
getSmallIntTypeDeclarationSQL
(
array
$columnDef
)
{
}
/**
* {@inheritDoc}
*/
public
function
_getCommonIntegerTypeDeclarationSQL
(
array
$columnDef
)
{
}
/**
* {@inheritDoc}
*/
public
function
getVarcharTypeDeclarationSQL
(
array
$field
)
{
return
'DUMMYVARCHAR()'
;
}
/**
* {@inheritDoc}
*/
public
function
getClobTypeDeclarationSQL
(
array
$field
)
{
return
'DUMMYCLOB'
;
}
/**
* {@inheritdoc}
*/
public
function
getJsonTypeDeclarationSQL
(
array
$field
)
{
return
'DUMMYJSON'
;
}
/**
* {@inheritdoc}
*/
public
function
getBinaryTypeDeclarationSQL
(
array
$field
)
{
return
'DUMMYBINARY'
;
}
public
function
getVarcharDefaultLength
()
{
return
255
;
}
public
function
getName
()
{
return
'mock'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
}
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
}
}
tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php
View file @
d3d09e29
...
...
@@ -2,12 +2,13 @@
namespace
Doctrine\Tests\DBAL\Schema
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\ForeignKeyConstraint
;
use
Doctrine\DBAL\Schema\SchemaDiff
;
use
Doctrine\DBAL\Schema\Sequence
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
PHPUnit\Framework\TestCase
;
class
SchemaDiffTest
extends
TestCase
...
...
@@ -36,9 +37,13 @@ class SchemaDiffTest extends TestCase
self
::
assertEquals
(
$expected
,
$sql
);
}
public
function
createPlatform
(
$unsafe
=
false
)
/**
* @return AbstractPlatform|MockObject
*/
private
function
createPlatform
(
bool
$unsafe
)
{
$platform
=
$this
->
createMock
(
MockPlatform
::
class
);
/** @var AbstractPlatform|MockObject $platform */
$platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$platform
->
expects
(
$this
->
exactly
(
1
))
->
method
(
'getCreateSchemaSQL'
)
->
with
(
'foo_ns'
)
...
...
@@ -93,6 +98,7 @@ class SchemaDiffTest extends TestCase
$platform
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'supportsForeignKeyConstraints'
)
->
will
(
$this
->
returnValue
(
true
));
return
$platform
;
}
...
...
tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php
View file @
d3d09e29
...
...
@@ -2,14 +2,23 @@
namespace
Doctrine\Tests\DBAL\Schema
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Schema\Identifier
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
PHPUnit\Framework\TestCase
;
class
TableDiffTest
extends
TestCase
{
/** @var AbstractPlatform|MockObject */
private
$platform
;
public
function
setUp
()
:
void
{
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
}
/**
* @group DBAL-1013
*/
...
...
@@ -17,7 +26,7 @@ class TableDiffTest extends TestCase
{
$tableDiff
=
new
TableDiff
(
'foo'
);
self
::
assertEquals
(
new
Identifier
(
'foo'
),
$tableDiff
->
getName
(
new
MockPlatform
()
));
self
::
assertEquals
(
new
Identifier
(
'foo'
),
$tableDiff
->
getName
(
$this
->
platform
));
}
/**
...
...
@@ -25,8 +34,7 @@ class TableDiffTest extends TestCase
*/
public
function
testPrefersNameFromTableObject
()
{
$platformMock
=
new
MockPlatform
();
$tableMock
=
$this
->
getMockBuilder
(
Table
::
class
)
$tableMock
=
$this
->
getMockBuilder
(
Table
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
...
...
@@ -35,10 +43,10 @@ class TableDiffTest extends TestCase
$tableMock
->
expects
(
$this
->
once
())
->
method
(
'getQuotedName'
)
->
with
(
$
platformMock
)
->
with
(
$
this
->
platform
)
->
will
(
$this
->
returnValue
(
'foo'
));
self
::
assertEquals
(
new
Identifier
(
'foo'
),
$tableDiff
->
getName
(
$
platformMock
));
self
::
assertEquals
(
new
Identifier
(
'foo'
),
$tableDiff
->
getName
(
$
this
->
platform
));
}
/**
...
...
tests/Doctrine/Tests/DBAL/StatementTest.php
View file @
d3d09e29
...
...
@@ -10,7 +10,6 @@ use Doctrine\DBAL\Driver\Connection as DriverConnection;
use
Doctrine\DBAL\Logging\SQLLogger
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Statement
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
Exception
;
use
PDOStatement
;
...
...
@@ -31,19 +30,16 @@ class StatementTest extends DbalTestCase
$this
->
pdoStatement
=
$this
->
getMockBuilder
(
PDOStatement
::
class
)
->
setMethods
([
'execute'
,
'bindParam'
,
'bindValue'
])
->
getMock
();
$platform
=
new
MockPlatform
();
$driverConnection
=
$this
->
createMock
(
DriverConnection
::
class
);
$driverConnection
=
$this
->
createMock
(
DriverConnection
::
class
);
$driverConnection
->
expects
(
$this
->
any
())
->
method
(
'prepare'
)
->
will
(
$this
->
returnValue
(
$this
->
pdoStatement
));
$driver
=
$this
->
createMock
(
Driver
::
class
);
$constructorArgs
=
[
[
'platform'
=>
$platform
],
$driver
,
];
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setConstructorArgs
(
$constructorArgs
)
$driver
=
$this
->
createMock
(
Driver
::
class
);
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
setConstructorArgs
([[],
$driver
])
->
getMock
();
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getWrappedConnection'
)
...
...
tests/Doctrine/Tests/DBAL/Types/ArrayTest.php
View file @
d3d09e29
...
...
@@ -3,23 +3,24 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ArrayType
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
serialize
;
class
ArrayTest
extends
DbalTestCase
{
/** @var AbstractPlatform */
/** @var AbstractPlatform
|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Array
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'array'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
View file @
d3d09e29
...
...
@@ -4,9 +4,10 @@ namespace Doctrine\Tests\DBAL\Types;
use
DateTime
;
use
DateTimeImmutable
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
PHPUnit\Framework\TestCase
;
use
stdClass
;
use
function
date_default_timezone_get
;
...
...
@@ -14,7 +15,7 @@ use function date_default_timezone_set;
abstract
class
BaseDateTypeTestCase
extends
TestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
protected
$platform
;
/** @var Type */
...
...
@@ -28,7 +29,7 @@ abstract class BaseDateTypeTestCase extends TestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
getMockForAbstractClass
(
AbstractPlatform
::
class
);
$this
->
currentTimezone
=
date_default_timezone_get
();
self
::
assertInstanceOf
(
Type
::
class
,
$this
->
type
);
...
...
tests/Doctrine/Tests/DBAL/Types/BinaryTest.php
View file @
d3d09e29
...
...
@@ -3,18 +3,19 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\BinaryType
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
base64_encode
;
use
function
fopen
;
use
function
stream_get_contents
;
class
BinaryTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
protected
$platform
;
/** @var BinaryType */
...
...
@@ -25,7 +26,7 @@ class BinaryTest extends DbalTestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'binary'
);
}
...
...
@@ -41,7 +42,11 @@ class BinaryTest extends DbalTestCase
public
function
testReturnsSQLDeclaration
()
{
self
::
assertSame
(
'DUMMYBINARY'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getBinaryTypeDeclarationSQL'
)
->
willReturn
(
'TEST_BINARY'
);
self
::
assertSame
(
'TEST_BINARY'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
}
public
function
testBinaryNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/BlobTest.php
View file @
d3d09e29
...
...
@@ -2,10 +2,11 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\BlobType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
base64_encode
;
use
function
chr
;
use
function
fopen
;
...
...
@@ -13,7 +14,7 @@ use function stream_get_contents;
class
BlobTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
protected
$platform
;
/** @var BlobType */
...
...
@@ -24,7 +25,7 @@ class BlobTest extends DbalTestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'blob'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
View file @
d3d09e29
...
...
@@ -2,21 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\BooleanType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
BooleanTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Boolean
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
getMockForAbstractClass
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'boolean'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php
View file @
d3d09e29
...
...
@@ -4,16 +4,17 @@ namespace Doctrine\Tests\DBAL\Types;
use
DateInterval
;
use
DateTime
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\DateIntervalType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
stdClass
;
final
class
DateIntervalTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var DateIntervalType */
...
...
@@ -24,7 +25,7 @@ final class DateIntervalTest extends DbalTestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'dateinterval'
);
self
::
assertInstanceOf
(
DateIntervalType
::
class
,
$this
->
type
);
...
...
tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
View file @
d3d09e29
...
...
@@ -2,21 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\DecimalType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
DecimalTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Decimal
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'decimal'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/FloatTest.php
View file @
d3d09e29
...
...
@@ -2,21 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\FloatType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
FloatTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Float
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'float'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php
View file @
d3d09e29
...
...
@@ -2,22 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\GuidType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
function
get_class
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
GuidTypeTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Guid
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'guid'
);
}
...
...
@@ -36,11 +37,10 @@ class GuidTypeTest extends DbalTestCase
{
self
::
assertTrue
(
$this
->
type
->
requiresSQLCommentHint
(
$this
->
platform
));
$mock
=
$this
->
createMock
(
get_class
(
$this
->
platform
));
$mock
->
expects
(
$this
->
any
())
$this
->
platform
->
expects
(
$this
->
any
())
->
method
(
'hasNativeGuidType'
)
->
will
(
$this
->
returnValue
(
true
));
self
::
assertFalse
(
$this
->
type
->
requiresSQLCommentHint
(
$
mock
));
self
::
assertFalse
(
$this
->
type
->
requiresSQLCommentHint
(
$
this
->
platform
));
}
}
tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
View file @
d3d09e29
...
...
@@ -2,21 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\IntegerType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
IntegerTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Integer
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'integer'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php
View file @
d3d09e29
...
...
@@ -3,17 +3,18 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\JsonArrayType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
base64_encode
;
use
function
fopen
;
use
function
json_encode
;
class
JsonArrayTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
protected
$platform
;
/** @var JsonArrayType */
...
...
@@ -24,7 +25,7 @@ class JsonArrayTest extends DbalTestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'json_array'
);
}
...
...
@@ -40,7 +41,11 @@ class JsonArrayTest extends DbalTestCase
public
function
testReturnsSQLDeclaration
()
{
self
::
assertSame
(
'DUMMYJSON'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getJsonTypeDeclarationSQL'
)
->
willReturn
(
'TEST_JSON'
);
self
::
assertSame
(
'TEST_JSON'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
}
public
function
testJsonNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/JsonTest.php
View file @
d3d09e29
...
...
@@ -3,18 +3,19 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\ParameterType
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\JsonType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
function
base64_encode
;
use
function
fopen
;
use
function
json_encode
;
class
JsonTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
protected
$platform
;
/** @var JsonType */
...
...
@@ -25,7 +26,7 @@ class JsonTest extends DbalTestCase
*/
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'json'
);
}
...
...
@@ -41,7 +42,11 @@ class JsonTest extends DbalTestCase
public
function
testReturnsSQLDeclaration
()
{
self
::
assertSame
(
'DUMMYJSON'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getJsonTypeDeclarationSQL'
)
->
willReturn
(
'TEST_JSON'
);
self
::
assertSame
(
'TEST_JSON'
,
$this
->
type
->
getSQLDeclaration
([],
$this
->
platform
));
}
public
function
testJsonNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
View file @
d3d09e29
...
...
@@ -2,24 +2,26 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\ObjectType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
stdClass
;
use
function
serialize
;
class
ObjectTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
Object
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'object'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
View file @
d3d09e29
...
...
@@ -2,21 +2,23 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\SmallIntType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
SmallIntTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
SmallInt
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'smallint'
);
}
...
...
tests/Doctrine/Tests/DBAL/Types/StringTest.php
View file @
d3d09e29
...
...
@@ -2,31 +2,41 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\StringType
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
StringTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
String
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
$this
->
type
=
Type
::
getType
(
'string'
);
}
public
function
testReturnsSqlDeclarationFromPlatformVarchar
()
{
self
::
assertEquals
(
'DUMMYVARCHAR()'
,
$this
->
type
->
getSqlDeclaration
([],
$this
->
platform
));
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getVarcharTypeDeclarationSQL'
)
->
willReturn
(
'TEST_VARCHAR'
);
self
::
assertEquals
(
'TEST_VARCHAR'
,
$this
->
type
->
getSqlDeclaration
([],
$this
->
platform
));
}
public
function
testReturnsDefaultLengthFromPlatformVarchar
()
{
$this
->
platform
->
expects
(
$this
->
once
())
->
method
(
'getVarcharDefaultLength'
)
->
willReturn
(
255
);
self
::
assertEquals
(
255
,
$this
->
type
->
getDefaultLength
(
$this
->
platform
));
}
...
...
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
View file @
d3d09e29
...
...
@@ -3,23 +3,24 @@
namespace
Doctrine\Tests\DBAL\Types
;
use
DateTime
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Types\ConversionException
;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\VarDateTimeType
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
VarDateTimeTest
extends
DbalTestCase
{
/** @var
MockPlatform
*/
/** @var
AbstractPlatform|MockObject
*/
private
$platform
;
/** @var Type */
/** @var
VarDateTime
Type */
private
$type
;
protected
function
setUp
()
:
void
{
$this
->
platform
=
new
MockPlatform
(
);
$this
->
platform
=
$this
->
createMock
(
AbstractPlatform
::
class
);
if
(
!
Type
::
hasType
(
'vardatetime'
))
{
Type
::
addType
(
'vardatetime'
,
VarDateTimeType
::
class
);
}
...
...
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