forked from bilfeldt/laravel-route-statistics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCase.php
51 lines (43 loc) · 1.42 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Bilfeldt\LaravelRouteStatistics\Tests;
use Bilfeldt\LaravelRouteStatistics\LaravelRouteStatisticsServiceProvider;
use Bilfeldt\RequestLogger\RequestLoggerServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
class TestCase extends Orchestra
{
public function setUp(): void
{
parent::setUp();
Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Bilfeldt\\LaravelRouteStatistics\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
}
protected function getPackageProviders($app)
{
return [
RequestLoggerServiceProvider::class,
LaravelRouteStatisticsServiceProvider::class,
];
}
public function getEnvironmentSetUp($app)
{
$app['config']->set('database.default', 'sqlite');
$app['config']->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
$this->runMigrations([
'create_route_statistics_table',
'add_parameters_to_route_statistics_table',
]);
}
private function runMigrations(array $fileNames): void
{
foreach ($fileNames as $fileName) {
$class = require __DIR__.'/../database/migrations/'.$fileName.'.php.stub';
$class->up();
}
}
}