Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static function register(): void

Context::storage()->attach($span->storeInContext($parent));
},
post: static function (\Doctrine\DBAL\Driver\Statement $statement, array $params, ResultInterface $result, ?Throwable $exception) {
post: static function (\Doctrine\DBAL\Driver\Statement $statement, array $params, ?ResultInterface $result, ?Throwable $exception) {
self::end($exception);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function test_connection_exception(): void
]);
}

public function test_statement_execution(): void
public function test_connection_execute_statement(): void
{
$connection = self::createConnection();
$statement = self::fillDB();
Expand Down Expand Up @@ -202,4 +202,39 @@ public function test_transaction(): void
$sth = $connection->prepare('SELECT * FROM `technology`');
$this->assertSame(2, count($sth->executeQuery()->fetchAllAssociative()));
}

public function test_statement_execute(): void
{
$connection = self::createConnection();
$statement = self::fillDB();
$connection->executeStatement($statement);
$stmt = $connection->prepare('SELECT * FROM `technology`');
$this->storage->exchangeArray([]);
$stmt->executeQuery();
$this->assertCount(1, $this->storage);
$span = $this->storage->offsetGet(0);
$this->assertSame('Doctrine::execute', $span->getName());
$this->assertSame('execute', $span->getAttributes()->get(TraceAttributes::DB_OPERATION_NAME));
}

public function test_statement_execute_error(): void
{
$connection = self::createConnection();
$statement = self::fillDB();
$connection->executeStatement($statement);
$stmt = $connection->prepare('insert into technology(name, date) values (?, ?);');
$this->storage->exchangeArray([]);
$e = null;

try {
$stmt->executeQuery();
} catch (\Throwable $e) {
// do nothing
}
$this->assertNotNull($e);
$this->assertCount(1, $this->storage);
$span = $this->storage->offsetGet(0);
$this->assertSame('Error', $span->getStatus()->getCode());
$this->assertStringContainsString('Unable to execute', $span->getStatus()->getDescription());
}
}
Loading