function DatabaseEventsTest::testEventEnablingAndDisabling
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Database/DatabaseEventsTest.php \Drupal\Tests\Core\Database\DatabaseEventsTest::testEventEnablingAndDisabling()
@covers ::isEventEnabled @covers ::enableEvents @covers ::disableEvents
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ DatabaseEventsTest.php, line 44
Class
- DatabaseEventsTest
- @coversDefaultClass \Drupal\Core\Database\Connection
Namespace
Drupal\Tests\Core\DatabaseCode
public function testEventEnablingAndDisabling() : void {
$this->connection
->enableEvents(StatementEvent::all());
$this->assertTrue($this->connection
->isEventEnabled(StatementExecutionStartEvent::class));
$this->assertTrue($this->connection
->isEventEnabled(StatementExecutionEndEvent::class));
$this->assertTrue($this->connection
->isEventEnabled(StatementExecutionFailureEvent::class));
$this->connection
->disableEvents([
StatementExecutionEndEvent::class,
]);
$this->assertTrue($this->connection
->isEventEnabled(StatementExecutionStartEvent::class));
$this->assertFalse($this->connection
->isEventEnabled(StatementExecutionEndEvent::class));
$this->assertTrue($this->connection
->isEventEnabled(StatementExecutionFailureEvent::class));
$this->connection
->disableEvents(StatementEvent::all());
$this->assertFalse($this->connection
->isEventEnabled(StatementExecutionStartEvent::class));
$this->assertFalse($this->connection
->isEventEnabled(StatementExecutionEndEvent::class));
$this->assertFalse($this->connection
->isEventEnabled(StatementExecutionFailureEvent::class));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.