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

[SF 5.3] Impossible to make functionnal test with SQLite: Operation 'AbstractPlatform::getListDatabasesSQL' is not supported by platform. #154

Closed
AlexandreGerault opened this issue Oct 21, 2021 · 42 comments · Fixed by #176

Comments

@AlexandreGerault
Copy link

Preconditions

My dependencies on a fresh Symfony app are:

"require": {
    "php": ">=7.4",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "composer/package-versions-deprecated": "1.11.99.4",
    "doctrine/doctrine-bundle": "^2.4",
    "doctrine/doctrine-migrations-bundle": "^3.2",
    "doctrine/orm": "^2.10",
    "symfony/console": "5.3.*",
    "symfony/dotenv": "5.3.*",
    "symfony/flex": "^1.3.1",
    "symfony/framework-bundle": "5.3.*",
    "symfony/proxy-manager-bridge": "5.3.*",
    "symfony/runtime": "5.3.*",
    "symfony/yaml": "5.3.*"
},
"require-dev": {
    "dama/doctrine-test-bundle": "^6.6",
    "doctrine/doctrine-fixtures-bundle": "^3.4",
    "liip/test-fixtures-bundle": "^2.0.0",
    "phpunit/phpunit": "^9.5",
    "symfony/browser-kit": "5.3.*",
    "symfony/css-selector": "5.3.*",
    "symfony/maker-bundle": "^1.34",
    "symfony/phpunit-bridge": "^5.3"
},
  1. PHP 7.4 & PHP 8
  2. Symfony 5.3

Steps to reproduce

  1. Install a fresh symfony application
symfony new app
cd app
composer require --dev phpunit/phpunit symfony/test-pack
  1. Create a WebTestCase in app/tests/DummyFunctionnalTest.php
  2. Install Doctrine and the maker bundle
composer require symfony/orm-pack
composer require --dev symfony/maker-bundle
  1. Set the DATABASE_URL in the .env.test file :
DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
  1. Create an entity with the maker
  2. Create a fixture that creates an entity
class PostFixtures extends Fixture
{
    public function load(ObjectManager $manager): void
    {
        $post = new Post();

        $post->setTitle("Titre");
        $post->setContent("Contenu");
        $post->setCreatedAt(new DateTimeImmutable());

        $manager->persist($post);
        $manager->flush();
    }
}
  1. Install LiipTestFixturesBundle:
composer require --dev liip/test-fixtures-bundle:^2.0.0
  1. Write a test :
class DummyFunctionalTest extends WebTestCase
{
    protected KernelBrowser $client;
    private AbstractDatabaseTool $databaseTool;

    protected function setUp(): void
    {
        parent::setUp();

        $this->client = static::createClient();
        $this->databaseTool = $this->client->getContainer()->get(DatabaseToolCollection::class)->get();
    }

    public function testDummy(): void
    {
        $this->databaseTool->loadFixtures([PostFixtures::class]);

        $this->assertNotNull($this->client->getContainer()->get(PostRepository::class)->findAll());
    }
}
  1. Run the tests

Expected result

  1. I expect the test to run and reach the assert statement

Actual result

I got this error when I run tests:

./bin/phpunit
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Testing 
E                                                                   1 / 1 (100%)

Time: 00:00.100, Memory: 16.00 MB

There was 1 error:

1) App\Tests\DummyIntegrationTest::testDummy
Doctrine\DBAL\Exception: Operation 'Doctrine\DBAL\Platforms\AbstractPlatform::getListDatabasesSQL' is not supported by platform.

/app/vendor/doctrine/dbal/src/Exception.php:22
/app/vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:2749
/app/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:102
/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:163
/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:60
/app/tests/DummyFunctionalTest.php:27

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
@AlexandreGerault
Copy link
Author

I looked at the source code reported by the error stacktrace. The AbstractPlatform::getListDatabaseSQL is a function that is defined only for throwing an Exception when it is not overriding by a child class. Looking at the SqlitePlatform child class, I found no definitions for getListDatabaseSQL thus it is normal for the code to throw an exception.

The code from Doctrine\DBAL\Platforms\AbstractPlatform throwing the error is:

public function getListDatabasesSQL()
{
    throw Exception::notSupported(__METHOD__);
}

Called from the LiipTestFixturesBundle in the Services/DatabaseTools/ORMDatabaseTool class:

protected function createDatabaseIfNotExists(): void
{
    $params = $this->connection->getParams();
    if (isset($params['master'])) {
        $params = $params['master'];
    }
    $dbName = $params['dbname'] ?? '';

    unset($params['dbname'], $params['url']);

    // Unset url to avoid issue:
    // “An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'test'”

    $tmpConnection = DriverManager::getConnection($params);
    $tmpConnection->connect();

    // The '->listDatabases' is the one that calls the AbstractPlatform::getListDatabasesSQL method
    if (!\in_array($dbName, $tmpConnection->getSchemaManager()->listDatabases(), true)) {
        $tmpConnection->getSchemaManager()->createDatabase($dbName);
    }

    $tmpConnection->close();
}

However I have no idea how I could solve that myself unfortunately

@AlexandreGerault
Copy link
Author

AlexandreGerault commented Oct 21, 2021

As SQLite seems to work on unique database this should not be possible to list databases. Thus a way to handle it could be creating the database anyway in a Sqlite context, kinda like this (that works in this specific case):

protected function createDatabaseIfNotExists(): void
{
    $params = $this->connection->getParams();
    if (isset($params['master'])) {
        $params = $params['master'];
    }
    $dbName = $params['dbname'] ?? '';

    unset($params['dbname'], $params['url']);

    // Unset url to avoid issue:
    // “An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'test'”

    $tmpConnection = DriverManager::getConnection($params);
    $tmpConnection->connect();
    
    $databases = $tmpConnection->getDatabasePlatform() instanceof SqlitePlatform
        ? ['']
        : $tmpConnection->getSchemaManager()->listDatabases();

    if (!\in_array($dbName, $databases, true)) {
        $tmpConnection->getSchemaManager()->createDatabase($dbName);
    }

    $tmpConnection->close();
}

EDIT: I ended testing it by forking the repo and it seems it does not break the actual tests suite

@alexislefebvre
Copy link
Collaborator

What versions of liip/test-fixtures-bundle and doctrine/dbal are used? The last version of liip/test-fixtures-bundle declares a conflict with doctrine/dbal to avoid this issue: #152 (comment)

@AlexandreGerault
Copy link
Author

Looking at composer.lock I have doctrine/dbal version 3.1.3 and liip/test-fixtures-bundle version 2.1.0

@alexislefebvre
Copy link
Collaborator

alexislefebvre commented Oct 22, 2021

3.1.3 is the version that was used to run tests 2 days ago: https://github.com/liip/LiipTestFixturesBundle/runs/3951469875?check_suite_focus=true#step:8:141

Maybe it works because the tests don't use an URL for sqlite:

doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.cache_dir%/test.db"
charset: UTF8

We can override createDatabaseIfNotExists in the ORMSqliteDatabaseTool class.

@AlexandreGerault
Copy link
Author

AlexandreGerault commented Oct 22, 2021

If you think that's the way to go I can take time to submit a PR.

But what I don't get is how this createDatabaseIfNotExists is being called on a sqlite database. Indeed, when I searched for occurences of the createDatabaseIfNotExists I find it is used only in ORMDatabaseTool::loadFixtures method.

But this method is beeing overrided in the ORMSqliteDatabaseTool class and thus isn't calling the createDatabaseIfNotExists method 🤔

Also, I ran the SQLite tests with some dumping and it never reach the code in createDatabaseIfNotExists... Wonder why it then happens when using in Symfony

Edit: I'm really interested to understand the difference since it can means some working behavior isn't covered by tests... But I don't get why has the tests really looks like the one we write in a Symfony application (for an integration/functional test)

@alexislefebvre
Copy link
Collaborator

I added tests with SQLite and URL in #155

@alexislefebvre
Copy link
Collaborator

@AlexandreGerault ORMSqliteDatabaseTool extends ORMDatabaseTool, so createDatabaseIfNotExists is called.

@AlexandreGerault
Copy link
Author

Yeah, I saw for this inheritance. But what I don't get is that the only place createDatabaseIfNotExists is called is in ORMDatabaseTool::loadFixtures which is overrided in ORMSqliteDatabaseTool::loadFixtures. And it this last method, no createDatabaseIfNotExists is called, is it?

@alexislefebvre
Copy link
Collaborator

Right, I missed that loadFixtures() was overridden for SQLite. (and I forgot we had so much duplicated code 😅)

@alexislefebvre
Copy link
Collaborator

alexislefebvre commented Oct 23, 2021

Please add this check before $this->databaseTool->loadFixtures([PostFixtures::class]); in your test:

$this->assertInstanceOf(
    \Liip\TestFixturesBundle\Services\DatabaseTools\ORMSqliteDatabaseTool::class,
    $this->databaseTool
);

We'll probably see that the bundle returns the ORM database tool instead of the specific SQLite one.


Could you please put the sources of your example on a GitHub repo? I followed the steps and it worked for me, I had to install doctrine/data-fixtures and doctrine/doctrine-fixtures-bundle. And I didn't find a Doctrine class that match with extends Fixture, so I extended Doctrine\Common\DataFixtures\AbstractFixture and registered the class as a fixture. I may have a configuration different from yours.

@AlexandreGerault
Copy link
Author

AlexandreGerault commented Oct 23, 2021

Here is the basic sources to produce the error: https://github.com/AlexandreGerault/debug-liip-test-fixtures-bundle

Now I'll make another branch with your test (it's failing): https://github.com/AlexandreGerault/debug-liip-test-fixtures-bundle/tree/debug/add-instance-of-sqlite-tool

@alexislefebvre
Copy link
Collaborator

I put my test projet on GitHub, please try it:

git clone git@github.com:alexislefebvre/LiipTestFixturesBundle-issue-154.git
cd LiipTestFixturesBundle-issue-154/
composer install
vendor/bin/phpunit --testdox

I have no error on my local environment, it uses PHP 7.4, not 8.0, but I don't think it should cause issues.

@alexislefebvre
Copy link
Collaborator

I missed that your project use DAMADoctrineTestBundle, please try this: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/caveats.md#damadoctrinetestbundle

@AlexandreGerault
Copy link
Author

AlexandreGerault commented Oct 23, 2021

To put in the config/packages/test/framework.yaml ?

EDIT: Now I'e just the error telling I've no table

@alexislefebvre
Copy link
Collaborator

I added a missing information on the doc, you have to create the database and schema before running your tests: https://github.com/liip/LiipTestFixturesBundle/blob/2.x/doc/configuration.md#configuration

@PapyDanone
Copy link

FYI I am having the same issue with:

  • symfony/framework-bundle 5.3.10
  • doctrine/dbal 3.1.4
  • liip/test-fixtures-bundle 2.1.0
  • liip/functional-test-bundle 4.4.3

Note that I'm not using DAMADoctrineBundle but changing keep_database_and_schema to true + re-creating the SQLite database before running the tests fixed it 👍

liip_test_fixtures:
    cache_db:
        sqlite: 'Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup'
    keep_database_and_schema: true
    cache_metadata: true

@alexislefebvre
Copy link
Collaborator

alexislefebvre commented Feb 1, 2022

@AlexandreGerault I was able to have another error message with your project by changing the doctrine config to this:

doctrine:
    dbal:
        driver: pdo_sqlite
        url: "%kernel.cache_dir%/test.db"

(instead of this config)

Could you please test and see if it gives you different results?

@flohw
Copy link

flohw commented Feb 8, 2022

Hi @alexislefebvre,

I encountered the same issue. I applied the patch provided in the close pr to make my tests work on my computer for now (but they fail in the CI due to this issue but this is normal at this point)

I tried the configuration you provide but ended in the same result.
Something to notice : url is defined with env(resolve:DATABASE_URL) and my .env.test contains DATABASE_URL=sqlite:///%kernel.project_dir%/var/data.db.

Here is my complete configuration in my config/packags/test/doctrine.yaml:

doctrine:
  dbal:
    logging: false
    schema_filter: ~
    driver: pdo_sqlite
    url: null
  orm:
    dql:
      datetime_functions:
        Year:        DoctrineExtensions\Query\Sqlite\Year

And the configuration in my config/packages/doctrine.yaml:

doctrine:
    dbal:
        # backtrace queries in profiler (increases memory usage per request)
        #profiling_collect_backtrace: '%kernel.debug%'
        server_version: '8'
        charset: utf8mb4
        url: '%env(resolve:DATABASE_URL)%'
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci
# ... A lot of configuration related to the project

[EDIT]: here is may configuration of config/test/liip_test_fixtures.yaml just in case it's needed:

liip_test_fixtures:
  cache_db:
    sqlite: Liip\TestFixturesBundle\Services\DatabaseBackup\SqliteDatabaseBackup

Tell me if you need more information or tests. I am working on the project every day and can provide quick feedback.

Thank you

@flohw
Copy link

flohw commented Feb 8, 2022

Sorry, I missed some part of the configuration... Here is the right errors with right configuration.

Error (with PR patch applied, same previous error when patch not applied):
InvalidArgumentException: Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.. But I think this is an expected error.

Stack trace /symfony/server/vendor/liip/test-fixtures-bundle/src/Services/DatabaseBackup/SqliteDatabaseBackup.php:68 /symfony/server/vendor/liip/test-fixtures-bundle/src/Services/DatabaseBackup/SqliteDatabaseBackup.php:46 /symfony/server/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:124 /symfony/server/tests/Functional/WebTestCase.php:29 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestResult.php:726 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:670

Note : as the project also have an Angular client, the Symfony app is in /symfony/server (in a docker container)

adding the configuration doctrine.dbal.path: '%env(resolve:DATABASE_URL)%' in my config/test/doctrine.yaml file create another error:
PDOException: SQLSTATE[HY000] [14] unable to open database file

Stack trace /symfony/server/vendor/doctrine/dbal/src/Driver/PDO/SQLite/Driver.php:42 /symfony/server/vendor/doctrine/dbal/src/Connection.php:325 /symfony/server/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:162 /symfony/server/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:61 /symfony/server/tests/Functional/WebTestCase.php:29 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestResult.php:726 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/Framework/TestSuite.php:678 /symfony/server/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:670

Just in case here this is the content of our custom WebTestCase:

Functional\Tests\WebTestCase
<?php

namespace Functional\Tests;

use Doctrine\Common\DataFixtures\ReferenceRepository;
use Factory\Tests\Administration\User\AdminUserFactory;
use Fixtures\Tests\Entity\Administration\User\AdminUserFixtures;
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
use Symfony\Component\BrowserKit\Cookie;
use Zenstruck\Browser\KernelBrowser;
use Zenstruck\Browser\Response\JsonResponse;
use Zenstruck\Browser\Test\HasBrowser;
use Zenstruck\Foundry\Test\Factories;

class WebTestCase extends \Liip\FunctionalTestBundle\Test\WebTestCase
{
    use Factories;
    use HasBrowser;

    protected AbstractDatabaseTool $databaseTool;
    protected ReferenceRepository $fixtures;

    protected function setUp(): void
    {
        parent::setUp();
        $this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get();
        $this->databaseTool->loadFixtures([
            AdminUserFixtures::class,
        ]);
    }

    protected function loadFixtures(array $classNames): void
    {
        $this->fixtures = $this->databaseTool->loadFixtures($classNames, true)->getReferenceRepository();
    }

    protected function createAdminClient(): KernelBrowser
    {
        return $this->createAuthenticatedClient(AdminUserFactory::ADMIN_USERNAME, 'password');
    }

    protected function createAuthenticatedClient(string $username, string $password): KernelBrowser
    {
        $response = $this->browser()
            ->post('/api/login_check', [
                'body' => [
                    'username' => $username,
                    'password' => $password,
                ],
            ])
            ->assertJson()
            ->use(function (JsonResponse $response) use ($username, $password) {
                self::assertTrue($response->isSuccessful(), "Cannot login user with $username:$password");
                $response->search('token');
            })->response();

        $browser = $this->browser();
        $browser->cookies()->set(new Cookie('JWT', $response->json()['token']));

        return $browser;
    }
}

@bjalt
Copy link

bjalt commented Feb 10, 2022

It's not directly related to the minimal project configuration at the beginning of the ticket, but I found the cause for my project to be the getsentry/sentry-symfony tracing to cause the exact same error message. Disabling the tracing fixed the issue.

@flohw
Copy link

flohw commented Feb 10, 2022

@bjalt Hi

Could you elaborate a bit more? I can't find this tracing option and don't understand what it is.
Should the issue be reported on sentry repository?

Thank you

@bjalt
Copy link

bjalt commented Feb 10, 2022

@flohw This is only relevant if you have a dependency on sentry/sentry-symfony:

Sentry can collect performance information which include database performance. To do this they need to decorate the database abstraction, which seems to cause the issue.
This is enabled by default and can be deactivated in the configuration:

# config/packages/sentry.yaml
sentry:
    tracing:
        enabled: false

@AlexandreGerault
Copy link
Author

@AlexandreGerault I was able to have another error message with your project by changing the doctrine config to this:

doctrine:
    dbal:
        driver: pdo_sqlite
        url: "%kernel.cache_dir%/test.db"

(instead of this config)

Could you please test and see if it gives you different results?

As soon as I've free time this week-end I'll test

@flohw
Copy link

flohw commented Feb 10, 2022

@flohw This is only relevant if you have a dependency on sentry/sentry-symfony:

Which I use 😉

Your solution works for me too. I will keep an eye here to provide other information if needed et try to look on the sentry one for the same purpose.

Thanks

@alexislefebvre
Copy link
Collaborator

@flohw This is only relevant if you have a dependency on sentry/sentry-symfony:

Sentry can collect performance information which include database performance. To do this they need to decorate the database abstraction, which seems to cause the issue. This is enabled by default and can be deactivated in the configuration:

# config/packages/sentry.yaml
sentry:
    tracing:
        enabled: false

That's a very nice finding! Sentry can be disabled only in the test environment:

# config/packages/test/sentry.yaml
sentry:
    tracing:
        enabled: false

@darthf1
Copy link

darthf1 commented Mar 30, 2022

Same issue, but with

"doctrine/doctrine-bundle": "2.6.0",
Testing /home/www/app/tests/Functional/Infrastructure/Download

Doctrine\DBAL\Exception : Operation 'Doctrine\DBAL\Platforms\AbstractPlatform::getListDatabasesSQL' is not supported by platform.
 /home/www/app/vendor/doctrine/dbal/src/Exception.php:22
 /home/www/app/vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:3059
 /home/www/app/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:115
 /home/www/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:163
 /home/www/app/vendor/liip/test-fixtures-bundle/src/Services/DatabaseTools/ORMDatabaseTool.php:60
 /home/www/app/tests/Functional/FixtureTestCase.php:37
 /home/www/app/tests/Functional/Infrastructure/Download/RequestDownloadBuilderTest.php:39

@77web
Copy link

77web commented Mar 30, 2022

I'm having same issue now :(

I dig into code and found $driverName is Doctrine\DBAL\Logging\Driver not Doctrine\DBAL\Driver\PDO\SQLite\Driver here 👇
https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Services/DatabaseToolCollection.php#L50

doctrine/dbal 3.3.4
doctrine/orm 2.11.2
symfony/doctrine-bridge 6.0.6


edit:

It seems that getDriverName() in DatabaseTool is just a string 👇
https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php#L37-L40

Then can't we use DatabasePlatform not DriverName to resolve appropriate DatabaseTool here?

@alexislefebvre
Copy link
Collaborator

@darthf1 and @77web please tell if the solution in this comment doesn't work for you. Do you use a package that decorate the connection to the database?

@77web
Copy link

77web commented Mar 30, 2022

@alexislefebvre no, I never use sentry.
I tried setting logging&profiling to false in dbal config, but nothing changed.

@darthf1
Copy link

darthf1 commented Mar 30, 2022

@darthf1 and @77web please tell if the solution in this comment doesn't work for you. Do you use a package that decorate the connection to the database?

Nope, sentry is disabled for me in the dev and test environment.

@77web
Copy link

77web commented Mar 30, 2022

It seems that dbal silently started using their logging middleware by default? 🤔️

@77web
Copy link

77web commented Mar 30, 2022

maybe doctrine/doctrine-bundle v2.6.0 is the cause:
https://github.com/doctrine/DoctrineBundle/releases/tag/2.6.0

doctrine/DoctrineBundle#1456 thanks to @l-vo

@stopfstedt
Copy link

encountering the described error after upgrading to doctrine-bundle v2.6.0 today, for the first time.
using version 2.1.1 of this bundle, running on PHP 8.1.

@77web
Copy link

77web commented Mar 30, 2022

Temporarily solved my problem by downgrading doctrine/doctrine-bundle to 2.5.x.
But it will occur again in the near future :(

@alexislefebvre
Copy link
Collaborator

Maybe we can find a way to disable this middleware, if it can fix the issue.

@alexislefebvre
Copy link
Collaborator

alexislefebvre commented Mar 31, 2022

I found one difference while using different versions of doctrine/doctrine-bundle, on this line:

$driverName = ('ORM' === $registry->getName()) ? \get_class($registry->getConnection()->getDriver()) : 'default';

With v2.6.0 it returns Doctrine\DBAL\Logging\Driver.
With v2.5.7 it returns Doctrine\DBAL\Driver\PDO\MySQL\Driver.

With 2.6.0, it won't find the item for SQLite in the following nice, so it returns the default configuration, and the ORMSqliteDatabaseTool is not used when it should have been.

We have to rewrite how the type of database is detected, because Doctrine\DBAL\Logging\Driver is hiding it.

@77web
Copy link

77web commented Mar 31, 2022

@alexislefebvre
yes, I mentioned it in comment yesterday 😅

It seems that getDriverName() in DatabaseTool is just a string 👇
https://github.com/liip/LiipTestFixturesBundle/blob/2.x/src/Services/DatabaseTools/ORMSqliteDatabaseTool.php#L37-L40
Then can't we use DatabasePlatform not DriverName to resolve appropriate DatabaseTool here?

I'm not familiar with PHPCR and MongoDBODM, so I thought why not use DatabasePlatform to distinguish db type...

@alexislefebvre
Copy link
Collaborator

I'm sorry I missed your comment.

I'm not familiar with how the driver is loaded, it's still black magic for me. Feel free to submit a PR if you have an idea.

@ndench
Copy link
Contributor

ndench commented Apr 1, 2022

It appears that DoctrineBundle 2.6.0 now injects middlewares all the time (https://github.com/doctrine/DoctrineBundle/pull/1472/files#diff-36d403fbfadb131317c08db172ddbb7844ce35323d45c6096043b97ed066b60a)? I stepped through the code and even though I have both logging: false and profiling: false in my config/test/doctrine.yaml it's still injecting the LoggingMiddleware.

I'm not sure that we need to rewrite how the database is detected as much as we need to figure out how to disable the middlewares in the test environment? From what I can see, there's no way to remove them. If a MiddlewareInterface exists it's auto tagged and auto injected.

@ndench
Copy link
Contributor

ndench commented Apr 1, 2022

Ok, I lied. After a bit more investigation I've found another way we can detect the type of database. Created PR #176 to fix it. If you're having this issue please install my fork and let me know if it works for you.

@alexislefebvre
Copy link
Collaborator

@ndench thanks, this PR was merged.

Please try the last release: https://github.com/liip/LiipTestFixturesBundle/releases/tag/2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants