Removed the rest of mock classes

parent 04cb1b41
...@@ -12,6 +12,7 @@ use Doctrine\DBAL\ConnectionException; ...@@ -12,6 +12,7 @@ use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Events; use Doctrine\DBAL\Events;
...@@ -21,10 +22,8 @@ use Doctrine\DBAL\Logging\DebugStack; ...@@ -21,10 +22,8 @@ use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Logging\EchoSQLLogger; use Doctrine\DBAL\Logging\EchoSQLLogger;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Mocks\DriverStatementMock;
use Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock;
use Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock;
use Exception; use Exception;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use stdClass; use stdClass;
...@@ -525,7 +524,7 @@ class ConnectionTest extends DbalTestCase ...@@ -525,7 +524,7 @@ class ConnectionTest extends DbalTestCase
$this->createMock(DriverConnection::class) $this->createMock(DriverConnection::class)
)); ));
$driverStatementMock = $this->createMock(DriverStatementMock::class); $driverStatementMock = $this->createMock(Statement::class);
$driverStatementMock->expects($this->once()) $driverStatementMock->expects($this->once())
->method('fetch') ->method('fetch')
...@@ -561,7 +560,7 @@ class ConnectionTest extends DbalTestCase ...@@ -561,7 +560,7 @@ class ConnectionTest extends DbalTestCase
$this->createMock(DriverConnection::class) $this->createMock(DriverConnection::class)
)); ));
$driverStatementMock = $this->createMock(DriverStatementMock::class); $driverStatementMock = $this->createMock(Statement::class);
$driverStatementMock->expects($this->once()) $driverStatementMock->expects($this->once())
->method('fetch') ->method('fetch')
...@@ -598,7 +597,7 @@ class ConnectionTest extends DbalTestCase ...@@ -598,7 +597,7 @@ class ConnectionTest extends DbalTestCase
$this->createMock(DriverConnection::class) $this->createMock(DriverConnection::class)
)); ));
$driverStatementMock = $this->createMock(DriverStatementMock::class); $driverStatementMock = $this->createMock(Statement::class);
$driverStatementMock->expects($this->once()) $driverStatementMock->expects($this->once())
->method('fetchColumn') ->method('fetchColumn')
...@@ -634,7 +633,7 @@ class ConnectionTest extends DbalTestCase ...@@ -634,7 +633,7 @@ class ConnectionTest extends DbalTestCase
$this->createMock(DriverConnection::class) $this->createMock(DriverConnection::class)
)); ));
$driverStatementMock = $this->createMock(DriverStatementMock::class); $driverStatementMock = $this->createMock(Statement::class);
$driverStatementMock->expects($this->once()) $driverStatementMock->expects($this->once())
->method('fetchAll') ->method('fetchAll')
...@@ -732,11 +731,11 @@ class ConnectionTest extends DbalTestCase ...@@ -732,11 +731,11 @@ class ConnectionTest extends DbalTestCase
*/ */
public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform()
{ {
/** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */
$driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
/** @var ServerInfoAwareConnectionMock|MockObject $driverConnectionMock */ /** @var ServerInfoAwareConnection|MockObject $driverConnectionMock */
$driverConnectionMock = $this->createMock(ServerInfoAwareConnectionMock::class); $driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);
/** @var AbstractPlatform|MockObject $platformMock */ /** @var AbstractPlatform|MockObject $platformMock */
$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
...@@ -861,8 +860,8 @@ class ConnectionTest extends DbalTestCase ...@@ -861,8 +860,8 @@ class ConnectionTest extends DbalTestCase
*/ */
public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase()
{ {
/** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */
$driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]);
$connection = new Connection(['dbname' => 'foo'], $driverMock); $connection = new Connection(['dbname' => 'foo'], $driverMock);
$originalException = new Exception('Original exception'); $originalException = new Exception('Original exception');
......
...@@ -4,12 +4,12 @@ namespace Doctrine\Tests\DBAL\Driver; ...@@ -4,12 +4,12 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform; use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\Schema\MySqlSchemaManager;
use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractMySQLDriverTest extends AbstractDriverTest class AbstractMySQLDriverTest extends AbstractDriverTest
{ {
...@@ -23,7 +23,7 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -23,7 +23,7 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
'password' => 'bar', 'password' => 'bar',
]; ];
$statement = $this->createMock(DriverResultStatementMock::class); $statement = $this->createMock(ResultStatement::class);
$statement->expects($this->once()) $statement->expects($this->once())
->method('fetchColumn') ->method('fetchColumn')
......
...@@ -4,13 +4,13 @@ namespace Doctrine\Tests\DBAL\Driver; ...@@ -4,13 +4,13 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform; use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
use Doctrine\DBAL\Platforms\PostgreSQL91Platform; use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
use Doctrine\DBAL\Platforms\PostgreSQL92Platform; use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractPostgreSQLDriverTest extends AbstractDriverTest class AbstractPostgreSQLDriverTest extends AbstractDriverTest
{ {
...@@ -24,7 +24,7 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest ...@@ -24,7 +24,7 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
'password' => 'bar', 'password' => 'bar',
]; ];
$statement = $this->createMock(DriverResultStatementMock::class); $statement = $this->createMock(ResultStatement::class);
$statement->expects($this->once()) $statement->expects($this->once())
->method('fetchColumn') ->method('fetchColumn')
......
...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType; ...@@ -8,7 +8,6 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Portability\Connection; use Doctrine\DBAL\Portability\Connection;
use Doctrine\DBAL\Portability\Statement; use Doctrine\DBAL\Portability\Statement;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Mocks\DriverStatementMock;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use ReflectionProperty; use ReflectionProperty;
use function iterator_to_array; use function iterator_to_array;
...@@ -29,7 +28,7 @@ class StatementTest extends DbalTestCase ...@@ -29,7 +28,7 @@ class StatementTest extends DbalTestCase
*/ */
protected function setUp() : void protected function setUp() : void
{ {
$this->wrappedStmt = $this->createWrappedStatement(); $this->wrappedStmt = $this->createMock(DriverStatement::class);
$this->conn = $this->createConnection(); $this->conn = $this->createConnection();
$this->stmt = $this->createStatement($this->wrappedStmt, $this->conn); $this->stmt = $this->createStatement($this->wrappedStmt, $this->conn);
} }
...@@ -179,12 +178,4 @@ class StatementTest extends DbalTestCase ...@@ -179,12 +178,4 @@ class StatementTest extends DbalTestCase
{ {
return new Statement($wrappedStatement, $connection); return new Statement($wrappedStatement, $connection);
} }
/**
* @return DriverStatement|MockObject
*/
protected function createWrappedStatement()
{
return $this->createMock(DriverStatementMock::class);
}
} }
<?php
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\ParameterType;
class DriverConnectionMock implements Connection
{
public function prepare($prepareString)
{
}
public function query()
{
}
public function quote($input, $type = ParameterType::STRING)
{
}
public function exec($statement)
{
}
public function lastInsertId($name = null)
{
}
public function beginTransaction()
{
}
public function commit()
{
}
public function rollBack()
{
}
public function errorCode()
{
}
public function errorInfo()
{
}
}
<?php
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\ResultStatement;
use IteratorAggregate;
interface DriverResultStatementMock extends ResultStatement, IteratorAggregate
{
}
<?php
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\Statement;
use IteratorAggregate;
interface DriverStatementMock extends Statement, IteratorAggregate
{
}
<?php
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
interface ServerInfoAwareConnectionMock extends Connection, ServerInfoAwareConnection
{
}
<?php
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\VersionAwarePlatformDriver;
interface VersionAwarePlatformDriverMock extends Driver, VersionAwarePlatformDriver
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment