// Execute a query, still no events captured.
$this->connection->
query('SELECT * FROM {test}'
);
$this->
assertSame(0,
$subscriber->countStatementStarts
);
$this->
assertSame(0,
$subscriber->countStatementEnds
);
$this->
assertEmpty($subscriber->statementIdsInExecution
);
$this->
assertFalse($this->connection->
isEventEnabled(StatementExecutionStartEvent::
class));
$this->
assertFalse($this->connection->
isEventEnabled(StatementExecutionEndEvent::
class));
// Enable the statement execution start event and execute a query, start
// event captured but no end one.
$this->connection->
enableEvents([StatementExecutionStartEvent::
class]);
$this->connection->
query('SELECT * FROM {test}'
);
$this->
assertSame(1,
$subscriber->countStatementStarts
);
$this->
assertSame(0,
$subscriber->countStatementEnds
);
$this->
assertCount(1,
$subscriber->statementIdsInExecution
);
$this->
assertTrue($this->connection->
isEventEnabled(StatementExecutionStartEvent::
class));
$this->
assertFalse($this->connection->
isEventEnabled(StatementExecutionEndEvent::
class));
// Reset the statements in execution map to cleanup for following tests.
$subscriber->statementIdsInExecution =
[];
// Enable the statement execution end event and execute a query, both
// events captured.