mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
[WIP] Improvements to unit tests. (#3574)
* Improvemenets to unit tests. * Break up modelfactory into multiple files, populate many states. * Begin testing validation at the unit test level, test relationships. * Add tests for Asset::availableForCheckout. * Model factories now generate all needed relationships on demand, which allows us to unit test with a empty database. * To faciliate the empty database, we move to using sqlite in memory as the unit testing database. * Fix bug with logs of checkouts to non users. * Fix location finding for assets. Also Fix location show page to show users associated with location. Still need some work to show assets. * More test and generator improvements * More unit test fixes. PermissionsTest is borked still. * More Updates * Rewrite permissionstest. Check that we have access on the model level rather than via web requests. Also test delete permissions. * Fix seeders. * Make the default asset model factory generate assets that are rtd for testing. * Save progress. * Rebase tests, fix department unit test, update database for functional tests. * Update functional and api tests to use new modelfactory signatures.
This commit is contained in:
parent
966a736602
commit
5d4920c741
|
@ -1,7 +1,8 @@
|
|||
APP_ENV=local
|
||||
APP_ENV=testing
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://snipe-it.localapp
|
||||
DB_CONNECTION=mysql
|
||||
DB_CONNECTION=sqlite_testing
|
||||
DB_DEFAULT=sqlite_testing
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeittests
|
||||
DB_USERNAME=snipeit
|
||||
|
|
|
@ -50,7 +50,11 @@ class UsersController extends Controller
|
|||
}
|
||||
|
||||
if ($request->has('company_id')) {
|
||||
$users = $users->where('company_id','=',$request->input('company_id'));
|
||||
$users = $users->where('company_id', '=', $request->input('company_id'));
|
||||
}
|
||||
|
||||
if ($request->has('location_id')) {
|
||||
$users = $users->where('location_id', '=', $request->input('location_id'));
|
||||
}
|
||||
|
||||
if ($request->has('department_id')) {
|
||||
|
|
|
@ -139,6 +139,7 @@ class Asset extends Depreciable
|
|||
* @param null $name
|
||||
* @return bool
|
||||
*/
|
||||
//FIXME: The admin parameter is never used. Can probably be removed.
|
||||
public function checkOut($target, $admin, $checkout_at = null, $expected_checkin = null, $note = null, $name = null)
|
||||
{
|
||||
if (!$target) {
|
||||
|
@ -163,7 +164,7 @@ class Asset extends Depreciable
|
|||
}
|
||||
|
||||
if ($this->save()) {
|
||||
$log = $this->logCheckout($note);
|
||||
$this->logCheckout($note, $target);
|
||||
// if ((($this->requireAcceptance()=='1') || ($this->getEula())) && ($user->email!='')) {
|
||||
// $this->checkOutNotifyMail($log->id, $user, $checkout_at, $expected_checkin, $note);
|
||||
// }
|
||||
|
@ -272,15 +273,13 @@ class Asset extends Depreciable
|
|||
**/
|
||||
public function assetLoc()
|
||||
{
|
||||
if ($this->assignedTo) {
|
||||
return $this->assignedTo->userloc();
|
||||
}
|
||||
|
||||
if (!empty($this->assignedType())) {
|
||||
if ($this->assignedType() == self::ASSET) {
|
||||
return $this->assignedTo->assetloc(); // Recurse until we have a final location
|
||||
} elseif ($this->assignedType() == self::LOCATION) {
|
||||
return $this->assignedTo();
|
||||
} elseif ($this->assignedType() == self::USER) {
|
||||
return $this->assignedTo->userLoc();
|
||||
}
|
||||
}
|
||||
return $this->defaultLoc();
|
||||
|
|
|
@ -45,12 +45,17 @@ trait Loggable
|
|||
$log->user_id = Auth::user()->id;
|
||||
|
||||
// @FIXME This needs to be generalized with new asset checkout.
|
||||
if (!is_null($this->asset_id) || isset($target)) {
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $this->asset_id;
|
||||
} elseif (!is_null($this->assigned_to)) {
|
||||
$log->target_type = User::class;
|
||||
$log->target_id = $this->assigned_to;
|
||||
if(isset($target)) {
|
||||
$log->target_type = get_class($target);
|
||||
$log->target_id = $target->id;
|
||||
} else {
|
||||
if (!is_null($this->asset_id)) {
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $this->asset_id;
|
||||
} elseif (!is_null($this->assigned_to)) {
|
||||
$log->target_type = User::class;
|
||||
$log->target_id = $this->assigned_to;
|
||||
}
|
||||
}
|
||||
|
||||
$item = call_user_func(array($log->target_type, 'find'), $log->target_id);
|
||||
|
|
|
@ -54,7 +54,7 @@ return [
|
|||
|
||||
'sqlite_testing' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => database_path('testing.sqlite'),
|
||||
'database' => ':memory:',
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
|
|
111
database/factories/ActionLogFactory.php
Normal file
111
database/factories/ActionLogFactory.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Actionlog;
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'asset-upload', function ($faker) {
|
||||
$asset = factory(App\Models\Asset::class)->create();
|
||||
return [
|
||||
'item_type' => get_class($asset),
|
||||
'item_id' => $asset->id,
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'filename' => $faker->word,
|
||||
'action_type' => 'uploaded'
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
// $item = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => factory(App\Models\Asset::class)->create(['company_id' => $company->id])->id,
|
||||
'item_type' => App\Models\Asset::class,
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\Asset::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\License::class)->create(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\Accessory::class)->create(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\Consumable::class)->create(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
|
||||
$company = factory(App\Models\Company::class)->create();
|
||||
$user = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$target = factory(App\Models\User::class)->create(['company_id' => $company->id]);
|
||||
$item = factory(App\Models\Component::class)->create(['company_id' => $company->id]);
|
||||
|
||||
return [
|
||||
'user_id' => $user->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $item->id,
|
||||
'item_type' => get_class($item),
|
||||
'target_id' => $target->id,
|
||||
'target_type' => get_class($target),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
106
database/factories/AssetFactory.php
Normal file
106
database/factories/AssetFactory.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Asset;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to modelling assets.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(Asset::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'model_id' => function () {
|
||||
return factory(App\Models\AssetModel::class)->create()->id;
|
||||
},
|
||||
'rtd_location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'serial' => $faker->uuid,
|
||||
'status_id' => function () {
|
||||
return factory(App\Models\Statuslabel::class)->states('rtd')->create()->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'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' => function () {
|
||||
return factory(App\Models\Supplier::class)->create()->id;
|
||||
},
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'requestable' => $faker->boolean()
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'deleted', function ($faker) {
|
||||
return [
|
||||
'deleted_at' => $faker->dateTime(),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-user', function ($faker) {
|
||||
return [
|
||||
'assigned_to' => factory(App\Models\User::class)->create()->id,
|
||||
'assigned_type' => App\Models\User::class,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-location', function ($faker) {
|
||||
return [
|
||||
'assigned_to' => factory(App\Models\Location::class)->create()->id,
|
||||
'assigned_type' => App\Models\Location::class,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Asset::class, 'assigned-to-asset', function ($faker) {
|
||||
return [
|
||||
'assigned_to' => factory(App\Models\Asset::class)->create()->id,
|
||||
'assigned_type' => App\Models\Asset::class,
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->define(App\Models\AssetModel::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->states('asset-category')->create()->id;
|
||||
},
|
||||
'model_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'eol' => 1,
|
||||
'notes' => $faker->paragraph(),
|
||||
'requestable' => $faker->boolean(),
|
||||
'depreciation_id' => function () {
|
||||
return factory(App\Models\Depreciation::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\AssetMaintenance::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'asset_id' => function () {
|
||||
return factory(App\Models\Asset::class)->create()->id;
|
||||
},
|
||||
'supplier_id' => function () {
|
||||
return factory(App\Models\Supplier::class)->create()->id;
|
||||
},
|
||||
'asset_maintenance_type' => $faker->randomElement(['maintenance', 'repair', 'upgrade']),
|
||||
'title' => $faker->sentence,
|
||||
'start_date' => $faker->date(),
|
||||
'is_warranty' => $faker->boolean(),
|
||||
'notes' => $faker->paragraph(),
|
||||
];
|
||||
});
|
46
database/factories/CategoryFactory.php
Normal file
46
database/factories/CategoryFactory.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Category Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Factories related exclusively to creating categories and the various states..
|
||||
|
|
||||
*/
|
||||
|
||||
|
||||
$factory->define(App\Models\Category::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'category_type' => $faker->randomElement(['asset', 'accessory', 'component', 'consumable']),
|
||||
'eula_text' => $faker->paragraph(),
|
||||
'require_acceptance' => $faker->boolean(),
|
||||
'use_default_eula' => $faker->boolean(),
|
||||
'checkin_email' => $faker->boolean()
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'asset-category', function ($faker) {
|
||||
return [
|
||||
'category_type' => 'asset',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'accessory-category', function ($faker) {
|
||||
return [
|
||||
'category_type' => 'accessory',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'component-category', function ($faker) {
|
||||
return [
|
||||
'category_type' => 'component',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(App\Models\Category::class, 'consumable-category', function ($faker) {
|
||||
return [
|
||||
'category_type' => 'consumable',
|
||||
];
|
||||
});
|
|
@ -19,39 +19,150 @@ use App\Models\Manufacturer;
|
|||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
|
||||
$factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Accessory::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'model_id' => AssetModel::inRandomOrder()->first()->id,
|
||||
'rtd_location_id' => Location::inRandomOrder()->first()->id,
|
||||
'serial' => $faker->uuid,
|
||||
'status_id' => Statuslabel::inRandomOrder()->first()->id,
|
||||
'user_id' => 1,
|
||||
'asset_tag' => $faker->unixTime('now'),
|
||||
'notes' => $faker->sentence,
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'name' => $faker->text(20),
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->states('accessory-category')->create()->id;
|
||||
},
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'supplier_id' => Supplier::inRandomOrder()->first()->id,
|
||||
'company_id' => Company::inRandomOrder()->first()->id,
|
||||
'requestable' => $faker->boolean()
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Company::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->company,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\AssetModel::class, 'assetmodel', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Component::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'serial' => $faker->uuid,
|
||||
'qty' => $faker->numberBetween(3, 10),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Consumable::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'category_id' => function () {
|
||||
return factory(App\Models\Category::class)->create()->id;
|
||||
},
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'manufacturer_id' => function () {
|
||||
return factory(App\Models\Manufacturer::class)->create()->id;
|
||||
},
|
||||
'user_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
'model_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'item_no' => $faker->numberBetween(1000000, 50000000),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\CustomField::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'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(),
|
||||
'requestable' => $faker->boolean(),
|
||||
'format' => 'IP',
|
||||
'element' => 'text',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Location::class, 'location', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Department::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'user_id' => '1',
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'manager_id' => function () {
|
||||
return factory(App\Models\User::class)->create()->id;
|
||||
},
|
||||
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Depreciation::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'months' => $faker->numberBetween(1, 10),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\License::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'serial' => $faker->uuid,
|
||||
'seats' => $faker->numberBetween(1, 10),
|
||||
'license_email' => $faker->safeEmail,
|
||||
'license_name' => $faker->name,
|
||||
'order_number' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_order' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'notes' => $faker->sentence,
|
||||
'supplier_id' => function () {
|
||||
return factory(App\Models\Supplier::class)->create()->id;
|
||||
},
|
||||
'company_id' =>function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\LicenseSeat::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'license_id' => function () {
|
||||
return factory(App\Models\License::class)->create()->id;
|
||||
},
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'notes' => $faker->sentence,
|
||||
'user_id' => '1',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(App\Models\Location::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'address' => $faker->streetAddress,
|
||||
|
@ -64,69 +175,13 @@ $factory->defineAs(App\Models\Location::class, 'location', function (Faker\Gener
|
|||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Category::class, 'category', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'category_type' => $faker->randomElement(['asset', 'accessory', 'component', 'consumable']),
|
||||
'eula_text' => $faker->paragraph(),
|
||||
'require_acceptance' => $faker->boolean(),
|
||||
'use_default_eula' => $faker->boolean(),
|
||||
'checkin_email' => $faker->boolean()
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Company::class, 'company', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Manufacturer::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->company,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Manufacturer::class, 'manufacturer', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->company,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Component::class, 'component', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'category_id' => Category::where('category_type', 'component')->inRandomOrder()->first()->id,
|
||||
'location_id' => Location::inRandomOrder()->first()->id,
|
||||
'serial' => $faker->uuid,
|
||||
'qty' => $faker->numberBetween(3, 10),
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
'company_id' => Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Depreciation::class, 'depreciation', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'months' => $faker->numberBetween(1, 10),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Accessory::class, 'accessory', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'company_id' => Company::inRandomOrder()->first()->id,
|
||||
'name' => $faker->text(20),
|
||||
'category_id' => Category::where('category_type', 'accessory')->inRandomOrder()->first()->id,
|
||||
'manufacturer_id' => Manufacturer::inRandomOrder()->first()->id,
|
||||
'location_id' => Location::inRandomOrder()->first()->id,
|
||||
'order_number' => $faker->numberBetween(1000000, 50000000),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
|
||||
});
|
||||
|
||||
|
||||
$factory->defineAs(App\Models\Supplier::class, 'supplier', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Supplier::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->company,
|
||||
'address' => $faker->streetAddress,
|
||||
|
@ -144,230 +199,16 @@ $factory->defineAs(App\Models\Supplier::class, 'supplier', function (Faker\Gener
|
|||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->defineAs(App\Models\Consumable::class, 'consumable', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\Setting::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->text(20),
|
||||
'company_id' => Company::inRandomOrder()->first()->id,
|
||||
'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),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'qty' => $faker->numberBetween(5, 10),
|
||||
'min_amt' => $faker->numberBetween($min = 1, $max = 2),
|
||||
];
|
||||
});
|
||||
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'rtd', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Ready to Deploy',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 1,
|
||||
'pending' => 0,
|
||||
'archived' => 0,
|
||||
'notes' => ''
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'pending', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Pending',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 1,
|
||||
'archived' => 0,
|
||||
'notes' => $faker->sentence
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'archived', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Archived',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 1,
|
||||
'notes' => 'These assets are permanently undeployable'
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'out_for_diagnostics', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Diagnostics',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 0,
|
||||
'notes' => ''
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'out_for_repair', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Repair',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 0,
|
||||
'notes' => ''
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'broken', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Broken - Not Fixable',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 1,
|
||||
'notes' => ''
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Statuslabel::class, 'lost', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Lost/Stolen',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 1,
|
||||
'notes' => '',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\License::class, 'license', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'serial' => $faker->uuid,
|
||||
'seats' => $faker->numberBetween(1, 10),
|
||||
'license_email' => $faker->safeEmail,
|
||||
'license_name' => $faker->name,
|
||||
'order_number' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_order' => $faker->numberBetween(1500, 13250),
|
||||
'purchase_date' => $faker->dateTime(),
|
||||
'purchase_cost' => $faker->randomFloat(2),
|
||||
'notes' => $faker->sentence,
|
||||
'supplier_id' => Supplier::inRandomOrder()->first()->id,
|
||||
'company_id' => Company::inRandomOrder()->first()->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\LicenseSeat::class, 'license-seat', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'license_id' => $faker->numberBetween(1, 10),
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'notes' => $faker->sentence,
|
||||
'user_id' => '1',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
|
||||
$company = Company::has('users')->has('assets')->inRandomOrder()->first();
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->assets()->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Asset',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
|
||||
$company = Company::has('users')->has('licenses')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->licenses()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->assets()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\Asset',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\License',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
|
||||
$company = Company::has('users')->has('accessories')->inRandomOrder()->first();
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->accessories()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Accessory',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
|
||||
$company = Company::has('users')->has('consumables')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->consumables()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Consumable',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
|
||||
$company = Company::has('users')->has('components')->inRandomOrder()->first();
|
||||
|
||||
return [
|
||||
'user_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'action_type' => 'checkout',
|
||||
'item_id' => $company->components()->whereNotNull('company_id')->inRandomOrder()->first()->id,
|
||||
'target_id' => $company->users()->inRandomOrder()->first()->id,
|
||||
'target_type' => 'App\\Models\\User',
|
||||
'created_at' => $faker->dateTime(),
|
||||
'item_type' => 'App\\Models\\Component',
|
||||
'note' => $faker->sentence,
|
||||
'company_id' => $company->id
|
||||
];
|
||||
});
|
||||
|
||||
$factory->defineAs(App\Models\CustomField::class, 'customfield-ip', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->catchPhrase,
|
||||
'format' => 'IP',
|
||||
'element' => 'text',
|
||||
'user_id' => 1,
|
||||
'per_page' => 20,
|
||||
'site_name' => $faker->sentence,
|
||||
'auto_increment_assets' => false,
|
||||
'alert_email' => $faker->safeEmail(),
|
||||
'alerts_enabled' => false,
|
||||
'brand' => 1,
|
||||
'default_currency' => $faker->currencyCode,
|
||||
'locale' => $faker->locale,
|
||||
];
|
||||
});
|
||||
|
|
60
database/factories/StatusLabelFactory.php
Normal file
60
database/factories/StatusLabelFactory.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Statuslabel;
|
||||
|
||||
$factory->define(Statuslabel::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'created_at' => $faker->dateTime(),
|
||||
'updated_at' => $faker->dateTime(),
|
||||
'user_id' => 1,
|
||||
'deleted_at' => null,
|
||||
'deployable' => 0,
|
||||
'pending' => 0,
|
||||
'archived' => 0,
|
||||
'notes' => ''
|
||||
];
|
||||
});
|
||||
$factory->state(Statuslabel::class, 'rtd', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'notes' => $faker->sentence,
|
||||
'deployable' => 1
|
||||
];
|
||||
});
|
||||
$factory->state(Statuslabel::class, 'pending', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'notes' => $faker->sentence,
|
||||
'pending' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'archived', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'notes' => 'These assets are permanently undeployable',
|
||||
'archived' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'out_for_diagnostics', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Diagnostics',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'out_for_repair', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Out for Repair',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'broken', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Broken - Not Fixable',
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Statuslabel::class, 'lost', function (Faker\Generator $faker) {
|
||||
return [
|
||||
'name' => 'Lost/Stolen',
|
||||
];
|
||||
});
|
|
@ -2,26 +2,31 @@
|
|||
|
||||
use App\Models\Company;
|
||||
|
||||
$factory->defineAs(App\Models\User::class, 'valid-user', function (Faker\Generator $faker) {
|
||||
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
|
||||
return [
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'username' => $faker->username,
|
||||
'password' => $faker->password,
|
||||
'permissions' => '{"user":"0"}',
|
||||
'email' => $faker->safeEmail,
|
||||
'company_id' => Company::inRandomOrder()->first()->id,
|
||||
'locale' => $faker->locale,
|
||||
'employee_num' => $faker->numberBetween(3500, 35050),
|
||||
'jobtitle' => $faker->word,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'notes' => $faker->sentence
|
||||
'first_name' => $faker->firstName,
|
||||
'last_name' => $faker->lastName,
|
||||
'username' => $faker->username,
|
||||
'password' => $faker->password,
|
||||
'permissions' => '{"user":"0"}',
|
||||
'email' => $faker->safeEmail,
|
||||
'company_id' => function () {
|
||||
return factory(App\Models\Company::class)->create()->id;
|
||||
},
|
||||
'locale' => $faker->locale,
|
||||
'employee_num' => $faker->numberBetween(3500, 35050),
|
||||
'jobtitle' => $faker->word,
|
||||
'phone' => $faker->phoneNumber,
|
||||
'notes' => $faker->sentence,
|
||||
'location_id' => function () {
|
||||
return factory(App\Models\Location::class)->create()->id;
|
||||
},
|
||||
];
|
||||
});
|
||||
// USER GLOBAL PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'superuser', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
'permissions' => '{"superuser":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -33,7 +38,7 @@ $factory->state(App\Models\User::class, 'admin', function ($faker) {
|
|||
// USER ASSET PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-assets', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"assets.view":"1"}',
|
||||
'permissions' => '{"assets.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -51,7 +56,7 @@ $factory->state(App\Models\User::class, 'edit-assets', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-assets', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"assets.delete":"1",}',
|
||||
'permissions' => '{"assets.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -76,7 +81,7 @@ $factory->state(App\Models\User::class, 'view-requestable-assets', function ($fa
|
|||
// USER ACCESSORY PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-accessories', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"accessories.view":"1"}',
|
||||
'permissions' => '{"accessories.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -94,7 +99,7 @@ $factory->state(App\Models\User::class, 'edit-accessories', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-accessories', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"accessories.delete":"1",}',
|
||||
'permissions' => '{"accessories.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -113,7 +118,7 @@ $factory->state(App\Models\User::class, 'checkout-accessories', function ($faker
|
|||
// USER CONSUMABLE PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-consumables', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"consumables.view":"1"}',
|
||||
'permissions' => '{"consumables.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -131,7 +136,7 @@ $factory->state(App\Models\User::class, 'edit-consumables', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-consumables', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"consumables.delete":"1",}',
|
||||
'permissions' => '{"consumables.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -150,7 +155,7 @@ $factory->state(App\Models\User::class, 'checkout-consumables', function ($faker
|
|||
// USER LICENSE PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-licenses', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"licenses.view":"1"}',
|
||||
'permissions' => '{"licenses.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -168,7 +173,7 @@ $factory->state(App\Models\User::class, 'edit-licenses', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-licenses', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"licenses.delete":"1",}',
|
||||
'permissions' => '{"licenses.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -187,7 +192,7 @@ $factory->state(App\Models\User::class, 'view-keys-licenses', function ($faker)
|
|||
// USER COMPONENTS PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-components', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"components.view":"1"}',
|
||||
'permissions' => '{"components.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -205,7 +210,7 @@ $factory->state(App\Models\User::class, 'edit-components', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-components', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"components.delete":"1",}',
|
||||
'permissions' => '{"components.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -224,7 +229,7 @@ $factory->state(App\Models\User::class, 'checkout-components', function ($faker)
|
|||
// USER USER PERMISSION STATES
|
||||
$factory->state(App\Models\User::class, 'view-users', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"users.view":"1"}',
|
||||
'permissions' => '{"users.view":"1"}',
|
||||
];
|
||||
});
|
||||
|
||||
|
@ -242,6 +247,6 @@ $factory->state(App\Models\User::class, 'edit-users', function ($faker) {
|
|||
|
||||
$factory->state(App\Models\User::class, 'delete-users', function ($faker) {
|
||||
return [
|
||||
'permissions' => '{"users.delete":"1",}',
|
||||
'permissions' => '{"users.delete":"1"}',
|
||||
];
|
||||
});
|
||||
|
|
|
@ -7,6 +7,6 @@ class AccessorySeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Accessory::truncate();
|
||||
factory(Accessory::class, 'accessory',15)->create();
|
||||
factory(Accessory::class,15)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ class ActionlogSeeder extends Seeder
|
|||
{
|
||||
Actionlog::truncate();
|
||||
factory(Actionlog::class, 'asset-checkout',25)->create();
|
||||
factory(Actionlog::class, 'accessory-checkout',15)->create();
|
||||
factory(Actionlog::class, 'consumable-checkout', 15)->create();
|
||||
factory(Actionlog::class, 'component-checkout', 15)->create();
|
||||
factory(Actionlog::class, 'license-checkout-asset', 15)->create();
|
||||
// factory(Actionlog::class, 'accessory-checkout',15)->create();
|
||||
// factory(Actionlog::class, 'consumable-checkout', 15)->create();
|
||||
// factory(Actionlog::class, 'component-checkout', 15)->create();
|
||||
// factory(Actionlog::class, 'license-checkout-asset', 15)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class AssetModelSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
AssetModel::truncate();
|
||||
factory(AssetModel::class, 'assetmodel',5)->create();
|
||||
factory(AssetModel::class,5)->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,6 @@ class AssetSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Asset::truncate();
|
||||
factory(Asset::class, 'asset', 100)->create();
|
||||
|
||||
// factory(App\Models\Asset::class, 50)->create()->each(function($u) {
|
||||
// $u->assetmodel()->save(factory(App\AssetModel::class)->make());
|
||||
// });
|
||||
factory(Asset::class, 100)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ class CategorySeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Category::truncate();
|
||||
factory(Category::class, 'category', 10)->create(['category_type' => 'asset']);
|
||||
factory(Category::class, 'category', 10)->create(['category_type' => 'accessory']);
|
||||
factory(Category::class, 'category', 10)->create(['category_type' => 'consumable']);
|
||||
factory(Category::class, 'category', 10)->create(['category_type' => 'component']);
|
||||
factory(Category::class, 10)->states('asset-category')->create();
|
||||
factory(Category::class, 10)->states('accessory-category')->create();
|
||||
factory(Category::class, 10)->states('component-category')->create();
|
||||
factory(Category::class, 10)->states('consumable-category')->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,6 @@ class CompanySeeder extends Seeder
|
|||
{
|
||||
//
|
||||
Company::truncate();
|
||||
factory(Company::class, 'company', 4)->create();
|
||||
factory(Company::class, 4)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ use App\Models\Component;
|
|||
|
||||
class ComponentSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Component::truncate();
|
||||
DB::table('components_assets')->truncate();
|
||||
factory(Component::class, 'component',10)->create();
|
||||
}
|
||||
public function run()
|
||||
{
|
||||
Component::truncate();
|
||||
DB::table('components_assets')->truncate();
|
||||
factory(Component::class, 10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use App\Models\Consumable;
|
|||
|
||||
class ConsumableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Consumable::truncate();
|
||||
factory(Consumable::class, 'consumable',25)->create();
|
||||
}
|
||||
public function run()
|
||||
{
|
||||
Consumable::truncate();
|
||||
factory(Consumable::class, 25)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use App\Models\Depreciation;
|
|||
|
||||
class DepreciationSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Depreciation::truncate();
|
||||
factory(Depreciation::class, 'depreciation')->create();
|
||||
}
|
||||
public function run()
|
||||
{
|
||||
Depreciation::truncate();
|
||||
factory(Depreciation::class, 5)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,19 +3,14 @@ use Illuminate\Database\Seeder;
|
|||
use App\Models\License;
|
||||
use App\Models\LicenseSeat;
|
||||
|
||||
|
||||
class LicenseSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
License::truncate();
|
||||
factory(License::class, 'license', 10)->create();
|
||||
public function run()
|
||||
{
|
||||
License::truncate();
|
||||
factory(License::class, 10)->create();
|
||||
|
||||
LicenseSeat::truncate();
|
||||
factory(LicenseSeat::class, 'license-seat', 10)->create();
|
||||
|
||||
// factory(App\Models\Asset::class, 50)->create()->each(function($u) {
|
||||
// $u->assetmodel()->save(factory(App\AssetModel::class)->make());
|
||||
// });
|
||||
}
|
||||
LicenseSeat::truncate();
|
||||
factory(LicenseSeat::class, 10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@ use App\Models\Location;
|
|||
|
||||
class LocationSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
Location::truncate();
|
||||
factory(Location::class, 'location', 5)->create();
|
||||
|
||||
}
|
||||
public function run()
|
||||
{
|
||||
Location::truncate();
|
||||
factory(Location::class, 5)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ class ManufacturerSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
Manufacturer::truncate();
|
||||
factory(Manufacturer::class, 'manufacturer', 10)->create();
|
||||
factory(Manufacturer::class, 10)->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,14 +7,13 @@ class StatuslabelSeeder extends Seeder
|
|||
{
|
||||
public function run()
|
||||
{
|
||||
Statuslabel::truncate();
|
||||
factory(Statuslabel::class, 'rtd')->create();
|
||||
factory(Statuslabel::class, 'pending')->create();
|
||||
factory(Statuslabel::class, 'archived')->create();
|
||||
factory(Statuslabel::class, 'out_for_diagnostics')->create();
|
||||
factory(Statuslabel::class, 'out_for_repair')->create();
|
||||
factory(Statuslabel::class, 'broken')->create();
|
||||
factory(Statuslabel::class, 'lost')->create();
|
||||
Statuslabel::truncate();
|
||||
factory(Statuslabel::class)->states('rtd')->create(['name' => "Ready to Deploy"]);
|
||||
factory(Statuslabel::class)->states('pending')->create(['name' => "Pending"]);
|
||||
factory(Statuslabel::class)->states('archived')->create(['name' => "Archived"]);
|
||||
factory(Statuslabel::class)->states('out_for_diagnostics')->create();
|
||||
factory(Statuslabel::class)->states('out_for_repair')->create();
|
||||
factory(Statuslabel::class)->states('broken')->create();
|
||||
factory(Statuslabel::class)->states('lost')->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,7 @@ class SupplierSeeder extends Seeder
|
|||
{
|
||||
public function run()
|
||||
{
|
||||
Supplier::truncate();
|
||||
factory(Supplier::class, 'supplier',5)->create();
|
||||
Supplier::truncate();
|
||||
factory(Supplier::class, 5)->create();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ class UserSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
// Don't truncate the user column, that might suck.
|
||||
factory(User::class, 'valid-user', 10)->create();
|
||||
factory(User::class, 10)->create();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,5 +23,7 @@
|
|||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
|
||||
<env name="DB_CONNECTION" value="sqlite_testing" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
name="location_users"
|
||||
id="table-users"
|
||||
class="table table-striped snipe-table"
|
||||
data-url="{{route('api.locations.viewusers', $location->id)}}"
|
||||
data-url="{{route('api.users.index', ['location_id' => $location->id]) }}"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
data-cookie-id-table="location_usersDetailTable">
|
||||
|
@ -54,7 +54,7 @@
|
|||
<table
|
||||
name="location_assets"
|
||||
id="table-assets"
|
||||
data-url="{{route('api.locations.viewassets', $location->id)}}"
|
||||
data-url="{{route('api.assets.index', ['location_id' => $location->id]) }}"
|
||||
class="table table-striped snipe-table"
|
||||
data-cookie="true"
|
||||
data-click-to-select="true"
|
||||
|
|
|
@ -295,20 +295,6 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
|
||||
Route::group(['prefix' => 'locations'], function () {
|
||||
|
||||
Route::get('{location}/users',
|
||||
[
|
||||
'as'=>'api.locations.viewusers',
|
||||
'uses'=>'LocationsController@getDataViewUsers'
|
||||
]
|
||||
);
|
||||
|
||||
Route::get('{location}/assets',
|
||||
[
|
||||
'as'=>'api.locations.viewassets',
|
||||
'uses'=>'LocationsController@getDataViewAssets'
|
||||
]
|
||||
);
|
||||
|
||||
// Do we actually still need this, now that we have an API?
|
||||
Route::get('{location}/check',
|
||||
[
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -21,7 +21,7 @@ class ApiAssetsCest
|
|||
$I->wantTo('Get a list of assets');
|
||||
|
||||
// setup
|
||||
$assets = factory(\App\Models\Asset::class, 'asset', 10)->create();
|
||||
$assets = factory(\App\Models\Asset::class, 10)->create();
|
||||
|
||||
// call
|
||||
$I->sendGET('/hardware');
|
||||
|
@ -121,7 +121,7 @@ class ApiAssetsCest
|
|||
{
|
||||
$I->wantTo('Create a new asset');
|
||||
|
||||
$temp_asset = factory(\App\Models\Asset::class, 'asset')->make();
|
||||
$temp_asset = factory(\App\Models\Asset::class)->make();
|
||||
|
||||
// setup
|
||||
$data = [
|
||||
|
@ -153,10 +153,10 @@ class ApiAssetsCest
|
|||
$I->wantTo('Update an asset with PATCH');
|
||||
|
||||
// create
|
||||
$asset = factory(\App\Models\Asset::class, 'asset')->create();
|
||||
$asset = factory(\App\Models\Asset::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
|
||||
|
||||
$temp_asset = factory(\App\Models\Asset::class, 'asset')->make();
|
||||
$temp_asset = factory(\App\Models\Asset::class)->make();
|
||||
|
||||
$data = [
|
||||
'asset_tag' => $temp_asset->asset_tag,
|
||||
|
@ -279,11 +279,11 @@ class ApiAssetsCest
|
|||
$I->wantTo('Update a asset with PUT');
|
||||
|
||||
// create
|
||||
$asset = factory(\App\Models\Asset::class, 'asset')->create();
|
||||
$asset = factory(\App\Models\Asset::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
|
||||
|
||||
$temp_asset_tag = $this->faker->uuid;
|
||||
$temp_asset = factory(\App\Models\Asset::class, 'asset')->make([
|
||||
$temp_asset = factory(\App\Models\Asset::class)->make([
|
||||
'asset_tag' => $temp_asset_tag,
|
||||
]);
|
||||
|
||||
|
@ -411,7 +411,7 @@ class ApiAssetsCest
|
|||
$I->wantTo('Delete an asset');
|
||||
|
||||
// create
|
||||
$asset = factory(\App\Models\Asset::class, 'asset')->create();
|
||||
$asset = factory(\App\Models\Asset::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
|
||||
|
||||
// delete
|
||||
|
|
|
@ -19,11 +19,11 @@ class ApiComponentsAssetsCest
|
|||
$I->wantTo('Get a list of assets related to a component');
|
||||
|
||||
// generate component
|
||||
$component = factory(\App\Models\Component::class, 'component')
|
||||
$component = factory(\App\Models\Component::class)
|
||||
->create(['user_id' => $this->user->id, 'qty' => 20]);
|
||||
|
||||
// generate assets and associate component
|
||||
$assets = factory(\App\Models\Asset::class, 'asset', 2)
|
||||
$assets = factory(\App\Models\Asset::class, 2)
|
||||
->create(['user_id' => $this->user->id])
|
||||
->each(function ($asset) use ($component) {
|
||||
$component->assets()->attach($component->id, [
|
||||
|
@ -65,7 +65,7 @@ class ApiComponentsAssetsCest
|
|||
{
|
||||
$I->wantTo('See an empty response when there are no associated assets to a component');
|
||||
|
||||
$component = factory(\App\Models\Component::class, 'component')
|
||||
$component = factory(\App\Models\Component::class)
|
||||
->create(['user_id' => $this->user->id, 'qty' => 20]);
|
||||
|
||||
$I->sendGET('/components/' . $component->id . '/assets');
|
||||
|
|
|
@ -21,7 +21,7 @@ class ApiComponentsCest
|
|||
$I->wantTo('Get a list of components');
|
||||
|
||||
// setup
|
||||
$components = factory(\App\Models\Component::class, 'component', 10)->create();
|
||||
$components = factory(\App\Models\Component::class, 10)->create();
|
||||
|
||||
// call
|
||||
$I->sendGET('/components');
|
||||
|
@ -46,9 +46,9 @@ class ApiComponentsCest
|
|||
$I->wantTo('Create a new component');
|
||||
|
||||
// setup
|
||||
$category = factory(\App\Models\Category::class, 'category')->create(['user_id' => $this->user->id]);
|
||||
$location = factory(\App\Models\Location::class, 'location')->create(['user_id' => $this->user->id]);
|
||||
$company = factory(\App\Models\Company::class, 'company')->create();
|
||||
$category = factory(\App\Models\Category::class)->create(['user_id' => $this->user->id]);
|
||||
$location = factory(\App\Models\Location::class)->create(['user_id' => $this->user->id]);
|
||||
$company = factory(\App\Models\Company::class)->create();
|
||||
|
||||
$data = [
|
||||
'category_id' => $category->id,
|
||||
|
@ -107,7 +107,7 @@ class ApiComponentsCest
|
|||
$I->wantTo('Update a component with PATCH');
|
||||
|
||||
// create
|
||||
$component = factory(\App\Models\Component::class, 'component')->create();
|
||||
$component = factory(\App\Models\Component::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Component::class, $component);
|
||||
|
||||
$data = [
|
||||
|
@ -142,7 +142,7 @@ class ApiComponentsCest
|
|||
$I->wantTo('Update a component with PUT');
|
||||
|
||||
// create
|
||||
$component = factory(\App\Models\Component::class, 'component')->create();
|
||||
$component = factory(\App\Models\Component::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Component::class, $component);
|
||||
|
||||
$data = [
|
||||
|
@ -176,7 +176,7 @@ class ApiComponentsCest
|
|||
$I->wantTo('Delete a component');
|
||||
|
||||
// create
|
||||
$component = factory(\App\Models\Component::class, 'component')->create();
|
||||
$component = factory(\App\Models\Component::class)->create();
|
||||
$I->assertInstanceOf(\App\Models\Component::class, $component);
|
||||
|
||||
// delete
|
||||
|
|
|
@ -53,7 +53,7 @@ class AccessoriesCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$accessory = factory(App\Models\Accessory::class,'accessory')->make();
|
||||
$accessory = factory(App\Models\Accessory::class)->make();
|
||||
$values = [
|
||||
'company_id' => $accessory->company_id,
|
||||
'name' => $accessory->name,
|
||||
|
|
|
@ -33,7 +33,7 @@ class AssetModelsCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$model = factory(App\Models\AssetModel::class, 'assetmodel')->make();
|
||||
$model = factory(App\Models\AssetModel::class)->make();
|
||||
$values = [
|
||||
'name' => $model->name,
|
||||
'manufacturer_id' => $model->manufacturer_id,
|
||||
|
@ -56,7 +56,7 @@ class AssetModelsCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete an asset model');
|
||||
$model = factory(App\Models\AssetModel::class, 'assetmodel')->create();
|
||||
$model = factory(App\Models\AssetModel::class)->create();
|
||||
$I->sendDelete(route('models.destroy', $model->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class AssetsCest
|
|||
|
||||
public function passesCreateAndCheckout(FunctionalTester $I)
|
||||
{
|
||||
$asset = factory(App\Models\Asset::class,'asset')->make();
|
||||
$asset = factory(App\Models\Asset::class)->make();
|
||||
$userId = $I->getUserId();
|
||||
$values = [
|
||||
'company_id' => $asset->company_id,
|
||||
|
|
|
@ -37,7 +37,7 @@ class CategoriesCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$category = factory(App\Models\Category::class, 'category')->make();
|
||||
$category = factory(App\Models\Category::class)->make();
|
||||
$values = [
|
||||
'name' => $category->name,
|
||||
'category_type' => $category->category_type,
|
||||
|
@ -55,7 +55,7 @@ class CategoriesCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete a category');
|
||||
$category = factory(App\Models\Category::class, 'category')->create();
|
||||
$category = factory(App\Models\Category::class)->create();
|
||||
$I->sendDelete(route('categories.destroy', $category->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class CompaniesCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$company = factory(App\Models\Company::class, 'company')->make();
|
||||
$company = factory(App\Models\Company::class)->make();
|
||||
$values = [
|
||||
'name' => $company->name
|
||||
];
|
||||
|
|
|
@ -47,7 +47,7 @@ class ComponentsCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$component = factory(App\Models\Component::class, 'component')->make();
|
||||
$component = factory(App\Models\Component::class)->make();
|
||||
|
||||
$values = [
|
||||
'name' => $component->name,
|
||||
|
|
|
@ -48,7 +48,7 @@ class ConsumablesCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$consumable = factory(App\Models\Consumable::class, 'consumable')->make();
|
||||
$consumable = factory(App\Models\Consumable::class)->make();
|
||||
$values = [
|
||||
'company_id' => $consumable->company_id,
|
||||
'name' => $consumable->name,
|
||||
|
|
|
@ -44,7 +44,7 @@ class DepreciationCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$depreciation = factory(App\Models\Depreciation::class, 'depreciation')->make();
|
||||
$depreciation = factory(App\Models\Depreciation::class)->make();
|
||||
$values = [
|
||||
'name' => $depreciation->name,
|
||||
'months' => $depreciation->months
|
||||
|
|
|
@ -47,7 +47,7 @@ class LicensesCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$license = factory(App\Models\License::class, 'license')->make();
|
||||
$license = factory(App\Models\License::class)->make();
|
||||
$values = [
|
||||
'name' => $license->name,
|
||||
'serial' => $license->serial,
|
||||
|
|
|
@ -45,7 +45,7 @@ class LocationsCest
|
|||
}
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$location = factory(App\Models\Location::class, 'location')->make();
|
||||
$location = factory(App\Models\Location::class)->make();
|
||||
$values = [
|
||||
'name' => $location->name,
|
||||
'parent_id' => $I->getLocationId(),
|
||||
|
@ -67,7 +67,7 @@ class LocationsCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete a location');
|
||||
$location = factory(App\Models\Location::class, 'location')->create();
|
||||
$location = factory(App\Models\Location::class)->create();
|
||||
$I->sendDelete(route('locations.destroy', $location->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ManufacturersCest
|
|||
}
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$manufacturer = factory(App\Models\Manufacturer::class, 'manufacturer')->make();
|
||||
$manufacturer = factory(App\Models\Manufacturer::class)->make();
|
||||
$values = [
|
||||
'name' => $manufacturer->name
|
||||
];
|
||||
|
@ -57,7 +57,7 @@ class ManufacturersCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete a manufacturer');
|
||||
$manufacturerId = factory(App\Models\Manufacturer::class, 'manufacturer')->create()->id;
|
||||
$manufacturerId = factory(App\Models\Manufacturer::class)->create()->id;
|
||||
$I->sendDelete(route('manufacturers.destroy', $manufacturerId), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class StatusLabelsCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$status = factory(App\Models\Statuslabel::class, 'pending')->make();
|
||||
$status = factory(App\Models\Statuslabel::class)->states('pending')->make();
|
||||
$submitValues = [
|
||||
'name' => 'Testing Status',
|
||||
'statuslabel_types' => 'pending',
|
||||
|
|
|
@ -40,7 +40,7 @@ class SuppliersCest
|
|||
}
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$supplier = factory(App\Models\Supplier::class, 'supplier')->make();
|
||||
$supplier = factory(App\Models\Supplier::class)->make();
|
||||
$values = [
|
||||
'name' => $supplier->name,
|
||||
'address' => $supplier->address,
|
||||
|
@ -66,7 +66,7 @@ class SuppliersCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete a supplier');
|
||||
$supplier = factory(App\Models\Supplier::class, 'supplier')->create();
|
||||
$supplier = factory(App\Models\Supplier::class)->create();
|
||||
$I->sendDelete(route('suppliers.destroy', $supplier->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ class UsersCest
|
|||
}
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$user = factory(App\Models\User::class, 'valid-user')->make();
|
||||
$user = factory(App\Models\User::class)->make();
|
||||
$submitValues = [
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
|
@ -61,8 +61,8 @@ class UsersCest
|
|||
'locale' => $user->locale,
|
||||
'employee_num' => $user->employee_num,
|
||||
'jobtitle' => $user->jobtitle,
|
||||
'manager_id' => 19,
|
||||
'location_id' => 67,
|
||||
'manager_id' => $user->manager_id,
|
||||
'location_id' => $user->location_id,
|
||||
'phone' => $user->phone,
|
||||
'activated' => true,
|
||||
'notes' => $user->notes
|
||||
|
@ -76,8 +76,8 @@ class UsersCest
|
|||
'locale' => $user->locale,
|
||||
'employee_num' => $user->employee_num,
|
||||
'jobtitle' => $user->jobtitle,
|
||||
'manager_id' => 19,
|
||||
'location_id' => 67,
|
||||
'manager_id' => $user->manager_id,
|
||||
'location_id' => $user->location_id,
|
||||
'phone' => $user->phone,
|
||||
'activated' => true,
|
||||
'notes' => $user->notes
|
||||
|
@ -91,7 +91,7 @@ class UsersCest
|
|||
|
||||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$user = factory(App\Models\User::class, 'valid-user')->create();
|
||||
$user = factory(App\Models\User::class)->create();
|
||||
$I->wantTo('Ensure I can delete a user');
|
||||
$I->sendDelete(route('users.destroy', $user->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
@ -7,23 +8,105 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
|
||||
class AccessoryTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testAccessoryAdd()
|
||||
{
|
||||
$accessory = factory(Accessory::class, 'accessory')->make();
|
||||
$values = [
|
||||
'name' => $accessory->name,
|
||||
'category_id' => $accessory->category_id,
|
||||
'qty' => $accessory->qty,
|
||||
];
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
Accessory::create($values);
|
||||
$this->tester->seeRecord('accessories', $values);
|
||||
}
|
||||
public function testAccessoryAdd()
|
||||
{
|
||||
$accessory = factory(Accessory::class)->make();
|
||||
|
||||
|
||||
$values = [
|
||||
'name' => $accessory->name,
|
||||
'category_id' => $accessory->category_id,
|
||||
'qty' => $accessory->qty,
|
||||
];
|
||||
Accessory::create($values);
|
||||
|
||||
$this->tester->seeRecord('accessories', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Accessory requires a name, a qty, and a category_id.
|
||||
$a = Accessory::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'qty' => 'qty',
|
||||
'category_id' => 'category id'
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testFailsMinValidation()
|
||||
{
|
||||
// An Accessory name has a min length of 3
|
||||
// An Accessory has a min qty of 1
|
||||
// An Accessory has a min amount of 0
|
||||
$a = factory(Accessory::class)->make([
|
||||
'name' => 'a',
|
||||
'qty' => 0,
|
||||
'min_amt' => -1
|
||||
]);
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'qty' => 'qty',
|
||||
'min_amt' => 'min amt'
|
||||
];
|
||||
$this->assertFalse($a->isValid());
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertContains("The ${fieldTitle} must be at least", $errors->get($field)[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCategoryIdMustExist()
|
||||
{
|
||||
$category = factory(Category::class)->create(['category_type' => 'accessory']);
|
||||
$accessory = factory(Accessory::class)->make(['category_id' => $category->id]);
|
||||
$accessory->save();
|
||||
$this->assertTrue($accessory->isValid());
|
||||
$newId = $category->id + 1;
|
||||
$accessory = factory(Accessory::class)->make(['category_id' => $newId]);
|
||||
$accessory->save();
|
||||
|
||||
$this->assertFalse($accessory->isValid());
|
||||
}
|
||||
|
||||
public function testAnAccessoryBelongsToACompany()
|
||||
{
|
||||
$accessory = factory(Accessory::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
|
||||
}
|
||||
|
||||
public function testAnAccessoryHasALocation()
|
||||
{
|
||||
$accessory = factory(Accessory::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
|
||||
}
|
||||
|
||||
public function testAnAccessoryBelongsToACategory()
|
||||
{
|
||||
$accessory = factory(Accessory::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
|
||||
$this->assertEquals('accessory', $accessory->category->category_type);
|
||||
}
|
||||
|
||||
public function testAnAccessoryHasAManufacturer()
|
||||
{
|
||||
$accessory = factory(Accessory::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AssetModelTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
|
@ -11,26 +12,43 @@ class AssetModelTest extends \Codeception\TestCase\Test
|
|||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testAssetModelAdd()
|
||||
{
|
||||
$assetmodel = factory(AssetModel::class, 'assetmodel')->make();
|
||||
$values = [
|
||||
$assetmodel = factory(AssetModel::class)->make();
|
||||
$values = [
|
||||
'name' => $assetmodel->name,
|
||||
'manufacturer_id' => $assetmodel->manufacturer_id,
|
||||
'category_id' => $assetmodel->category_id,
|
||||
'eol' => $assetmodel->eol,
|
||||
];
|
||||
];
|
||||
|
||||
AssetModel::create($values);
|
||||
$this->tester->seeRecord('models', $values);
|
||||
AssetModel::create($values);
|
||||
$this->tester->seeRecord('models', $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_zeros_blank_eol_but_not_others()
|
||||
public function testAnAssetModelRequiresAttributes()
|
||||
{
|
||||
// An Asset Model requires a name, a category_id, and a manufacturer_id.
|
||||
$a = AssetModel::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'manufacturer_id' => 'manufacturer id',
|
||||
'category_id' => 'category id'
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testAnAssetModelZerosOutBlankEols()
|
||||
{
|
||||
$am = new AssetModel;
|
||||
$am->eol = '';
|
||||
|
@ -38,4 +56,31 @@ class AssetModelTest extends \Codeception\TestCase\Test
|
|||
$am->eol = '4';
|
||||
$this->assertTrue($am->eol==4);
|
||||
}
|
||||
|
||||
public function testAnAssetModelContainsAssets()
|
||||
{
|
||||
$assetmodel = factory(AssetModel::class)->create();
|
||||
$asset = factory(Asset::class)->create([
|
||||
'model_id' => $assetmodel->id,
|
||||
]);
|
||||
$this->assertEquals(1,$assetmodel->assets()->count());
|
||||
}
|
||||
|
||||
public function testAnAssetModelHasACategory()
|
||||
{
|
||||
$assetmodel = factory(AssetModel::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Category::class, $assetmodel->category);
|
||||
}
|
||||
|
||||
public function anAssetModelHasADepreciation()
|
||||
{
|
||||
$assetmodel = factory(AssetModel::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Depreciation::class, $assetmodel->depreciation);
|
||||
}
|
||||
|
||||
public function testAnAssetModelHasAManufacturer()
|
||||
{
|
||||
$assetmodel = factory(AssetModel::class)->create();
|
||||
$this->assertInstanceOf(App\Models\Manufacturer::class, $assetmodel->manufacturer);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
use App\Models\Asset;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AssetTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
|
@ -11,31 +12,53 @@ class AssetTest extends \Codeception\TestCase\Test
|
|||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
use DatabaseTransactions;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testAssetAdd()
|
||||
{
|
||||
$asset = factory(Asset::class, 'asset')->make();
|
||||
$asset = factory(Asset::class)->make();
|
||||
$values = [
|
||||
'name' => $asset->name,
|
||||
'model_id' => $asset->model_id,
|
||||
'status_id' => $asset->status_id,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
];
|
||||
'name' => $asset->name,
|
||||
'model_id' => $asset->model_id,
|
||||
'status_id' => $asset->status_id,
|
||||
'asset_tag' => $asset->asset_tag,
|
||||
];
|
||||
|
||||
Asset::create($values);
|
||||
$this->tester->seeRecord('assets', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Asset requires a name, a qty, and a category_id.
|
||||
$a = Asset::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'model_id' => 'model id',
|
||||
'status_id' => 'status id',
|
||||
'asset_tag' => 'asset tag'
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function testWarrantyExpiresAttribute()
|
||||
{
|
||||
$asset = factory(\App\Models\Asset::class, 'asset')->create();
|
||||
$asset = factory(\App\Models\Asset::class)->create();
|
||||
|
||||
$asset->purchase_date = \Carbon\Carbon::createFromDate(2017, 1, 1);
|
||||
$asset->purchase_date = \Carbon\Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0);
|
||||
$asset->warranty_months = 24;
|
||||
$asset->save();
|
||||
|
||||
|
@ -43,22 +66,192 @@ class AssetTest extends \Codeception\TestCase\Test
|
|||
|
||||
$this->tester->assertInstanceOf(\DateTime::class, $saved_asset->purchase_date);
|
||||
$this->tester->assertEquals(
|
||||
\Carbon\Carbon::createFromDate(2017,1,1)->format('Y-m-d'),
|
||||
\Carbon\Carbon::createFromDate(2017, 1, 1)->format('Y-m-d'),
|
||||
$saved_asset->purchase_date->format('Y-m-d')
|
||||
);
|
||||
$this->tester->assertEquals(
|
||||
\Carbon\Carbon::createFromDate(2017,1,1)->setTime(0,0,0),
|
||||
\Carbon\Carbon::createFromDate(2017, 1, 1)->setTime(0, 0, 0),
|
||||
$saved_asset->purchase_date
|
||||
);
|
||||
$this->tester->assertEquals(24, $saved_asset->warranty_months);
|
||||
$this->tester->assertInstanceOf(\DateTime::class, $saved_asset->warranty_expires);
|
||||
$this->tester->assertEquals(
|
||||
\Carbon\Carbon::createFromDate(2019,1,1)->format('Y-m-d'),
|
||||
\Carbon\Carbon::createFromDate(2019, 1, 1)->format('Y-m-d'),
|
||||
$saved_asset->warranty_expires->format('Y-m-d')
|
||||
);
|
||||
$this->tester->assertEquals(
|
||||
\Carbon\Carbon::createFromDate(2019,1,1)->setTime(0,0,0),
|
||||
\Carbon\Carbon::createFromDate(2019, 1, 1)->setTime(0, 0, 0),
|
||||
$saved_asset->warranty_expires
|
||||
);
|
||||
}
|
||||
|
||||
public function testModelIdMustExist()
|
||||
{
|
||||
$model = factory(AssetModel::class)->create();
|
||||
$asset = factory(Asset::class)->make(['model_id' => $model->id]);
|
||||
$asset->save();
|
||||
$this->assertTrue($asset->isValid());
|
||||
$newId = $model->id + 1;
|
||||
$asset = factory(Asset::class)->make(['model_id' => $newId]);
|
||||
$asset->save();
|
||||
|
||||
$this->assertFalse($asset->isValid());
|
||||
}
|
||||
|
||||
public function testAnAssetHasRelationships()
|
||||
{
|
||||
$asset = factory(Asset::class)->create();
|
||||
$this->assertInstanceOf(AssetModel::class, $asset->model);
|
||||
$this->assertInstanceOf(Company::class, $asset->company);
|
||||
$this->assertInstanceOf(App\Models\Depreciation::class, $asset->depreciation);
|
||||
$this->assertInstanceOf(App\Models\Statuslabel::class, $asset->assetstatus);
|
||||
$this->assertInstanceOf(App\Models\Supplier::class, $asset->supplier);
|
||||
}
|
||||
|
||||
public function testAnAssetCanBeAvailableForCheckout()
|
||||
{
|
||||
// Logic: If the asset is not assigned to anyone,
|
||||
// and the statuslabel type is "deployable"
|
||||
// and the asset is not deleted
|
||||
// Then it is available for checkout
|
||||
|
||||
// An asset assigned to someone should not be available for checkout.
|
||||
$user = factory(App\Models\User::class)->create();
|
||||
$assetAssigned = factory(Asset::class)->create(['assigned_to' => $user->id]);
|
||||
$this->assertFalse($assetAssigned->availableForCheckout());
|
||||
|
||||
// An asset with a non deployable statuslabel should not be available for checkout.
|
||||
$status = factory(App\Models\Statuslabel::class)->states('archived')->create();
|
||||
$assetUndeployable = factory(Asset::class)->create(['status_id' => $status->id]);
|
||||
$this->assertFalse($assetUndeployable->availableForCheckout());
|
||||
|
||||
// An asset that has been deleted is not avaiable for checkout.
|
||||
$assetDeleted = factory(Asset::class)->states('deleted')->create();
|
||||
$this->assertFalse($assetDeleted->availableForCheckout());
|
||||
|
||||
// A ready to deploy asset that isn't assigned to anyone is available for checkout
|
||||
$status = factory(App\Models\Statuslabel::class)->states('rtd')->create();
|
||||
$asset = factory(Asset::class)->create(['status_id' => $status->id]);
|
||||
$this->assertTrue($asset->availableForCheckout());
|
||||
}
|
||||
|
||||
public function testAnAssetCanHaveComponents()
|
||||
{
|
||||
$asset = factory(Asset::class)->create();
|
||||
$components = factory(App\Models\Component::class, 5)->create();
|
||||
$components->each(function($component) use ($asset) {
|
||||
$component->assets()->attach($component, [
|
||||
'asset_id'=>$asset->id
|
||||
]);
|
||||
});
|
||||
$this->assertInstanceOf(App\Models\Component::class, $asset->components()->first());
|
||||
$this->assertCount(5, $asset->components);
|
||||
}
|
||||
|
||||
public function testAnAssetCanHaveUploads()
|
||||
{
|
||||
$asset = factory(Asset::class)->create();
|
||||
$this->assertCount(0, $asset->uploads);
|
||||
factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
|
||||
$this->assertCount(1, $asset->fresh()->uploads);
|
||||
}
|
||||
|
||||
// Helper Method for checking in assets.... We should extract this to the model or a trait.
|
||||
|
||||
private function checkin($asset, $target) {
|
||||
$asset->expected_checkin = null;
|
||||
$asset->last_checkout = null;
|
||||
$asset->assigned_to = null;
|
||||
$asset->assignedTo()->disassociate($asset);
|
||||
$asset->accepted = null;
|
||||
$asset->save();
|
||||
$asset->logCheckin($target, 'Test Checkin');
|
||||
}
|
||||
|
||||
public function testAnAssetCanBeCheckedOut()
|
||||
{
|
||||
// This tests Asset::checkOut(), Asset::assignedTo(), Asset::assignedAssets(), Asset::assetLoc(), Asset::assignedType(), defaultLoc()
|
||||
// Need to mock settings here to avoid issues with checkout notifications.
|
||||
factory(App\Models\Setting::class)->create();
|
||||
$asset = factory(Asset::class)->create();
|
||||
$adminUser = factory(App\Models\User::class)->states('superuser')->create();
|
||||
Auth::login($adminUser);
|
||||
|
||||
$target = factory(App\Models\User::class)->create();
|
||||
// An Asset Can be checked out to a user, and this should be logged.
|
||||
$asset->checkOut($target, $adminUser);
|
||||
$asset->save();
|
||||
|
||||
$this->assertInstanceOf(App\Models\User::class, $asset->assignedTo);
|
||||
$this->assertEquals($asset->assetLoc->id, $target->userLoc->id);
|
||||
$this->assertEquals('user', $asset->assignedType());
|
||||
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkout',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
$this->checkin($asset, $target);
|
||||
$this->assertNull($asset->fresh()->assignedTo);
|
||||
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkin from',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
|
||||
|
||||
// An Asset Can be checked out to a asset, and this should be logged.
|
||||
$target = factory(App\Models\Asset::class)->create();
|
||||
$asset->checkOut($target, $adminUser);
|
||||
$asset->save();
|
||||
$this->assertInstanceOf(App\Models\Asset::class, $asset->fresh()->assignedTo);
|
||||
$this->assertEquals($asset->fresh()->assetLoc->id, $target->fresh()->assetLoc->id);
|
||||
$this->assertEquals('asset', $asset->assignedType());
|
||||
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkout',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
|
||||
$this->assertCount(1, $target->assignedAssets);
|
||||
$this->checkin($asset, $target);
|
||||
$this->assertNull($asset->fresh()->assignedTo);
|
||||
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkin from',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
|
||||
// An Asset Can be checked out to a location, and this should be logged.
|
||||
$target = factory(App\Models\Location::class)->create();
|
||||
$asset->checkOut($target, $adminUser);
|
||||
$asset->save();
|
||||
$this->assertInstanceOf(App\Models\Location::class, $asset->fresh()->assignedTo);
|
||||
$this->assertEquals($asset->fresh()->assetLoc->id, $target->fresh()->id);
|
||||
$this->assertEquals('location', $asset->assignedType());
|
||||
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkout',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
$this->checkin($asset, $target);
|
||||
$this->assertNull($asset->fresh()->assignedTo);
|
||||
|
||||
$this->tester->seeRecord('action_logs', [
|
||||
'action_type' => 'checkin from',
|
||||
'target_type' => get_class($target),
|
||||
'target_id' => $target->id
|
||||
]);
|
||||
}
|
||||
|
||||
public function testAnAssetHasMaintenances()
|
||||
{
|
||||
$asset = factory(Asset::class)->create();
|
||||
factory(App\Models\AssetMaintenance::class)->create(['asset_id' => $asset->id]);
|
||||
$this->assertCount(1, $asset->assetmaintenances);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ class CategoryTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testAssetCategoryAdd()
|
||||
{
|
||||
$category = factory(Category::class, 'category')->make(['category_type' => 'asset']);
|
||||
$category = factory(Category::class)->make(['category_type' => 'asset']);
|
||||
$values = [
|
||||
'name' => $category->name,
|
||||
'category_type' => $category->category_type,
|
||||
|
@ -29,7 +34,7 @@ class CategoryTest extends \Codeception\TestCase\Test
|
|||
|
||||
public function testAccessoryCategoryAdd()
|
||||
{
|
||||
$category = factory(Category::class, 'category')->make(['category_type' => 'accessory']);
|
||||
$category = factory(Category::class)->make(['category_type' => 'accessory']);
|
||||
$values = [
|
||||
'name' => $category->name,
|
||||
'category_type' => $category->category_type,
|
||||
|
@ -40,4 +45,57 @@ class CategoryTest extends \Codeception\TestCase\Test
|
|||
Category::create($values);
|
||||
$this->tester->seeRecord('categories', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Asset requires a name, a qty, and a category_id.
|
||||
$a = Category::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'category_type' => 'category type'
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testACategoryCanHaveAssets()
|
||||
{
|
||||
$category = factory(Category::class)->create(['category_type' => 'asset']);
|
||||
$models = factory(App\Models\AssetModel::class, 5)->create(['category_id' => $category->id]);
|
||||
$this->assertEquals(5, $category->has_models());
|
||||
$this->assertCount(5, $category->models);
|
||||
|
||||
$models->each(function($model) {
|
||||
factory(App\Models\Asset::class, 2)->create(['model_id' => $model->id]);
|
||||
});
|
||||
$this->assertEquals(10, $category->itemCount());
|
||||
}
|
||||
|
||||
public function testACategoryCanHaveAccessories()
|
||||
{
|
||||
$category = factory(Category::class)->create(['category_type' => 'accessory']);
|
||||
factory(App\Models\Accessory::class, 5)->create(['category_id' => $category->id]);
|
||||
$this->assertCount(5, $category->accessories);
|
||||
$this->assertEquals(5, $category->itemCount());
|
||||
}
|
||||
|
||||
public function testACategoryCanHaveConsumables()
|
||||
{
|
||||
$category = factory(Category::class)->create(['category_type' => 'consumable']);
|
||||
factory(App\Models\Consumable::class, 5)->create(['category_id' => $category->id]);
|
||||
$this->assertCount(5, $category->consumables);
|
||||
$this->assertEquals(5, $category->itemCount());
|
||||
}
|
||||
|
||||
public function testACategoryCanHaveComponents()
|
||||
{
|
||||
$category = factory(Category::class)->create(['category_type' => 'component']);
|
||||
factory(App\Models\Component::class, 5)->create(['category_id' => $category->id]);
|
||||
$this->assertCount(5, $category->components);
|
||||
$this->assertEquals(5, $category->itemCount());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,81 @@ class CompanyTest extends \Codeception\TestCase\Test
|
|||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
private $company;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
|
||||
$this->company = factory(Company::class)->create();
|
||||
}
|
||||
|
||||
public function testAssetAdd()
|
||||
{
|
||||
$company = factory(Company::class, 'company')->make();
|
||||
$values = [
|
||||
$company = factory(Company::class)->make();
|
||||
$values = [
|
||||
'name' => $company->name,
|
||||
];
|
||||
];
|
||||
|
||||
Company::create($values);
|
||||
$this->tester->seeRecord('companies', $values);
|
||||
Company::create($values);
|
||||
$this->tester->seeRecord('companies', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Company requires a name, a qty, and a category_id.
|
||||
$a = Company::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveUsers()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\User::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->users);
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveAssets()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\Asset::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->assets);
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveLicenses()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\License::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->licenses);
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveAccessories()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\Accessory::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->accessories);
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveConsumables()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\Consumable::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->consumables);
|
||||
}
|
||||
|
||||
public function testACompanyCanHaveComponents()
|
||||
{
|
||||
$this->company = factory(Company::class)->create();
|
||||
factory(App\Models\Component::class, 1)->create(['company_id'=>$this->company->id]);
|
||||
$this->assertCount(1, $this->company->components);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ class ConsumableTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testConsumableAdd()
|
||||
{
|
||||
$consumable = factory(Consumable::class, 'consumable')->make();
|
||||
$consumable = factory(Consumable::class)->make();
|
||||
$values = [
|
||||
'name' => $consumable->name,
|
||||
'qty' => $consumable->qty,
|
||||
|
@ -27,4 +32,31 @@ class ConsumableTest extends \Codeception\TestCase\Test
|
|||
$this->tester->seeRecord('consumables', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Consumable requires a name, a qty, and a category_id.
|
||||
$a = Consumable::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'qty' => 'qty',
|
||||
'category_id' => 'category id'
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testAConsumableHasRelationships()
|
||||
{
|
||||
$consumable = factory(Consumable::class)->create();
|
||||
$this->assertInstanceOf(App\Models\User::class, $consumable->admin);
|
||||
$this->assertInstanceOf(App\Models\Company::class, $consumable->company);
|
||||
$this->assertInstanceOf(App\Models\Manufacturer::class, $consumable->manufacturer);
|
||||
$this->assertInstanceOf(App\Models\Location::class, $consumable->location);
|
||||
$this->assertInstanceOf(App\Models\Category::class, $consumable->category);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ class CustomFieldTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testConstructor()
|
||||
{
|
||||
$customfield = new CustomField();
|
||||
|
@ -21,7 +26,7 @@ class CustomFieldTest extends \Codeception\TestCase\Test
|
|||
|
||||
public function testFormat()
|
||||
{
|
||||
$customfield = factory(CustomField::class, 'customfield-ip')->make();
|
||||
$customfield = factory(CustomField::class)->make();
|
||||
$values = [
|
||||
'name' => $customfield->name,
|
||||
'format' => $customfield->format,
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
use App\Models\Department;
|
||||
use App\Models\Location;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class DepartmentTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
|
@ -11,13 +12,20 @@ class DepartmentTest extends \Codeception\TestCase\Test
|
|||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
use DatabaseTransactions;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testDepartmentAdd()
|
||||
{
|
||||
$department = factory(Department::class, 'department')->make();
|
||||
$department = factory(Department::class)->make();
|
||||
$values = [
|
||||
'name' => $department->name,
|
||||
'user_id' => $department->user_id,
|
||||
'manager_id' => $department->manager_id,
|
||||
];
|
||||
|
||||
Department::create($values);
|
||||
|
|
|
@ -12,9 +12,14 @@ class DepreciationTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testDepreciationAdd()
|
||||
{
|
||||
$depreciations = factory(Depreciation::class, 'depreciation')->make();
|
||||
$depreciations = factory(Depreciation::class)->make();
|
||||
$values = [
|
||||
'name' => $depreciations->name,
|
||||
'months' => $depreciations->months,
|
||||
|
@ -24,4 +29,33 @@ class DepreciationTest extends \Codeception\TestCase\Test
|
|||
$this->tester->seeRecord('depreciations', $values);
|
||||
}
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Asset requires a name, a qty, and a category_id.
|
||||
$a = Depreciation::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'months' => 'months',
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testADepreciationHasModels()
|
||||
{
|
||||
$depreciation = factory(Depreciation::class)->create();
|
||||
factory(App\Models\AssetModel::class, 5)->create(['depreciation_id'=>$depreciation->id]);
|
||||
$this->assertEquals(5,$depreciation->has_models());
|
||||
}
|
||||
|
||||
public function testADepreciationHasLicenses()
|
||||
{
|
||||
$depreciation = factory(Depreciation::class)->create();
|
||||
factory(App\Models\License::class, 5)->create(['depreciation_id'=>$depreciation->id]);
|
||||
$this->assertEquals(5,$depreciation->has_licenses());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,20 +8,24 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class LocationTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testLocationAdd()
|
||||
protected function _before()
|
||||
{
|
||||
$location = factory(Location::class, 'location')->make();
|
||||
$values = [
|
||||
'name' => $location->name,
|
||||
];
|
||||
|
||||
Location::create($values);
|
||||
$this->tester->seeRecord('locations', $values);
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testAssetAdd()
|
||||
{
|
||||
$location = factory(Location::class)->make();
|
||||
$values = [
|
||||
'name' => $location->name,
|
||||
];
|
||||
|
||||
Location::create($values);
|
||||
$this->tester->seeRecord('locations', $values);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ class ManufacturerTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testManufacturerAdd()
|
||||
{
|
||||
$manufacturers = factory(Manufacturer::class, 'manufacturer')->make();
|
||||
$manufacturers = factory(Manufacturer::class)->make();
|
||||
$values = [
|
||||
'name' => $manufacturers->name,
|
||||
];
|
||||
|
|
|
@ -10,66 +10,56 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class PermissionsTest extends TestCase
|
||||
class PermissionsTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
// use DatabaseMigrations;
|
||||
use DatabaseTransactions;
|
||||
public function setUp()
|
||||
|
||||
public function _before()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->hardwareId = Asset::first()->id;
|
||||
Artisan::call('migrate');
|
||||
$this->noHardware = [
|
||||
route('hardware.index') => 403,
|
||||
route('hardware.create') => 403,
|
||||
route('hardware.edit', $this->hardwareId) => 403,
|
||||
route('hardware.show', $this->hardwareId) => 403,
|
||||
'assets.view' => false,
|
||||
'assets.create' => false,
|
||||
'assets.edit' => false,
|
||||
'assets.delete' => false,
|
||||
];
|
||||
|
||||
$this->licenseId = License::first()->id;
|
||||
$this->noLicenses = [
|
||||
route('licenses.index') => 403,
|
||||
route('licenses.create') => 403,
|
||||
route('licenses.edit', $this->licenseId) => 403,
|
||||
route('licenses.show', $this->licenseId) => 403,
|
||||
'licenses.view' => false,
|
||||
'licenses.create' => false,
|
||||
'licenses.edit' => false,
|
||||
'licenses.delete' => false,
|
||||
];
|
||||
|
||||
$this->accessoryId = Accessory::first()->id;
|
||||
$this->noAccessories = [
|
||||
route('accessories.index') => 403,
|
||||
route('accessories.create') => 403,
|
||||
route('accessories.edit', $this->accessoryId) => 403,
|
||||
route('accessories.show', $this->accessoryId) => 403,
|
||||
'accessories.view' => false,
|
||||
'accessories.create' => false,
|
||||
'accessories.edit' => false,
|
||||
'accessories.delete' => false,
|
||||
];
|
||||
|
||||
$this->consumableId = Consumable::first()->id;
|
||||
$this->noConsumables = [
|
||||
route('consumables.index') => 403,
|
||||
route('consumables.create') => 403,
|
||||
route('consumables.edit', $this->consumableId) => 403,
|
||||
route('consumables.show', $this->consumableId) => 403,
|
||||
'consumables.view' => false,
|
||||
'consumables.create' => false,
|
||||
'consumables.edit' => false,
|
||||
'consumables.delete' => false,
|
||||
];
|
||||
|
||||
$this->componentId = Component::first()->id;
|
||||
$this->noComponents = [
|
||||
route('components.index') => 403,
|
||||
route('components.create') => 403,
|
||||
route('components.edit', $this->componentId) => 403,
|
||||
route('components.show', $this->componentId) => 403,
|
||||
'components.view' => false,
|
||||
'components.create' => false,
|
||||
'components.edit' => false,
|
||||
'components.delete' => false,
|
||||
];
|
||||
|
||||
$this->userId = User::first()->id;
|
||||
$this->noUsers = [
|
||||
route('users.index') => 403,
|
||||
route('users.create') => 403,
|
||||
route('users.edit', $this->userId) => 403,
|
||||
route('users.show', $this->userId) => 403,
|
||||
'users.view' => false,
|
||||
'users.create' => false,
|
||||
'users.edit' => false,
|
||||
'users.delete' => false,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
}
|
||||
private $noHardware;
|
||||
private $noLicenses;
|
||||
private $noAccessories;
|
||||
|
@ -77,24 +67,16 @@ class PermissionsTest extends TestCase
|
|||
private $noComponents;
|
||||
private $noUsers;
|
||||
|
||||
// An existing id for each type;
|
||||
private $hardwareId;
|
||||
private $licenseId;
|
||||
private $accessoryId;
|
||||
private $consumableId;
|
||||
private $componentId;
|
||||
private $userId;
|
||||
// tests
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_no_permissions_sees_nothing()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->create();
|
||||
$u = factory(App\Models\User::class)->create();
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
// $permissions = $this->noHardware;
|
||||
$this->hitRoutes($permissions, $u);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,14 +84,14 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_asset_permissions_can_view_assets()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-assets')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-assets')->create();
|
||||
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('hardware.index') => 200,
|
||||
route('hardware.create') => 403,
|
||||
route('hardware.edit', $this->hardwareId) => 403,
|
||||
route('hardware.show', $this->hardwareId) => 200,
|
||||
'assets.view' => true,
|
||||
'assets.create' => false,
|
||||
'assets.edit' => false,
|
||||
'assets.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -119,14 +101,14 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_asset_permissions_can_create_assets()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-assets')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-assets')->create();
|
||||
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('hardware.index') => 403,
|
||||
route('hardware.create') => 200,
|
||||
route('hardware.edit', $this->hardwareId) => 403,
|
||||
route('hardware.show', $this->hardwareId) => 403,
|
||||
'assets.view' => false,
|
||||
'assets.create' => true,
|
||||
'assets.edit' => false,
|
||||
'assets.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -136,15 +118,31 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_assets_permissions_can_edit_assets()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-assets')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-assets')->create();
|
||||
|
||||
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('hardware.index') => 403,
|
||||
route('hardware.create') => 403,
|
||||
route('hardware.edit', $this->hardwareId) => 200,
|
||||
route('hardware.show', $this->hardwareId) => 403,
|
||||
'assets.view' => false,
|
||||
'assets.create' => false,
|
||||
'assets.edit' => true,
|
||||
'assets.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_assets_permissions_can_delete_assets()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-assets')->create();
|
||||
$permissions = $this->noLicenses + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
$permissions = array_merge($permissions, [
|
||||
'assets.view' => false,
|
||||
'assets.create' => false,
|
||||
'assets.edit' => false,
|
||||
'assets.delete' => true,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -154,14 +152,14 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_licenses_permissions_can_view_licenses()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-licenses')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-licenses')->create();
|
||||
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('licenses.index') => 200,
|
||||
route('licenses.create') => 403,
|
||||
route('licenses.edit', $this->licenseId) => 403,
|
||||
route('licenses.show', $this->licenseId) => 200,
|
||||
'licenses.view' => true,
|
||||
'licenses.create' => false,
|
||||
'licenses.edit' => false,
|
||||
'licenses.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -171,14 +169,14 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_licenses_permissions_can_create_licenses()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-licenses')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-licenses')->create();
|
||||
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('licenses.index') => 403,
|
||||
route('licenses.create') => 200,
|
||||
route('licenses.edit', $this->licenseId) => 403,
|
||||
route('licenses.show', $this->licenseId) => 403,
|
||||
'licenses.view' => false,
|
||||
'licenses.create' => true,
|
||||
'licenses.edit' => false,
|
||||
'licenses.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -188,14 +186,31 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_licenses_permissions_can_edit_licenses()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-licenses')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-licenses')->create();
|
||||
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('licenses.index') => 403,
|
||||
route('licenses.create') => 403,
|
||||
route('licenses.edit', $this->licenseId) => 200,
|
||||
route('licenses.show', $this->licenseId) => 403,
|
||||
'licenses.view' => false,
|
||||
'licenses.create' => false,
|
||||
'licenses.edit' => true,
|
||||
'licenses.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_licenses_permissions_can_delete_licenses()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-licenses')->create();
|
||||
$permissions = $this->noHardware + $this->noAccessories + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
'licenses.view' => false,
|
||||
'licenses.create' => false,
|
||||
'licenses.edit' => false,
|
||||
'licenses.delete' => true,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -205,15 +220,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_accessories_permissions_can_view_accessories()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-accessories')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-accessories')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('accessories.index') => 200,
|
||||
route('accessories.create') => 403,
|
||||
route('accessories.edit', $this->accessoryId) => 403,
|
||||
route('accessories.show', $this->accessoryId) => 200,
|
||||
'accessories.view' => true,
|
||||
'accessories.create' => false,
|
||||
'accessories.edit' => false,
|
||||
'accessories.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -223,15 +238,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_accessories_permissions_can_create_accessories()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-accessories')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-accessories')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('accessories.index') => 403,
|
||||
route('accessories.create') => 200,
|
||||
route('accessories.edit', $this->accessoryId) => 403,
|
||||
route('accessories.show', $this->accessoryId) => 403,
|
||||
'accessories.view' => false,
|
||||
'accessories.create' => true,
|
||||
'accessories.edit' => false,
|
||||
'accessories.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -241,15 +256,33 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_accessories_permissions_can_edit_accessories()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-accessories')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-accessories')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('accessories.index') => 403,
|
||||
route('accessories.create') => 403,
|
||||
route('accessories.edit', $this->accessoryId) => 200,
|
||||
route('accessories.show', $this->accessoryId) => 403,
|
||||
'accessories.view' => false,
|
||||
'accessories.create' => false,
|
||||
'accessories.edit' => true,
|
||||
'accessories.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_accessories_permissions_can_delete_accessories()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-accessories')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
'accessories.view' => false,
|
||||
'accessories.create' => false,
|
||||
'accessories.edit' => false,
|
||||
'accessories.delete' => true,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -259,15 +292,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_consumables_permissions_can_view_consumables()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-consumables')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-consumables')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('consumables.index') => 200,
|
||||
route('consumables.create') => 403,
|
||||
route('consumables.edit', $this->consumableId) => 403,
|
||||
route('consumables.show', $this->consumableId) => 200,
|
||||
'consumables.view' => true,
|
||||
'consumables.create' => false,
|
||||
'consumables.edit' => false,
|
||||
'consumables.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -277,15 +310,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_consumables_permissions_can_create_consumables()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-consumables')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-consumables')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noConsumables + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('consumables.index') => 403,
|
||||
route('consumables.create') => 200,
|
||||
route('consumables.edit', $this->consumableId) => 403,
|
||||
route('consumables.show', $this->consumableId) => 403,
|
||||
'consumables.view' => false,
|
||||
'consumables.create' => true,
|
||||
'consumables.edit' => false,
|
||||
'consumables.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -295,15 +328,33 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_consumables_permissions_can_edit_consumables()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-consumables')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-consumables')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('consumables.index') => 403,
|
||||
route('consumables.create') => 403,
|
||||
route('consumables.edit', $this->consumableId) => 200,
|
||||
route('consumables.show', $this->consumableId) => 403,
|
||||
'consumables.view' => false,
|
||||
'consumables.create' => false,
|
||||
'consumables.edit' => true,
|
||||
'consumables.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_consumables_permissions_can_delete_consumables()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-consumables')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories + $this->noComponents + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
'consumables.view' => false,
|
||||
'consumables.create' => false,
|
||||
'consumables.edit' => false,
|
||||
'consumables.delete' => true,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -313,15 +364,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_users_permissions_can_view_users()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-users')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-users')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noComponents;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('users.index') => 200,
|
||||
route('users.create') => 403,
|
||||
route('users.edit', $this->userId) => 403,
|
||||
route('users.show', $this->userId) => 200,
|
||||
'users.view' => true,
|
||||
'users.create' => false,
|
||||
'users.edit' => false,
|
||||
'users.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -331,15 +382,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_users_permissions_can_create_users()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-users')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-users')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noComponents;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('users.index') => 403,
|
||||
route('users.create') => 200,
|
||||
route('users.edit', $this->userId) => 403,
|
||||
route('users.show', $this->userId) => 403,
|
||||
'users.view' => false,
|
||||
'users.create' => true,
|
||||
'users.edit' => false,
|
||||
'users.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -349,15 +400,33 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_users_permissions_can_edit_users()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-users')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-users')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noComponents;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('users.index') => 403,
|
||||
route('users.create') => 403,
|
||||
route('users.edit', $this->userId) => 200,
|
||||
route('users.show', $this->userId) => 403,
|
||||
'users.view' => false,
|
||||
'users.create' => false,
|
||||
'users.edit' => true,
|
||||
'users.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_users_permissions_can_delete_users()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-users')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noComponents;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
'users.view' => false,
|
||||
'users.create' => false,
|
||||
'users.edit' => false,
|
||||
'users.delete' => true,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -367,15 +436,15 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_view_components_permissions_can_view_components()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('view-components')->create();
|
||||
$u = factory(App\Models\User::class)->states('view-components')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('components.index') => 200,
|
||||
route('components.create') => 403,
|
||||
route('components.edit', $this->componentId) => 403,
|
||||
route('components.show', $this->componentId) => 200,
|
||||
'components.view' => true,
|
||||
'components.create' => false,
|
||||
'components.edit' => false,
|
||||
'components.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -385,14 +454,14 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_create_components_permissions_can_create_components()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('create-components')->create();
|
||||
$u = factory(App\Models\User::class)->states('create-components')->create();
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('components.index') => 403,
|
||||
route('components.create') => 200,
|
||||
route('components.edit', $this->componentId) => 403,
|
||||
route('components.show', $this->componentId) => 403,
|
||||
'components.view' => false,
|
||||
'components.create' => true,
|
||||
'components.edit' => false,
|
||||
'components.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
@ -402,26 +471,42 @@ class PermissionsTest extends TestCase
|
|||
*/
|
||||
public function a_user_with_edit_components_permissions_can_edit_components()
|
||||
{
|
||||
$u = factory(App\Models\User::class, 'valid-user')->states('edit-components')->create();
|
||||
$u = factory(App\Models\User::class)->states('edit-components')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
route('components.index') => 403,
|
||||
route('components.create') => 403,
|
||||
route('components.edit', $this->componentId) => 200,
|
||||
route('components.show', $this->componentId) => 403,
|
||||
'components.view' => false,
|
||||
'components.create' => false,
|
||||
'components.edit' => true,
|
||||
'components.delete' => false,
|
||||
]);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function a_user_with_delete_components_permissions_can_delete_components()
|
||||
{
|
||||
$u = factory(App\Models\User::class)->states('delete-components')->create();
|
||||
|
||||
$permissions = $this->noHardware + $this->noLicenses + $this->noAccessories +$this->noConsumables + $this->noUsers;
|
||||
|
||||
$permissions = array_merge($permissions, [
|
||||
'components.view' => false,
|
||||
'components.create' => false,
|
||||
'components.edit' => false,
|
||||
'components.delete' => true,
|
||||
]);
|
||||
// dd($u);
|
||||
$this->hitRoutes($permissions, $u);
|
||||
}
|
||||
|
||||
private function hitRoutes(array $routes, User $user)
|
||||
{
|
||||
$this->actingAs($user);
|
||||
|
||||
foreach ($routes as $route => $response) {
|
||||
$this->get($route)
|
||||
->assertStatus($response);
|
||||
foreach ($routes as $route => $expectation) {
|
||||
$this->assertEquals($user->hasAccess($route), $expectation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ class SnipeModelTest extends \Codeception\TestCase\Test
|
|||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
public function it_sets_purchase_dates_appropriately()
|
||||
{
|
||||
$c = new SnipeModel;
|
||||
|
|
|
@ -8,112 +8,112 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
class StatuslabelTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testRTDStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'rtd')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('rtd')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testPendingStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'pending')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('pending')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testArchivedStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'archived')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('archived')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testOutForRepairStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'out_for_repair')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('out_for_repair')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testOutForDiagnosticsStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'out_for_diagnostics')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('out_for_diagnostics')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testBrokenStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'broken')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('broken')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
public function testLostStatuslabelAdd()
|
||||
{
|
||||
$statuslabel = factory(Statuslabel::class, 'lost')->make();
|
||||
$values = [
|
||||
$statuslabel = factory(Statuslabel::class)->states('lost')->make();
|
||||
$values = [
|
||||
'name' => $statuslabel->name,
|
||||
'deployable' => $statuslabel->deployable,
|
||||
'pending' => $statuslabel->pending,
|
||||
'archived' => $statuslabel->archived,
|
||||
];
|
||||
];
|
||||
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
Statuslabel::create($values);
|
||||
$this->tester->seeRecord('status_labels', $values);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,14 @@ class SupplierTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testSupplierAdd()
|
||||
{
|
||||
$supplier = factory(Supplier::class, 'supplier')->make();
|
||||
$supplier = factory(Supplier::class)->make();
|
||||
$values = [
|
||||
'name' => $supplier->name,
|
||||
];
|
||||
|
|
|
@ -13,9 +13,14 @@ class UserTest extends \Codeception\TestCase\Test
|
|||
protected $tester;
|
||||
use DatabaseMigrations;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
Artisan::call('migrate');
|
||||
}
|
||||
|
||||
public function testUserAdd()
|
||||
{
|
||||
$user = factory(User::class, 'valid-user')->make();
|
||||
$user = factory(User::class)->make();
|
||||
$values = [
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
|
|
Loading…
Reference in a new issue