Skip to content

Commit

Permalink
allow symfony 7.0 (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored Sep 19, 2023
1 parent a3a039c commit ac45c76
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 26 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
- php: 8.2
symfony_require: 6.3.*
test_make_target: test
- php: 8.2
symfony_require: 7.0.*
stability: dev
test_make_target: test

steps:
- uses: actions/checkout@v2
Expand All @@ -52,6 +56,10 @@ jobs:
if: matrix.stability
run: composer config minimum-stability ${{ matrix.stability }}

- name: Remove behat/behat
if: matrix.symfony_require == '7.0.*'
run: composer remove behat/behat --no-update --dev

- name: Install symfony/flex
run: composer global config allow-plugins.symfony/flex true && composer global require symfony/flex

Expand All @@ -62,6 +70,7 @@ jobs:
run: make ${{ matrix.test_make_target }}

- name: Behat
if: matrix.symfony_require != '7.0.*'
run: make behat

php-stan:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"doctrine/dbal": "^3.3",
"doctrine/doctrine-bundle": "^2.2.2",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"symfony/cache": "^5.4 || ^6.2",
"symfony/framework-bundle": "^5.4 || ^6.2"
"symfony/cache": "^5.4 || ^6.2 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.2 || ^7.0"
},
"require-dev": {
"behat/behat": "^3.0",
"doctrine/cache": "^1.12",
"phpstan/phpstan": "^1.2",
"phpunit/phpunit": "^8.0 || ^9.0 || ^10.0",
"symfony/phpunit-bridge": "^6.2",
"symfony/process": "^5.4 || ^6.2",
"symfony/yaml": "^5.4 || ^6.2"
"symfony/process": "^5.4 || ^6.2 || ^7.0",
"symfony/yaml": "^5.4 || ^6.2 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down
38 changes: 20 additions & 18 deletions tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/MockDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@

class MockDriver implements Driver
{
private function getMock(string $class)
{
// TODO: remove this once we drop support for PHPUnit < 10
$generatorClass = class_exists('PHPUnit\Framework\MockObject\Generator')
? 'PHPUnit\Framework\MockObject\Generator'
: 'PHPUnit\Framework\MockObject\Generator\Generator';
private $connection;
private $schemaManager;
private $exceptionConverter;

/** @phpstan-ignore-next-line */
return (new $generatorClass())->getMock(
$class,
[],
[],
'',
false
);
/**
* @param Driver\Connection $connection
* @param AbstractSchemaManager $schemaManager
* @param ExceptionConverter $exceptionConverter
*/
public function __construct(
$connection,
$schemaManager,
$exceptionConverter
) {
$this->connection = $connection;
$this->schemaManager = $schemaManager;
$this->exceptionConverter = $exceptionConverter;
}

/**
* {@inheritdoc}
*/
public function connect(array $params): \Doctrine\DBAL\Driver\Connection
public function connect(array $params): Driver\Connection
{
return $this->getMock(Driver\Connection::class);
return clone $this->connection;
}

/**
Expand All @@ -49,7 +51,7 @@ public function getDatabasePlatform(): AbstractPlatform
*/
public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager
{
return $this->getMock(AbstractSchemaManager::class);
return $this->schemaManager;
}

/**
Expand All @@ -70,6 +72,6 @@ public function getDatabase(Connection $conn): string

public function getExceptionConverter(): ExceptionConverter
{
return $this->getMock(ExceptionConverter::class);
return $this->exceptionConverter;
}
}
20 changes: 16 additions & 4 deletions tests/DAMA/DoctrineTestBundle/Doctrine/DBAL/StaticDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@

class StaticDriverTest extends TestCase
{
private $driver;

protected function setUp(): void
{
parent::setUp();
$this->driver = new MockDriver(
$this->createMock('Doctrine\DBAL\Driver\Connection'),
$this->createMock('Doctrine\DBAL\Schema\AbstractSchemaManager'),
$this->createMock('Doctrine\DBAL\Driver\API\ExceptionConverter')
);
}

public function testConnect(): void
{
$driver = new StaticDriver(new MockDriver());
$driver = new StaticDriver($this->driver);

$driver::setKeepStaticConnections(true);

Expand All @@ -36,7 +48,7 @@ public function testConnect(): void
$this->assertInstanceOf(StaticConnection::class, $connection1);
$this->assertNotSame($connection1->getWrappedConnection(), $connection2->getWrappedConnection());

$driver = new StaticDriver(new MockDriver());
$driver = new StaticDriver($this->driver);

/** @var StaticConnection $connectionNew1 */
$connectionNew1 = $driver->connect(['dama.connection_name' => 'foo'] + $params);
Expand All @@ -59,7 +71,7 @@ public function testConnect(): void

public function testConnectWithPlatform(): void
{
$driver = new StaticDriver(new MockDriver());
$driver = new StaticDriver($this->driver);

$driver::setKeepStaticConnections(true);

Expand Down Expand Up @@ -92,7 +104,7 @@ public function testConnectWithPlatform(): void
$this->assertInstanceOf(StaticConnection::class, $connection1);
$this->assertNotSame($connection1->getWrappedConnection(), $connection2->getWrappedConnection());

$driver = new StaticDriver(new MockDriver());
$driver = new StaticDriver($this->driver);

/** @var StaticConnection $connectionNew1 */
$connectionNew1 = $driver->connect(['dama.connection_name' => 'foo'] + $params);
Expand Down

0 comments on commit ac45c76

Please sign in to comment.