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

Error when using ResetDatabase with DamaDoctrineTestBundle and Symfony Messenger with Doctrine #771

Open
javiereguiluz opened this issue Dec 27, 2024 · 1 comment · May be fixed by #779

Comments

@javiereguiluz
Copy link
Contributor

Related to #757. I spent some time fully understand when and why it fails. I found the cause, but I can't find a solution.

(1) The only way to avoid errors is to make this change:

bda4e15

(2) This is because whenever you use the ResetDatabase trait in tests, it will call that method. I added a debug_print_backtrace() in the BaseOrmResetter::dropAndResetDatabase() method and found this:

#0 vendor/zenstruck/foundry/src/ORM/ResetDatabase/SchemaDatabaseResetter.php(32): Zenstruck\Foundry\ORM\ResetDatabase\BaseOrmResetter->dropAndResetDatabase(Object(Symfony\Bundle\FrameworkBundle\Console\Application))
#1 vendor/zenstruck/foundry/src/ORM/ResetDatabase/DamaDatabaseResetter.php(46): Zenstruck\Foundry\ORM\ResetDatabase\SchemaDatabaseResetter->resetBeforeFirstTest(Object(App\Kernel))
#2 vendor/zenstruck/foundry/src/Persistence/ResetDatabase/ResetDatabaseManager.php(66): Zenstruck\Foundry\ORM\ResetDatabase\DamaDatabaseResetter->resetBeforeFirstTest(Object(App\Kernel))
#3 vendor/zenstruck/foundry/src/Test/ResetDatabase.php(35): Zenstruck\Foundry\Persistence\ResetDatabase\ResetDatabaseManager::resetBeforeFirstTest(Object(Closure), Object(Closure))
#4 vendor/bin/.phpunit/phpunit-9.6-0/src/Framework/TestSuite.php(629): App\Tests\Checkout\MerchantTest::_resetDatabaseBeforeFirstTest()
#5 vendor/bin/.phpunit/phpunit-9.6-0/src/Framework/TestSuite.php(685): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#6 vendor/bin/.phpunit/phpunit-9.6-0/src/Framework/TestSuite.php(685): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#7 vendor/bin/.phpunit/phpunit-9.6-0/src/TextUI/TestRunner.php(651): PHPUnit\Framework\TestSuite->run(Object(PHPUnit\Framework\TestResult))
#8 vendor/bin/.phpunit/phpunit-9.6-0/src/TextUI/Command.php(146): PHPUnit\TextUI\TestRunner->run(Object(PHPUnit\Framework\TestSuite), Array, Array, true)
#9 vendor/bin/.phpunit/phpunit-9.6-0/src/TextUI/Command.php(99): PHPUnit\TextUI\Command->run(Array, true)
#10 vendor/bin/.phpunit/phpunit-9.6-0/phpunit(22): PHPUnit\TextUI\Command::main()
#11 vendor/symfony/phpunit-bridge/bin/simple-phpunit.php(465): include('...')
#12 vendor/symfony/phpunit-bridge/bin/simple-phpunit(13): require('...')
#13 vendor/bin/simple-phpunit(119): include('...')

(3) I can't solve this with decoration. I defined my decorator like this:

services:
    App\Tests\DatabaseResetter:
        decorates: 'Zenstruck\Foundry\ORM\ResetDatabase\OrmResetter'
        arguments:
            - '@.inner'
        tags:
            - { name: '.foundry.persistence.database_resetter', priority: -10 }

Everything works and the decorator methods are called, etc.

BUT

This won't solve the problem. I must override the original logic of BaseOrmResetter::dropAndResetDatabase() and I can't decorate BaseOrmResetter, only OrmResetter


Can anybody please give me some help about what to do here? Thanks a lot!

@nikophil
Copy link
Member

Hi @javiereguiluz

after decorating, do you have several services tagged with .foundry.persistence.database_resetter?

I think the problem is the related than whan is reported here.

There might be a problem with the extension point...

@nikophil nikophil linked a pull request Jan 5, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants