-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTestCase.php
57 lines (45 loc) · 1.67 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
52
53
54
55
56
57
<?php
namespace Coderflex\LaravelCsv\Tests;
use Coderflex\LaravelCsv\Http\Livewire\CsvImporter;
use Coderflex\LaravelCsv\Http\Livewire\HandleImports;
use Coderflex\LaravelCsv\LaravelCsvServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Livewire\Livewire;
use Livewire\LivewireServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;
class TestCase extends Orchestra
{
protected function setUp(): void
{
parent::setUp();
config()->set('app.key', '6rE9Nz59bGRbeMATftriyQjrpF7DcOQm');
Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Coderflex\\LaravelCsv\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
$this->registerLivewireComponents();
}
protected function getPackageProviders($app)
{
return [
LivewireServiceProvider::class,
LaravelCsvServiceProvider::class,
];
}
public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');
$migrations = [
include __DIR__.'/../database/migrations/create_csv_imports_table.php.stub',
include __DIR__.'/Database/Migrations/create_customers_table.php',
include __DIR__.'/Database/Migrations/create_users_table.php',
include __DIR__.'/Database/Migrations/create_job_batches_table.php',
];
collect($migrations)->each(fn ($path) => $path->up());
}
private function registerLivewireComponents(): self
{
Livewire::component('csv-importer', CsvImporter::class);
Livewire::component('handle-imports', HandleImports::class);
return $this;
}
}