diff --git a/.travis.yml b/.travis.yml index ccb95d0fb3..83db93506e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,11 +21,11 @@ before_script: - chmod -R 777 storage - php artisan migrate --env=testing-ci --database=mysql --force - ./vendor/bin/codecept build - - php artisan key:generate --env=testing-ci - - php artisan db:seed --env=testing-ci --database=mysql --force + - php artisan --env=testing-ci key:generate + - php artisan --env=testing-ci db:seed --database=mysql --force - php artisan --env=testing-ci snipeit:create-admin --first_name=Alison --last_name=Foobar --email=me@example.com --username=snipe --password=password - php artisan --env=testing-ci snipeit:travisci-install - - php artisan passport:install + - php artisan --env=testing-ci passport:install - php artisan serve --env=testing-ci --port=8000 --host=localhost & - sleep 5 - pip install --user codecov diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 1c91b123b7..10afc78161 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -11,26 +11,28 @@ | */ +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; $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $faker) { return [ 'name' => $faker->catchPhrase, - 'model_id' => $faker->numberBetween(1, 5), - 'rtd_location_id' => $faker->numberBetween(1, 5), + 'model_id' => AssetModel::inRandomOrder()->first()->id, + 'rtd_location_id' => Location::inRandomOrder()->first()->id, 'serial' => $faker->uuid, - 'status_id' => 1, + 'status_id' => Statuslabel::inRandomOrder()->first()->id, 'user_id' => 1, 'asset_tag' => $faker->unixTime('now'), 'notes' => $faker->sentence, 'purchase_date' => $faker->dateTime(), 'purchase_cost' => $faker->randomFloat(2), 'order_number' => $faker->numberBetween(1000000, 50000000), - 'supplier_id' => $faker->numberBetween(1, 5), + 'supplier_id' => Supplier::inRandomOrder()->first()->id, 'company_id' => Company::inRandomOrder()->first()->id, 'requestable' => $faker->boolean() ]; @@ -40,8 +42,8 @@ $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $ $factory->defineAs(App\Models\AssetModel::class, 'assetmodel', function (Faker\Generator $faker) { return [ 'name' => $faker->catchPhrase, - 'manufacturer_id' => $faker->numberBetween(1, 10), - 'category_id' => $faker->numberBetween(1, 9), + 'manufacturer_id' => Manufacturer::inRandomOrder()->first()->id, + 'category_id' => Category::where('category_type', 'asset')->inRandomOrder()->first()->id, 'model_number' => $faker->numberBetween(1000000, 50000000), 'eol' => 1, 'notes' => $faker->paragraph(), @@ -88,7 +90,7 @@ $factory->defineAs(App\Models\Manufacturer::class, 'manufacturer', function (Fak $factory->defineAs(App\Models\Component::class, 'component', function (Faker\Generator $faker) { return [ 'name' => $faker->text(20), - 'category_id' => $faker->numberBetween(21, 25), + 'category_id' => Category::where('category_type', 'component')->inRandomOrder()->first()->id, 'location_id' => Location::inRandomOrder()->first()->id, 'serial' => $faker->uuid, 'qty' => $faker->numberBetween(3, 10), @@ -113,7 +115,7 @@ $factory->defineAs(App\Models\Accessory::class, 'accessory', function (Faker\Gen 'name' => $faker->text(20), 'category_id' => Category::where('category_type', 'accessory')->inRandomOrder()->first()->id, 'manufacturer_id' => Manufacturer::inRandomOrder()->first()->id, - 'location_id' => $faker->numberBetween(1, 5), + 'location_id' => Location::inRandomOrder()->first()->id, 'order_number' => $faker->numberBetween(1000000, 50000000), 'purchase_date' => $faker->dateTime(), 'purchase_cost' => $faker->randomFloat(2), @@ -147,7 +149,7 @@ $factory->defineAs(App\Models\Consumable::class, 'consumable', function (Faker\G return [ 'name' => $faker->text(20), 'company_id' => Company::inRandomOrder()->first()->id, - 'category_id' => $faker->numberBetween(16, 20), + 'category_id' => Category::where('category_type', 'consumable')->inRandomOrder()->first()->id, 'model_number' => $faker->numberBetween(1000000, 50000000), 'item_no' => $faker->numberBetween(1000000, 50000000), 'order_number' => $faker->numberBetween(1000000, 50000000), diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index c0b628e80c..983b64e5b4 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -10,9 +10,7 @@ $factory->defineAs(App\Models\User::class, 'valid-user', function (Faker\Generat 'password' => $faker->password, 'permissions' => '{"user":"0"}', 'email' => $faker->safeEmail, - 'company_id' => function () { - return factory(App\Models\Company::class, 'company')->create()->id; - }, + 'company_id' => Company::inRandomOrder()->first()->id, 'locale' => $faker->locale, 'employee_num' => $faker->numberBetween(3500, 35050), 'jobtitle' => $faker->word, diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 6332a85999..bbbfbcb607 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -22,12 +22,14 @@ class DatabaseSeeder extends Seeder $this->call(LocationSeeder::class); $this->call(SupplierSeeder::class); $this->call(AssetModelSeeder::class); + $this->call(DepreciationSeeder::class); + $this->call(StatuslabelSeeder::class); $this->call(AccessorySeeder::class); $this->call(AssetSeeder::class); $this->call(LicenseSeeder::class); $this->call(ComponentSeeder::class); $this->call(ConsumableSeeder::class); - $this->call(StatuslabelSeeder::class); + $this->call(LicenseSeeder::class); $this->call(ActionlogSeeder::class); $this->call(CustomFieldSeeder::class);