// Enable the statement execution end event and execute a query, both
// events captured.
$this->connection->
enableEvents([StatementExecutionEndEvent::
class]);
$this->connection->
query('SELECT * FROM {test}'
);
$this->
assertSame(2,
$subscriber->countStatementStarts
);
$this->
assertSame(1,
$subscriber->countStatementEnds
);
$this->
assertEmpty($subscriber->statementIdsInExecution
);
$this->
assertTrue($this->connection->
isEventEnabled(StatementExecutionStartEvent::
class));
$this->
assertTrue($this->connection->
isEventEnabled(StatementExecutionEndEvent::
class));
// Disable both events, no more events captured.
$this->connection->
disableEvents([ StatementExecutionStartEvent::
class,
StatementExecutionEndEvent::
class,
]);
$this->connection->
query('SELECT * FROM {test}'
);
$this->
assertSame(2,
$subscriber->countStatementStarts
);
$this->
assertSame(1,
$subscriber->countStatementEnds
);
$this->
assertEmpty($subscriber->statementIdsInExecution
);
$this->
assertFalse($this->connection->
isEventEnabled(StatementExecutionStartEvent::
class));
$this->
assertFalse($this->connection->
isEventEnabled(StatementExecutionEndEvent::
class));
// Enable the statement execution end only, no events captured since the