Current Behavior
The tests implemented in #4833 are missing to test the behaviour when the application code creates a transaction in it self (results in a nested transaction).
The fix in #4833 leads to that an event marked with ShouldDispatchAfterCommit is dispatched to early during tests.
Steps to Reproduce
Extend the AfterCommitListenerTest test case with following code and resolve deps:
#[Test]
public function after_commit_event_is_dispatched_after_a_transaction(): void
{
$this->extend(
(new Extend\Event())->listen(AfterCommitDispatchableEvent::class, function () use (&$ran) {
$ran = true;
})
);
$this->connection()->beginTransaction();
$this->app()->getContainer()->make(Dispatcher::class)->dispatch(new AfterCommitDispatchableEvent());
$this->assertFalse(
$ran,
'A ShouldDispatchAfterCommit event should not be dispatched during a nested transaction in a test.'
);
$this->connection()->commit();
$this->assertTrue(
$ran,
'A ShouldDispatchAfterCommit event should be dispatched during an integration test.'
);
}
private function connection(): ConnectionInterface
{
return $this->app()->getContainer()->make(ConnectionInterface::class);
}
Expected Behavior
test should run
Screenshots
No response
Environment
- Flarum version: 2.0.0-rc.8
- Website URL: http://example.com
- Webserver: [e.g. apache, nginx]
- Hosting environment: [e.g. shared, vps]
- PHP version: x.y.z
- Database: [e.g. MySQL 8.4.11, MariaDB 10.11.2, PostgreSQL 16.1, SQLite 3.45]
- Browser: [e.g. chrome 67, safari 11]
Output of php flarum info
Output of "php flarum info", run this in terminal in your Flarum directory.
Possible Solution
No response
Additional Context
No response
Current Behavior
The tests implemented in #4833 are missing to test the behaviour when the application code creates a transaction in it self (results in a nested transaction).
The fix in #4833 leads to that an event marked with ShouldDispatchAfterCommit is dispatched to early during tests.
Steps to Reproduce
Extend the AfterCommitListenerTest test case with following code and resolve deps:
Expected Behavior
test should run
Screenshots
No response
Environment
Output of
php flarum infoPossible Solution
No response
Additional Context
No response