File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
src/Instrumentation/Laravel/tests/Integration/Database Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace OpenTelemetry \Tests \Contrib \Instrumentation \Laravel ;
4+
5+ use OpenTelemetry \Tests \Contrib \Instrumentation \Laravel \Integration \TestCase ;
6+ use Illuminate \Support \Facades \DB ;
7+
8+ /**
9+ * Integration test for Eloquent\Model hooks
10+ */
11+ class ModelTest extends TestCase
12+ {
13+ protected function getEnvironmentSetUp ($ app ): void
14+ {
15+ // Setup default database to use sqlite :memory:
16+ $ app ['config ' ]->set ('database.default ' , 'testbench ' );
17+ $ app ['config ' ]->set ('database.connections.testbench ' , [
18+ 'driver ' => 'sqlite ' ,
19+ 'database ' => ':memory: ' ,
20+ 'prefix ' => '' ,
21+ ]);
22+ }
23+
24+ public function setUp (): void
25+ {
26+ // Setup database table for fixture model
27+ DB ::statement ('CREATE TABLE IF NOT EXISTS test_models(
28+ id BIGINTEGER,
29+ name VARCHAR(255),
30+ created_at DATETIME,
31+ updated_at DATETIME
32+ )
33+ ' );
34+ }
35+
36+ public function tearDown (): void
37+ {
38+ // Reset table
39+ DB ::statement ('DROP IF EXISTS test_models ' );
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments