Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerequisites for PHPUnit update to version 10 in 4.0.x #6066

Merged
merged 6 commits into from Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions psalm.xml.dist
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
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
@@ -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();
}
}
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
@@ -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();
}
}
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