Skip to content

Commit

Permalink
Merge pull request doctrine#6066 from morozov/pre-phpunit-10
Browse files Browse the repository at this point in the history
Prerequisites for PHPUnit update to version 10 in 4.0.x
  • Loading branch information
derrabus authored Jun 15, 2023
2 parents d4df00b + 41af257 commit e9b3de4
Show file tree
Hide file tree
Showing 56 changed files with 336 additions and 376 deletions.
6 changes: 3 additions & 3 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<file name="src/Types/ArrayType.php"/>
<file name="src/Types/ObjectType.php"/>
<file name="src/Types/Type.php"/>
<file name="tests/Schema/ComparatorTest.php"/>
<file name="tests/Schema/AbstractComparatorTestCase.php"/>
<!--
TODO: remove in 4.0.0
-->
Expand Down Expand Up @@ -747,8 +747,8 @@
or breaking API changes.
-->
<file name="src/Platforms/AbstractMySQLPlatform.php"/>
<file name="tests/Functional/Driver/AbstractDriverTest.php"/>
<file name="tests/Functional/Driver/AbstractDriverTestCase.php"/>

<!-- We're checking for invalid input. -->
<directory name="src/Driver/PgSQL"/>
<file name="src/Result.php"/>
Expand Down
6 changes: 3 additions & 3 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public function testCommitReturn(bool $expectedResult): void
}

/** @return bool[][] */
public function resultProvider(): array
public static function resultProvider(): array
{
return [[true], [false]];
}
Expand Down Expand Up @@ -745,7 +745,7 @@ public function testPlatformDetectionFetchedFromParameters(): void

$driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);

$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
$platformMock = $this->createMock(AbstractPlatform::class);

$connection = new Connection(['serverVersion' => '8.0'], $driverMock);

Expand All @@ -767,7 +767,7 @@ public function testPlatformDetectionFetchedFromPrimaryReplicaParameters(): void

$driverConnectionMock = $this->createMock(ServerInfoAwareConnection::class);

$platformMock = $this->getMockForAbstractClass(AbstractPlatform::class);
$platformMock = $this->createMock(AbstractPlatform::class);

$connection = new Connection(['primary' => ['serverVersion' => '8.0']], $driverMock);

Expand Down
59 changes: 0 additions & 59 deletions tests/Driver/AbstractDB2DriverTest.php

This file was deleted.

33 changes: 33 additions & 0 deletions tests/Driver/AbstractDB2DriverTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Doctrine\DBAL\Tests\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
use Doctrine\DBAL\Driver\API\IBMDB2\ExceptionConverter;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\DB2SchemaManager;

/** @extends AbstractDriverTestCase<DB2Platform> */
abstract class AbstractDB2DriverTestCase extends AbstractDriverTestCase
{
protected function createPlatform(): AbstractPlatform
{
return new DB2Platform();
}

protected function createSchemaManager(Connection $connection): AbstractSchemaManager
{
return new DB2SchemaManager(
$connection,
$this->createPlatform(),
);
}

protected function createExceptionConverter(): ExceptionConverterInterface
{
return new ExceptionConverter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
use PHPUnit\Framework\TestCase;
use ReflectionProperty;

use function get_class;
use function sprintf;

/** @template P of AbstractPlatform */
abstract class AbstractDriverTest extends TestCase
abstract class AbstractDriverTestCase extends TestCase
{
use VerifyDeprecations;

Expand All @@ -32,59 +29,6 @@ protected function setUp(): void
$this->driver = $this->createDriver();
}

public function testVersionAwarePlatformCreationIsTested(): void
{
if (! $this->driver instanceof VersionAwarePlatformDriver) {
self::markTestSkipped('This test is only intended for version aware platform drivers.');
}

self::assertNotEmpty(
static::getDatabasePlatformsForVersions(),
sprintf(
'No test data found for test %s. You have to return test data from %s.',
static::class . '::' . __FUNCTION__,
static::class . '::getDatabasePlatformsForVersions',
),
);
}

/**
* @param class-string<AbstractPlatform> $expectedPlatformClass
*
* @dataProvider getDatabasePlatformsForVersions
*/
public function testCreatesDatabasePlatformForVersion(
string $version,
string $expectedPlatformClass,
?string $deprecation = null,
?bool $expectDeprecation = null
): void {
if (! $this->driver instanceof VersionAwarePlatformDriver) {
self::markTestSkipped('This test is only intended for version aware platform drivers.');
}

if ($deprecation !== null) {
if ($expectDeprecation ?? true) {
$this->expectDeprecationWithIdentifier($deprecation);
} else {
$this->expectNoDeprecationWithIdentifier($deprecation);
}
}

$actualPlatform = $this->driver->createDatabasePlatformForVersion($version);

self::assertInstanceOf(
$expectedPlatformClass,
$actualPlatform,
sprintf(
'Expected platform for version "%s" should be "%s", "%s" given',
$version,
$expectedPlatformClass,
get_class($actualPlatform),
),
);
}

public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(): void
{
if (! $this->driver instanceof VersionAwarePlatformDriver) {
Expand Down
92 changes: 0 additions & 92 deletions tests/Driver/AbstractMySQLDriverTest.php

This file was deleted.

33 changes: 33 additions & 0 deletions tests/Driver/AbstractMySQLDriverTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Doctrine\DBAL\Tests\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\MySQL;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\MySQLSchemaManager;

/** @extends AbstractDriverTestCase<MySQLPlatform> */
abstract class AbstractMySQLDriverTestCase extends AbstractDriverTestCase
{
protected function createPlatform(): AbstractPlatform
{
return new MySQLPlatform();
}

protected function createSchemaManager(Connection $connection): AbstractSchemaManager
{
return new MySQLSchemaManager(
$connection,
$this->createPlatform(),
);
}

protected function createExceptionConverter(): ExceptionConverter
{
return new MySQL\ExceptionConverter();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@
namespace Doctrine\DBAL\Tests\Driver;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\API\ExceptionConverter;
use Doctrine\DBAL\Driver\API\OCI;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\OracleSchemaManager;

/** @extends AbstractDriverTest<OraclePlatform> */
class AbstractOracleDriverTest extends AbstractDriverTest
/** @extends AbstractDriverTestCase<OraclePlatform> */
abstract class AbstractOracleDriverTestCase extends AbstractDriverTestCase
{
protected function createDriver(): Driver
{
return $this->getMockForAbstractClass(AbstractOracleDriver::class);
}

protected function createPlatform(): AbstractPlatform
{
return new OraclePlatform();
Expand Down
Loading

0 comments on commit e9b3de4

Please sign in to comment.