Skip to content

Commit

Permalink
Fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
DamienHarper committed Sep 2, 2024
1 parent af891c9 commit 035b3a7
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions tests/Provider/Doctrine/Event/DoctrineSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
use Doctrine\DBAL\Connection as ConnectionDbal;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\ServerVersionProvider;
use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\OnFlushEventArgs;
Expand Down Expand Up @@ -92,19 +94,24 @@ public function process($transaction): void

$nativeDriver = $this->createMock(Driver::class);
$dhDriver = new AuditorDriver($nativeDriver);
$driver = new class($dhDriver) implements VersionAwarePlatformDriver {
public function connect(array $params): void {}
$driver = new class($dhDriver) implements Driver {
public function __construct(private readonly Driver $dhDriver)
{
}

public function getDatabasePlatform(): void {}
public function connect(array $params): DriverConnection {
return $this->dhDriver->connect($params);
}

public function getSchemaManager(ConnectionDbal $conn, AbstractPlatform $platform): void {}
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform
{
return $this->dhDriver->getDatabasePlatform($versionProvider);
}

public function getExceptionConverter(): Driver\API\ExceptionConverter
{
return new ExceptionConverter();
}

public function createDatabasePlatformForVersion($version): void {}
};

$objectManager
Expand Down Expand Up @@ -141,19 +148,26 @@ public function process($transaction): void

$args = new OnFlushEventArgs($objectManager);

$driver = new class implements VersionAwarePlatformDriver {
public function connect(array $params): void {}
$nativeDriver = $this->createMock(Driver::class);
$dhDriver = new AuditorDriver($nativeDriver);
$driver = new class($dhDriver) implements Driver {
public function __construct(private readonly Driver $dhDriver)
{
}

public function getDatabasePlatform(): void {}
public function connect(array $params): DriverConnection {
return $this->dhDriver->connect($params);
}

public function getSchemaManager(ConnectionDbal $conn, AbstractPlatform $platform): void {}
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform
{
return $this->dhDriver->getDatabasePlatform($versionProvider);
}

public function getExceptionConverter(): Driver\API\ExceptionConverter
{
return new ExceptionConverter();
}

public function createDatabasePlatformForVersion($version): void {}
};

$objectManager
Expand Down

0 comments on commit 035b3a7

Please sign in to comment.