mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-27 06:29:47 -08:00
Merge pull request #12954 from marcusmoore/fixes/test-suite-fixes
Clear the settings cache on app destruction
This commit is contained in:
commit
63af17da74
|
@ -2,12 +2,16 @@
|
||||||
|
|
||||||
namespace Tests\Support;
|
namespace Tests\Support;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
|
|
||||||
trait InteractsWithSettings
|
trait InteractsWithSettings
|
||||||
{
|
{
|
||||||
protected Settings $settings;
|
protected Settings $settings;
|
||||||
|
|
||||||
public function setUpSettings()
|
public function initializeSettings()
|
||||||
{
|
{
|
||||||
$this->settings = Settings::initialize();
|
$this->settings = Settings::initialize();
|
||||||
|
|
||||||
|
$this->beforeApplicationDestroyed(fn() => Setting::$_cache = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ abstract class TestCase extends BaseTestCase
|
||||||
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
$this->withoutMiddleware($this->globallyDisabledMiddleware);
|
||||||
|
|
||||||
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
|
if (collect(class_uses_recursive($this))->contains(InteractsWithSettings::class)) {
|
||||||
$this->setUpSettings();
|
$this->initializeSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,13 @@ namespace Tests\Unit;
|
||||||
|
|
||||||
use App\Models\AssetMaintenance;
|
use App\Models\AssetMaintenance;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AssetMaintenanceTest extends TestCase
|
class AssetMaintenanceTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testZerosOutWarrantyIfBlank()
|
public function testZerosOutWarrantyIfBlank()
|
||||||
{
|
{
|
||||||
$c = new AssetMaintenance;
|
$c = new AssetMaintenance;
|
||||||
|
|
|
@ -4,10 +4,13 @@ namespace Tests\Unit;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AssetModelTest extends TestCase
|
class AssetModelTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testAnAssetModelZerosOutBlankEols()
|
public function testAnAssetModelZerosOutBlankEols()
|
||||||
{
|
{
|
||||||
$am = new AssetModel;
|
$am = new AssetModel;
|
||||||
|
|
|
@ -5,10 +5,13 @@ use App\Models\Asset;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class AssetTest extends TestCase
|
class AssetTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
// public function testAutoIncrementMixed()
|
// public function testAutoIncrementMixed()
|
||||||
// {
|
// {
|
||||||
// $expected = '123411';
|
// $expected = '123411';
|
||||||
|
|
|
@ -4,10 +4,13 @@ namespace Tests\Unit;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class CategoryTest extends TestCase
|
class CategoryTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testFailsEmptyValidation()
|
public function testFailsEmptyValidation()
|
||||||
{
|
{
|
||||||
// An Asset requires a name, a qty, and a category_id.
|
// An Asset requires a name, a qty, and a category_id.
|
||||||
|
|
|
@ -5,10 +5,13 @@ use App\Models\Category;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Component;
|
use App\Models\Component;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ComponentTest extends TestCase
|
class ComponentTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testAComponentBelongsToACompany()
|
public function testAComponentBelongsToACompany()
|
||||||
{
|
{
|
||||||
$component = Component::factory()
|
$component = Component::factory()
|
||||||
|
|
|
@ -5,10 +5,13 @@ use App\Models\Depreciation;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use App\Models\License;
|
use App\Models\License;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class DepreciationTest extends TestCase
|
class DepreciationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testADepreciationHasModels()
|
public function testADepreciationHasModels()
|
||||||
{
|
{
|
||||||
$depreciation = Depreciation::factory()->create();
|
$depreciation = Depreciation::factory()->create();
|
||||||
|
|
|
@ -8,10 +8,13 @@ use App\Models\Category;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Notifications\CheckoutAssetNotification;
|
use App\Notifications\CheckoutAssetNotification;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class NotificationTest extends TestCase
|
class NotificationTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
||||||
{
|
{
|
||||||
$admin = User::factory()->superuser()->create();
|
$admin = User::factory()->superuser()->create();
|
||||||
|
|
|
@ -2,10 +2,13 @@
|
||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use App\Models\SnipeModel;
|
use App\Models\SnipeModel;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class SnipeModelTest extends TestCase
|
class SnipeModelTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
public function testSetsPurchaseDatesAppropriately()
|
public function testSetsPurchaseDatesAppropriately()
|
||||||
{
|
{
|
||||||
$c = new SnipeModel;
|
$c = new SnipeModel;
|
||||||
|
|
Loading…
Reference in a new issue