From ed2797afddef8f296f917f3055dcda585bdefd7a Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 1 Dec 2021 23:33:20 -0800 Subject: [PATCH] Small fixes Signed-off-by: snipe --- database/factories/UserFactory.php | 17 ++++------------- tests/unit/BaseTest.php | 4 ++-- tests/unit/LocationTest.php | 3 +-- tests/unit/NotificationTest.php | 9 +-------- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 6905dcf30e..6dd98b5b7d 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -2,20 +2,11 @@ namespace Database\Factories; -use App\Models\Company; use Illuminate\Database\Eloquent\Factories\Factory; - - +use \Auth; class UserFactory extends Factory { - /** - * The name of the factory's corresponding model. - * - * @var string - */ - protected $model = \App\Models\User::class; - /** * Define the model's default state. * @@ -23,7 +14,6 @@ class UserFactory extends Factory */ public function definition() { - $password = Hash::make('password'); return [ 'activated' => 1, 'address' => $this->faker->address, @@ -39,7 +29,7 @@ class UserFactory extends Factory 'locale' => $this->faker->locale, 'location_id' => rand(1, 5), 'notes' => 'Created by DB seeder', - 'password' => $password, + 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 'permissions' => '{"user":"0"}', 'phone' => $this->faker->phoneNumber, 'state' => $this->faker->stateAbbr, @@ -47,7 +37,7 @@ class UserFactory extends Factory 'zip' => $this->faker->postcode, ]; } - + public function firstAdmin() { return $this->state(function () { @@ -408,4 +398,5 @@ class UserFactory extends Factory ]; }); } + } diff --git a/tests/unit/BaseTest.php b/tests/unit/BaseTest.php index c30ef4b910..516f985e2e 100644 --- a/tests/unit/BaseTest.php +++ b/tests/unit/BaseTest.php @@ -6,6 +6,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\WithoutMiddleware; use Tests\TestCase; +use Auth; class BaseTest extends TestCase { @@ -25,13 +26,12 @@ class BaseTest extends TestCase ]); } Auth::login($user); - return $user; } protected function createValidAssetModel($state = 'mbp-13-model', $overrides = []) { - return \App\Models\AssetModel::factory()->state()->create(array_merge([ + return \App\Models\AssetModel::factory()->state($state)->create(array_merge([ 'category_id' => $this->createValidCategory(), 'manufacturer_id' => $this->createValidManufacturer(), 'depreciation_id' => $this->createValidDepreciation(), diff --git a/tests/unit/LocationTest.php b/tests/unit/LocationTest.php index 30cc8f98fc..eda9c6a896 100644 --- a/tests/unit/LocationTest.php +++ b/tests/unit/LocationTest.php @@ -3,8 +3,7 @@ namespace Tests\Unit; use App\Models\Location; use Tests\Unit\BaseTest; -use Illuminate\Database\Eloquent\Factories\Factory; -use Tests\TestCase; + class LocationTest extends BaseTest { diff --git a/tests/unit/NotificationTest.php b/tests/unit/NotificationTest.php index 0fd2810e1d..83296196c8 100644 --- a/tests/unit/NotificationTest.php +++ b/tests/unit/NotificationTest.php @@ -1,18 +1,11 @@