A free open source IT asset/license management system
Fixed location unit test
snipe17bd6d71e785
diff --git a/database/factories/LocationFactory.php b/database/factories/LocationFactory.phpindex ef90f006a9..62afd25d03 100644--- a/database/factories/LocationFactory.php+++ b/database/factories/LocationFactory.php@@ -1,36 +1,12 @@<?php-/*-|---------------------------------------------------------------------------| Model Factories-|---------------------------------------------------------------------------|-| Here you may define all of your model factories. Model factories give-| you a convenient way to create models for testing and seeding your-| database. Just tell the factory how a default model should look.-|-*/-namespace Database\Factories;-use App\Models\AssetModel;-use App\Models\Category;-use App\Models\Company;-use App\Models\Location;-use App\Models\Manufacturer;-use App\Models\Statuslabel;-use App\Models\Supplier;use Illuminate\Database\Eloquent\Factories\Factory;+use Illuminate\Support\Str;class LocationFactory extends Factory{- /**- * The name of the factory's corresponding model.- *- * @var string- */- protected $model = \App\Models\Location::class;-/*** Define the model's default state.*@@ -39,15 +15,17 @@ class LocationFactory extends Factorypublic function definition(){return [- 'name' => $this->faker->city,- 'address' => $this->faker->streetAddress,- 'address2' => $this->faker->secondaryAddress,- 'city' => $this->faker->city,- 'state' => $this->faker->stateAbbr,- 'country' => $this->faker->countryCode,- 'currency' => $this->faker->currencyCode,- 'zip' => $this->faker->postcode,+ 'name' => $this->faker->city(),+ 'address' => $this->faker->streetAddress(),+ 'address2' => $this->faker->secondaryAddress(),+ 'city' => $this->faker->city(),+ 'state' => $this->faker->stateAbbr(),+ 'country' => $this->faker->countryCode(),+ 'currency' => $this->faker->currencyCode(),+ 'zip' => $this->faker->postcode(),'image' => rand(1, 9).'.jpg',+];}+}diff --git a/tests/TestCase.php b/tests/TestCase.phpindex e849640102..2932d4a69d 100644--- a/tests/TestCase.php+++ b/tests/TestCase.php@@ -1,40 +1,10 @@<?php+namespace Tests;-use PHPUnit\Framework\TestCase;+use Illuminate\Foundation\Testing\TestCase as BaseTestCase;-class TestCase extends TestCase+abstract class TestCase extends BaseTestCase{- /**- * The base URL to use while testing the application.- *- * @var string- */- protected $baseUrl = 'http://localhost:8000';-- /**- * Creates the application.- *- * @return \Illuminate\Foundation\Application- */- public function createApplication()- {- $app = require __DIR__.'/../bootstrap/app.php';- $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();- return $app;- }--- public function setUp() : void- {- parent::setUp();- \Artisan::call('migrate:fresh');- $this->seed();- }-- public function tearDown() : void- {- //Artisan::call('migrate:reset');- parent::tearDown();- }-}\ No newline at end of file+ use CreatesApplication;+}diff --git a/tests/unit/BaseTest.php b/tests/unit/BaseTest.phpindex 9ad3fb213f..c30ef4b910 100644--- a/tests/unit/BaseTest.php+++ b/tests/unit/BaseTest.php@@ -5,7 +5,7 @@ use App\Models\User;use Illuminate\Foundation\Testing\DatabaseMigrations;use Illuminate\Foundation\Testing\DatabaseTransactions;use Illuminate\Foundation\Testing\WithoutMiddleware;-use PHPUnit\Framework\TestCase;+use Tests\TestCase;class BaseTest extends TestCase{diff --git a/tests/unit/LocationTest.php b/tests/unit/LocationTest.phpindex d4739e1a31..30cc8f98fc 100644--- a/tests/unit/LocationTest.php+++ b/tests/unit/LocationTest.php@@ -2,10 +2,9 @@namespace Tests\Unit;use App\Models\Location;-use Illuminate\Foundation\Testing\DatabaseMigrations;-use Illuminate\Foundation\Testing\DatabaseTransactions;-use Illuminate\Foundation\Testing\WithoutMiddleware;use Tests\Unit\BaseTest;+use Illuminate\Database\Eloquent\Factories\Factory;+use Tests\TestCase;class LocationTest extends BaseTest{@@ -36,6 +35,6 @@ class LocationTest extends BaseTest]);$this->assertFalse($a->isValid());- $this->assertStringContainsString('The parent id and id must be different', $a->getErrors());+ $this->assertStringContainsString(trans('validation.non_circular', ['attribute' => 'parent id']), $a->getErrors());}}