Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Oct 14, 2024
1 parent 210c5d0 commit 3e4deb2
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

namespace Dystcz\LunarApiProductViews\Tests;

use Dystcz\LunarApiProductViews\Tests\Stubs\Users\User;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\Config;
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables;
use Illuminate\Support\Facades\Redis;
use LaravelJsonApi\Testing\MakesJsonApiRequests;
use LaravelJsonApi\Testing\TestExceptionHandler;
use Lunar\Database\Factories\LanguageFactory;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as Orchestra;

abstract class TestCase extends Orchestra
{
use MakesJsonApiRequests;
use WithWorkbench;

protected function setUp(): void
{
Expand All @@ -25,8 +27,6 @@ protected function setUp(): void
'name' => 'English',
]);

Config::set('auth.providers.users.model', User::class);

activity()->disableLogging();
}

Expand Down Expand Up @@ -55,10 +55,6 @@ protected function getPackageProviders($app): array
\LaravelJsonApi\Laravel\ServiceProvider::class,
\LaravelJsonApi\Spec\ServiceProvider::class,

// Lunar Api
\Dystcz\LunarApi\LunarApiServiceProvider::class,
\Dystcz\LunarApi\JsonApiServiceProvider::class,

// Lunar core
\Lunar\LunarServiceProvider::class,
\Spatie\MediaLibrary\MediaLibraryServiceProvider::class,
Expand All @@ -67,6 +63,17 @@ protected function getPackageProviders($app): array
\Kalnoy\Nestedset\NestedSetServiceProvider::class,
\Spatie\LaravelBlink\BlinkServiceProvider::class,

// Livewire
\Livewire\LivewireServiceProvider::class,

// Lunar Api
\Dystcz\LunarApi\LunarApiServiceProvider::class,
\Dystcz\LunarApi\JsonApiServiceProvider::class,

// Hashids
\Vinkla\Hashids\HashidsServiceProvider::class,
\Dystcz\LunarApi\LunarApiHashidsServiceProvider::class,

// Lunar API product views
\Dystcz\LunarApiProductViews\LunarApiProductViewsServiceProvider::class,
];
Expand All @@ -75,17 +82,37 @@ protected function getPackageProviders($app): array
/**
* @param Application $app
*/
public function getEnvironmentSetUp($app): void
protected function defineEnvironment($app): void
{
Config::set('database.default', 'sqlite');

Config::set('database.migrations', 'migrations');
$app->useEnvironmentPath(__DIR__.'/..');
$app->bootstrapWith([LoadEnvironmentVariables::class]);

tap($app['config'], function (Repository $config) {
/**
* App configuration.
*/
$config->set('auth.providers.users', [
'driver' => 'eloquent',
'model' => \Dystcz\LunarApiProductViews\Tests\Stubs\Users\User::class,
]);

$config->set('database.default', 'sqlite');
$config->set('database.migrations', 'migrations');
$config->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
});
}

Config::set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
/**
* Define database migrations.
*/
protected function defineDatabaseMigrations(): void
{
$this->loadLaravelMigrations();
// $this->loadMigrationsFrom(workbench_path('database/migrations'));
}

protected function resolveApplicationExceptionHandler($app): void
Expand All @@ -95,12 +122,4 @@ protected function resolveApplicationExceptionHandler($app): void
TestExceptionHandler::class
);
}

/**
* Define database migrations.
*/
protected function defineDatabaseMigrations(): void
{
$this->loadLaravelMigrations();
}
}

0 comments on commit 3e4deb2

Please sign in to comment.