@@ -95,7 +95,7 @@ public function test_connection_exception(): void
9595 ]);
9696 }
9797
98- public function test_statement_execution (): void
98+ public function test_connection_execute_statement (): void
9999 {
100100 $ connection = self ::createConnection ();
101101 $ statement = self ::fillDB ();
@@ -202,4 +202,39 @@ public function test_transaction(): void
202202 $ sth = $ connection ->prepare ('SELECT * FROM `technology` ' );
203203 $ this ->assertSame (2 , count ($ sth ->executeQuery ()->fetchAllAssociative ()));
204204 }
205+
206+ public function test_statement_execute (): void
207+ {
208+ $ connection = self ::createConnection ();
209+ $ statement = self ::fillDB ();
210+ $ connection ->executeStatement ($ statement );
211+ $ stmt = $ connection ->prepare ('SELECT * FROM `technology` ' );
212+ $ this ->storage ->exchangeArray ([]);
213+ $ stmt ->executeQuery ();
214+ $ this ->assertCount (1 , $ this ->storage );
215+ $ span = $ this ->storage ->offsetGet (0 );
216+ $ this ->assertSame ('Doctrine::execute ' , $ span ->getName ());
217+ $ this ->assertSame ('execute ' , $ span ->getAttributes ()->get (TraceAttributes::DB_OPERATION_NAME ));
218+ }
219+
220+ public function test_statement_execute_error (): void
221+ {
222+ $ connection = self ::createConnection ();
223+ $ statement = self ::fillDB ();
224+ $ connection ->executeStatement ($ statement );
225+ $ stmt = $ connection ->prepare ('insert into technology(name, date) values (?, ?); ' );
226+ $ this ->storage ->exchangeArray ([]);
227+ $ e = null ;
228+
229+ try {
230+ $ stmt ->executeQuery ();
231+ } catch (\Throwable $ e ) {
232+ // do nothing
233+ }
234+ $ this ->assertNotNull ($ e );
235+ $ this ->assertCount (1 , $ this ->storage );
236+ $ span = $ this ->storage ->offsetGet (0 );
237+ $ this ->assertSame ('Error ' , $ span ->getStatus ()->getCode ());
238+ $ this ->assertStringContainsString ('Unable to execute ' , $ span ->getStatus ()->getDescription ());
239+ }
205240}
0 commit comments