You are browsing the documentation for version 3.1 of OroCommerce, OroCRM and OroPlatform, which is no longer maintained. Read version 5.1 (the latest LTS version) of the Oro documentation to get up-to-date information.

See our Release Process documentation for more information on the currently supported and upcoming releases.

Additional Doctrine Events

Additional doctrine events are triggered during the execution of OroBundleTestFrameworkBundleTestWebTestCase.

OroComponentTestingDoctrineEvents::ON_AFTER_TEST_TRANSACTION_ROLLBACK (onAfterTestTransactionRollback)

This event is triggered when the transaction that provides functional test isolation is rolled back. This event is useful when you need to rollback changes made by the test fixture if the database is not the only one affected by these changes (e.g., cache)

Use the following code to subscribe to this event:

 1 use Doctrine\Common\DataFixtures\AbstractFixture;
 2 use Doctrine\Common\Persistence\ObjectManager;
 3 use Doctrine\DBAL\Event\ConnectionEventArgs;
 4 use Oro\Component\Testing\Doctrine\Events;
 6 class LoadSomeData extends AbstractFixture
 7 {
 8     public function load(ObjectManager $manager)
 9     {
10         // load data....
12         $manager->getConnection()
13             ->getEventManager()
14             ->addEventListener(Events::ON_AFTER_TEST_TRANSACTION_ROLLBACK, $this);
15     }
17     /**
18      * Will be executed when (if) this fixture will be rolled back
19      */
20     public function onAfterTestTransactionRollback(ConnectionEventArgs $args)
21     {
22         // do something (e.g. clear some caches)....
23     }
24 }