Small fixes

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2021-12-01 23:33:20 -08:00
parent ad6d70b86f
commit ed2797afdd
4 changed files with 8 additions and 25 deletions

View file

@ -2,20 +2,11 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\Company;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
use \Auth;
class UserFactory extends Factory 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. * Define the model's default state.
* *
@ -23,7 +14,6 @@ class UserFactory extends Factory
*/ */
public function definition() public function definition()
{ {
$password = Hash::make('password');
return [ return [
'activated' => 1, 'activated' => 1,
'address' => $this->faker->address, 'address' => $this->faker->address,
@ -39,7 +29,7 @@ class UserFactory extends Factory
'locale' => $this->faker->locale, 'locale' => $this->faker->locale,
'location_id' => rand(1, 5), 'location_id' => rand(1, 5),
'notes' => 'Created by DB seeder', 'notes' => 'Created by DB seeder',
'password' => $password, 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'permissions' => '{"user":"0"}', 'permissions' => '{"user":"0"}',
'phone' => $this->faker->phoneNumber, 'phone' => $this->faker->phoneNumber,
'state' => $this->faker->stateAbbr, 'state' => $this->faker->stateAbbr,
@ -47,7 +37,7 @@ class UserFactory extends Factory
'zip' => $this->faker->postcode, 'zip' => $this->faker->postcode,
]; ];
} }
public function firstAdmin() public function firstAdmin()
{ {
return $this->state(function () { return $this->state(function () {
@ -408,4 +398,5 @@ class UserFactory extends Factory
]; ];
}); });
} }
} }

View file

@ -6,6 +6,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\TestCase; use Tests\TestCase;
use Auth;
class BaseTest extends TestCase class BaseTest extends TestCase
{ {
@ -25,13 +26,12 @@ class BaseTest extends TestCase
]); ]);
} }
Auth::login($user); Auth::login($user);
return $user; return $user;
} }
protected function createValidAssetModel($state = 'mbp-13-model', $overrides = []) 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(), 'category_id' => $this->createValidCategory(),
'manufacturer_id' => $this->createValidManufacturer(), 'manufacturer_id' => $this->createValidManufacturer(),
'depreciation_id' => $this->createValidDepreciation(), 'depreciation_id' => $this->createValidDepreciation(),

View file

@ -3,8 +3,7 @@ namespace Tests\Unit;
use App\Models\Location; use App\Models\Location;
use Tests\Unit\BaseTest; use Tests\Unit\BaseTest;
use Illuminate\Database\Eloquent\Factories\Factory;
use Tests\TestCase;
class LocationTest extends BaseTest class LocationTest extends BaseTest
{ {

View file

@ -1,18 +1,11 @@
<?php <?php
namespace Tests\Unit; namespace Tests\Unit;
use App\Exceptions\CheckoutNotAllowed;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Location;
use App\Models\User; use App\Models\User;
use App\Notifications\CheckoutAssetNotification; use App\Notifications\CheckoutAssetNotification;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Tests\Unit\BaseTest; use Tests\Unit\BaseTest;
use Auth;
class NotificationTest extends BaseTest class NotificationTest extends BaseTest
{ {