From 808ba3f51b70d2e320440b2dc3a3506a89cf1efc Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 23 May 2019 16:35:29 -0700 Subject: [PATCH] Removed the rest of mock classes --- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 25 +++++----- .../DBAL/Driver/AbstractMySQLDriverTest.php | 4 +- .../Driver/AbstractPostgreSQLDriverTest.php | 4 +- .../Tests/DBAL/Portability/StatementTest.php | 11 +---- .../Tests/Mocks/DriverConnectionMock.php | 49 ------------------- .../Tests/Mocks/DriverResultStatementMock.php | 10 ---- .../Tests/Mocks/DriverStatementMock.php | 10 ---- .../Mocks/ServerInfoAwareConnectionMock.php | 10 ---- .../Mocks/VersionAwarePlatformDriverMock.php | 10 ---- 9 files changed, 17 insertions(+), 116 deletions(-) delete mode 100644 tests/Doctrine/Tests/Mocks/DriverConnectionMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/DriverResultStatementMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/DriverStatementMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/ServerInfoAwareConnectionMock.php delete mode 100644 tests/Doctrine/Tests/Mocks/VersionAwarePlatformDriverMock.php diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 3c3bc9f9b50..2b18a203e05 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Events; @@ -21,10 +22,8 @@ use Doctrine\DBAL\Logging\EchoSQLLogger; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\Tests\DbalTestCase; -use Doctrine\Tests\Mocks\DriverStatementMock; -use Doctrine\Tests\Mocks\ServerInfoAwareConnectionMock; -use Doctrine\Tests\Mocks\VersionAwarePlatformDriverMock; use Exception; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -525,7 +524,7 @@ public function testFetchAssoc() $this->createMock(DriverConnection::class) )); - $driverStatementMock = $this->createMock(DriverStatementMock::class); + $driverStatementMock = $this->createMock(Statement::class); $driverStatementMock->expects($this->once()) ->method('fetch') @@ -561,7 +560,7 @@ public function testFetchArray() $this->createMock(DriverConnection::class) )); - $driverStatementMock = $this->createMock(DriverStatementMock::class); + $driverStatementMock = $this->createMock(Statement::class); $driverStatementMock->expects($this->once()) ->method('fetch') @@ -598,7 +597,7 @@ public function testFetchColumn() $this->createMock(DriverConnection::class) )); - $driverStatementMock = $this->createMock(DriverStatementMock::class); + $driverStatementMock = $this->createMock(Statement::class); $driverStatementMock->expects($this->once()) ->method('fetchColumn') @@ -634,7 +633,7 @@ public function testFetchAll() $this->createMock(DriverConnection::class) )); - $driverStatementMock = $this->createMock(DriverStatementMock::class); + $driverStatementMock = $this->createMock(Statement::class); $driverStatementMock->expects($this->once()) ->method('fetchAll') @@ -732,11 +731,11 @@ public function testCallConnectOnce($method, $params) */ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() { - /** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ - $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); + /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */ + $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); - /** @var ServerInfoAwareConnectionMock|MockObject $driverConnectionMock */ - $driverConnectionMock = $this->createMock(ServerInfoAwareConnectionMock::class); + /** @var ServerInfoAwareConnection|MockObject $driverConnectionMock */ + $driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class); /** @var AbstractPlatform|MockObject $platformMock */ $platformMock = $this->getMockForAbstractClass(AbstractPlatform::class); @@ -861,8 +860,8 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void */ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() { - /** @var VersionAwarePlatformDriverMock|MockObject $driverMock */ - $driverMock = $this->createMock(VersionAwarePlatformDriverMock::class); + /** @var Driver|VersionAwarePlatformDriver|MockObject $driverMock */ + $driverMock = $this->createMock([Driver::class, VersionAwarePlatformDriver::class]); $connection = new Connection(['dbname' => 'foo'], $driverMock); $originalException = new Exception('Original exception'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php index 8a2374e2497..fdb1668f5a1 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php @@ -4,12 +4,12 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\AbstractMySQLDriver; +use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL80Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\MySqlSchemaManager; -use Doctrine\Tests\Mocks\DriverResultStatementMock; class AbstractMySQLDriverTest extends AbstractDriverTest { @@ -23,7 +23,7 @@ public function testReturnsDatabaseName() 'password' => 'bar', ]; - $statement = $this->createMock(DriverResultStatementMock::class); + $statement = $this->createMock(ResultStatement::class); $statement->expects($this->once()) ->method('fetchColumn') diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php index 2807a715c8b..1f508882484 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php @@ -4,13 +4,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; +use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; use Doctrine\DBAL\Platforms\PostgreSQL91Platform; use Doctrine\DBAL\Platforms\PostgreSQL92Platform; use Doctrine\DBAL\Platforms\PostgreSQL94Platform; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; -use Doctrine\Tests\Mocks\DriverResultStatementMock; class AbstractPostgreSQLDriverTest extends AbstractDriverTest { @@ -24,7 +24,7 @@ public function testReturnsDatabaseName() 'password' => 'bar', ]; - $statement = $this->createMock(DriverResultStatementMock::class); + $statement = $this->createMock(ResultStatement::class); $statement->expects($this->once()) ->method('fetchColumn') diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php index 74ace7cc042..4d0c066d618 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -8,7 +8,6 @@ use Doctrine\DBAL\Portability\Connection; use Doctrine\DBAL\Portability\Statement; use Doctrine\Tests\DbalTestCase; -use Doctrine\Tests\Mocks\DriverStatementMock; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; use function iterator_to_array; @@ -29,7 +28,7 @@ class StatementTest extends DbalTestCase */ protected function setUp() : void { - $this->wrappedStmt = $this->createWrappedStatement(); + $this->wrappedStmt = $this->createMock(DriverStatement::class); $this->conn = $this->createConnection(); $this->stmt = $this->createStatement($this->wrappedStmt, $this->conn); } @@ -179,12 +178,4 @@ protected function createStatement(DriverStatement $wrappedStatement, Connection { return new Statement($wrappedStatement, $connection); } - - /** - * @return DriverStatement|MockObject - */ - protected function createWrappedStatement() - { - return $this->createMock(DriverStatementMock::class); - } } diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php deleted file mode 100644 index fa22cc5f91b..00000000000 --- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php +++ /dev/null @@ -1,49 +0,0 @@ -