mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Introduce trait to conditionally interact with settings
This commit is contained in:
parent
cd0796ddda
commit
7c95e45178
|
@ -6,10 +6,13 @@ use App\Models\Asset;
|
|||
use App\Models\User;
|
||||
use Illuminate\Testing\Fluent\AssertableJson;
|
||||
use Laravel\Passport\Passport;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetIndexTest extends TestCase
|
||||
{
|
||||
use InteractsWithSettings;
|
||||
|
||||
public function testAssetIndexReturnsExpectedAssets()
|
||||
{
|
||||
Asset::factory()->count(3)->create();
|
||||
|
|
|
@ -6,10 +6,13 @@ use App\Models\Company;
|
|||
use App\Models\User;
|
||||
use Illuminate\Testing\Fluent\AssertableJson;
|
||||
use Laravel\Passport\Passport;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UsersForSelectListTest extends TestCase
|
||||
{
|
||||
use InteractsWithSettings;
|
||||
|
||||
public function testUsersAreReturned()
|
||||
{
|
||||
$users = User::factory()->superuser()->count(3)->create();
|
||||
|
|
8
tests/Support/InteractsWithSettings.php
Normal file
8
tests/Support/InteractsWithSettings.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
trait InteractsWithSettings
|
||||
{
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ namespace Tests;
|
|||
use App\Http\Middleware\SecurityHeaders;
|
||||
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Tests\Support\InteractsWithSettings;
|
||||
use Tests\Support\Settings;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
|
@ -24,6 +25,8 @@ abstract class TestCase extends BaseTestCase
|
|||
|
||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||
|
||||
$this->settings = Settings::initialize();
|
||||
if (in_array(InteractsWithSettings::class, class_uses_recursive($this))) {
|
||||
$this->settings = Settings::initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue