doctrine-test-bundle: Combining Sentry with this bundle breaks test when data is inserted

Follow-up from #194.

It appears that using Sentry in combination with this bundle, the tests break when new data is inserted into the database, with the cryptic (probably PDO) error “There is no active transaction”. Disabling Sentry in the test environment solves the issue for us.

It seemed the following caused the transaction to trigger:

class SomeTest extends KernelTestCase
{
  private Registry $doctrine;

  protected function setUp(): void
  {
    self::bootKernel();
    $this->doctrine = self::getContainer()->get('doctrine');
  }

  public function testSomething()
  {
    $entity = new Entity();

    $this->doctrine->getManager()->persist($entity);
    $this->doctrine->getManager()->flush();

    $this->assertTrue(true); // To avoid risky test warning
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Most upvoted comments

I currently don’t see a way to fix this 😕 In the end I decided to revert the fix that caused the issues. There are too many possible side-effects.

@dmaicher Thank you for your effort looking into this! Really appreciated 👏🏻

I still disabled Sentry tracing for our test environment (thank you for the suggestion @Marmelatze, I previously just disabled the whole bundle for test, but this has less impact).

Yes that works for me with enabled tracing.

yes, just noticed when setting up a small project to reproduce, that it works with DBAL 3 😃 Disabling sentry in test env is a suitable workaround (at least for me, as there is no error logging needed usually)

Unfortunately I cannot reproduce it. I tried installing https://github.com/getsentry/sentry-symfony on one of my apps. Tests are passing fine.

In case you can provide a minimal reproducer please let me know. Until then I will close here for now.