Skip to content

Commit 6a917b8

Browse files
committed
create test boilerplate
1 parent a3fb3a4 commit 6a917b8

File tree

1 file changed

+41
-0
lines changed
  • src/Instrumentation/Laravel/tests/Integration/Database

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}

0 commit comments

Comments
 (0)