Update LicensesController.php (#2948)

* Update LicensesController.php

Should fix #2939.  Cannot test at the moment, so please check :)

* Add delete tests.  Improve test item generation.

* Add relationship here.

* Fix some issues with seeding.
This commit is contained in:
Daniel Meltzer 2016-11-20 21:59:57 -06:00 committed by snipe
parent d8eb68af83
commit ac9fd3b3bb
22 changed files with 587 additions and 332 deletions

View file

@ -396,7 +396,7 @@ class LicensesController extends Controller
return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
}
if (($license->assignedcount()) && ($license->assignedcount() > 0)) {
if ($license->assigned_seats_count > 0) {
// Redirect to the license management page
return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.assoc_users'));

View file

@ -47,6 +47,11 @@ class Manufacturer extends SnipeModel
return $this->hasManyThrough('\App\Models\Asset', '\App\Models\AssetModel', 'manufacturer_id', 'model_id');
}
public function models()
{
return $this->hasMany('\App\Models\AssetModel', 'manufacturer_id');
}
public function licenses()
{
return $this->hasMany('\App\Models\License', 'manufacturer_id');

View file

@ -11,6 +11,11 @@
|
*/
use App\Models\Company;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Supplier;
$factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $faker) {
return [
'name' => $faker->catchPhrase,
@ -22,10 +27,12 @@ $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $
'asset_tag' => $faker->unixTime('now'),
'notes' => $faker->sentence,
'purchase_date' => $faker->dateTime(),
'purchase_cost' => $faker->randomFloat(2),
'order_number' => $faker->numberBetween(1000000,50000000),
'supplier_id' => $faker->numberBetween(1,5),
'requestable' => $faker->numberBetween(0,1),
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
'company_id' => Company::inRandomOrder()->first()->id,
'requestable' => $faker->boolean()
];
});
@ -37,23 +44,31 @@ $factory->defineAs(App\Models\AssetModel::class, 'assetmodel', function (Faker\G
'category_id' => $faker->numberBetween(1,9),
'model_number' => $faker->numberBetween(1000000,50000000),
'eol' => 1,
'notes' => $faker->paragraph(),
'requestable' => $faker->boolean(),
];
});
$factory->defineAs(App\Models\Location::class, 'location', function (Faker\Generator $faker) {
return [
'name' => $faker->city,
'city' => $faker->city,
'state' => $faker->stateAbbr,
'country' => $faker->countryCode,
'currency' => $faker->currencyCode,
];
return [
'name' => $faker->catchPhrase,
'address' => $faker->streetAddress,
'address2' => $faker->secondaryAddress,
'city' => $faker->city,
'state' => $faker->stateAbbr,
'country' => $faker->countryCode,
'currency' => $faker->currencyCode,
'zip' => $faker->postcode
];
});
$factory->defineAs(App\Models\Category::class, 'asset-category', function (Faker\Generator $faker) {
return [
'name' => $faker->text(20),
'category_type' => $faker->randomElement($array = array ('asset')),
'eula_text' => $faker->paragraph(),
'require_acceptance' => $faker->boolean(),
'checkin_email' => $faker->boolean()
];
});
@ -95,9 +110,14 @@ $factory->defineAs(App\Models\Component::class, 'component', function (Faker\Gen
return [
'name' => $faker->text(20),
'category_id' => $faker->numberBetween(21,25),
'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' => \App\Models\Company::inRandomOrder()->first()->id
'company_id' => Company::inRandomOrder()->first()->id
];
});
@ -110,39 +130,52 @@ $factory->defineAs(App\Models\Depreciation::class, 'depreciation', function (Fak
$factory->defineAs(App\Models\Accessory::class, 'accessory', function (Faker\Generator $faker) {
return [
'company_id' => Company::inRandomOrder()->first()->id,
'name' => $faker->text(20),
'category_id' => $faker->numberBetween(11,15),
'qty' => $faker->numberBetween(5, 10),
'manufacturer_id' => Manufacturer::inRandomOrder()->first()->id,
'location_id' => $faker->numberBetween(1,5),
'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),
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
];
});
$factory->defineAs(App\Models\Supplier::class, 'supplier', function (Faker\Generator $faker) {
return [
'name' => $faker->company,
'address' => $faker->streetAddress,
'city' => $faker->city,
'state' => $faker->stateAbbr,
'country' => $faker->countryCode,
'contact' => $faker->name,
'phone' => $faker->phoneNumber,
'email' => $faker->safeEmail,
];
return [
'name' => $faker->company,
'address' => $faker->streetAddress,
'address2' => $faker->secondaryAddress,
'city' => $faker->city,
'state' => $faker->stateAbbr,
'zip' => $faker->postCode,
'country' => $faker->countryCode,
'contact' => $faker->name,
'phone' => $faker->phoneNumber,
'fax' => $faker->phoneNumber,
'email' => $faker->safeEmail,
'url' => $faker->url,
'notes' => $faker->paragraph
];
});
$factory->defineAs(App\Models\Consumable::class, 'consumable', function (Faker\Generator $faker) {
return [
'name' => $faker->text(20),
'company_id' => Company::inRandomOrder()->first()->id,
'category_id' => $faker->numberBetween(16, 20),
'company_id' => $faker->numberBetween(1, 10),
'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),
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
];
});
@ -171,7 +204,7 @@ $factory->defineAs(App\Models\Statuslabel::class, 'pending', function (Faker\Gen
'deployable' => 0,
'pending' => 1,
'archived' => 0,
'notes' => ''
'notes' => $faker->sentence
];
});
@ -246,17 +279,20 @@ $factory->defineAs(App\Models\Statuslabel::class, 'lost', function (Faker\Genera
});
$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,
'purchase_date' => $faker->dateTime(),
'purchase_cost' => $faker->randomFloat(2),
'notes' => $faker->sentence,
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
];
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) {
@ -270,7 +306,7 @@ $factory->defineAs(App\Models\LicenseSeat::class, 'license-seat', function (Fake
});
$factory->defineAs(App\Models\Actionlog::class, 'asset-checkout', function (Faker\Generator $faker) {
$company = \App\Models\Company::has('users')->has('assets')->inRandomOrder()->first();
$company = Company::has('users')->has('assets')->inRandomOrder()->first();
return [
'user_id' => $company->users()->inRandomOrder()->first()->id,
'action_type' => 'checkout',
@ -285,7 +321,7 @@ $factory->defineAs(App\Models\Actionlog::class, 'asset-checkout', function (Fake
});
$factory->defineAs(App\Models\Actionlog::class, 'license-checkout-asset', function (Faker\Generator $faker) {
$company = \App\Models\Company::has('users')->has('licenses')->inRandomOrder()->first();
$company = Company::has('users')->has('licenses')->inRandomOrder()->first();
return [
'user_id' => $company->users()->inRandomOrder()->first()->id,
@ -301,7 +337,7 @@ $factory->defineAs(App\Models\Actionlog::class, 'license-checkout-asset', functi
});
$factory->defineAs(App\Models\Actionlog::class, 'accessory-checkout', function (Faker\Generator $faker) {
$company = \App\Models\Company::has('users')->has('accessories')->inRandomOrder()->first();
$company = Company::has('users')->has('accessories')->inRandomOrder()->first();
return [
'user_id' => $company->users()->inRandomOrder()->first()->id,
'action_type' => 'checkout',
@ -316,7 +352,7 @@ $factory->defineAs(App\Models\Actionlog::class, 'accessory-checkout', function (
});
$factory->defineAs(App\Models\Actionlog::class, 'consumable-checkout', function (Faker\Generator $faker) {
$company = \App\Models\Company::has('users')->has('consumables')->inRandomOrder()->first();
$company = Company::has('users')->has('consumables')->inRandomOrder()->first();
return [
'user_id' => $company->users()->inRandomOrder()->first()->id,
@ -332,7 +368,7 @@ $factory->defineAs(App\Models\Actionlog::class, 'consumable-checkout', function
});
$factory->defineAs(App\Models\Actionlog::class, 'component-checkout', function (Faker\Generator $faker) {
$company = \App\Models\Company::has('users')->has('components')->inRandomOrder()->first();
$company = Company::has('users')->has('components')->inRandomOrder()->first();
return [
'user_id' => $company->users()->inRandomOrder()->first()->id,
@ -357,12 +393,17 @@ $factory->defineAs(App\Models\CustomField::class, 'customfield-ip', function (Fa
$factory->defineAs(App\Models\User::class, 'valid-user', function (Faker\Generator $faker) {
return [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'email' => $faker->safeEmail,
'password' => $faker->password,
'username' => $faker->username,
'company_id' => \App\Models\Company::inRandomOrder()->first()->id
];
return [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'username' => $faker->username,
'password' => $faker->password,
'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
];
});

View file

@ -16,6 +16,8 @@ class DatabaseSeeder extends Seeder
$this->call(CompanySeeder::class);
$this->call(UserSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(LocationSeeder::class);
$this->call(AssetModelSeeder::class);
$this->call(AccessorySeeder::class);
$this->call(AssetSeeder::class);
@ -27,8 +29,6 @@ class DatabaseSeeder extends Seeder
$this->call(LicenseSeeder::class);
$this->call(ActionlogSeeder::class);
$this->call(DepreciationSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(LocationSeeder::class);
$this->call(CustomFieldSeeder::class);
Model::reguard();

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,21 @@
<?php
<?php
use App\Models\Accessory;
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use App\Models\Company;
use App\Models\Component;
use App\Models\Consumable;
use App\Models\Depreciation;
use App\Models\Location;
use App\Models\Manufacturer;
use App\Models\Statuslabel;
use App\Models\Supplier;
use App\Models\User;
/**
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
@ -23,4 +37,117 @@ class FunctionalTester extends \Codeception\Actor
/**
* Define custom actions here
*/
public function getCompanyId()
{
return Company::inRandomOrder()->first()->id;
}
public function getCategoryId()
{
return Category::inRandomOrder()->first()->id;
}
public function getManufacturerId()
{
return Manufacturer::inRandomOrder()->first()->id;
}
public function getLocationId()
{
return Location::inRandomOrder()->first()->id;
}
/**
* @return mixed Random Accessory Id
*/
public function getAccessoryId()
{
return Accessory::inRandomOrder()->first()->id;
}
/**
* @return mixed Random Asset Model Id;
*/
public function getModelId()
{
return AssetModel::inRandomOrder()->first()->id;
}
/**
* @return mixed Id of Empty Asset Model
*/
public function getEmptyModelId()
{
return AssetModel::doesntHave('assets')->first()->id;
}
/**
* @return mixed Id of random status
*/
public function getStatusId()
{
return StatusLabel::inRandomOrder()->first()->id;
}
/**
* Id of random user
* @return mixed
*/
public function getUserId()
{
return User::inRandomOrder()->first()->id;
}
/**
* @return mixed Id of random supplier
*/
public function getSupplierId()
{
return Supplier::inRandomOrder()->first()->id;
}
/**
* @return mixed Id of Random Asset
*/
public function getAssetId()
{
return Asset::inRandomOrder()->first()->id;
}
/**
* An Empty category
* @return mixed Id of Empty Category
*/
public function getEmptyCategoryId()
{
return Category::where('category_type', 'asset')->doesntHave('models')->first()->id;
}
/**
* A random component id for testing
* @return mixed Id of random component
*/
public function getComponentId()
{
return Component::inRandomOrder()->first()->id;
}
/**
* A random consumable Id for testing
* @return mixed
*/
public function getConsumableId()
{
return Consumable::inRandomOrder()->first()->id;
}
/**
* Return a random depreciation id for tests.
* @return mixed
*/
public function getDepreciationId()
{
return Depreciation::inRandomOrder()->first()->id;
}
}

View file

@ -11,6 +11,7 @@ modules:
- \Helper\Functional
- Laravel5:
environment_file: .env.tests
cleanup: false
- Db:
dsn: 'mysql:host=localhost;dbname=snipeittests'
user: 'snipeit'

View file

@ -11,10 +11,6 @@ class AccessoriesCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
@ -53,17 +49,18 @@ class AccessoriesCest
public function passesCorrectValidation(FunctionalTester $I)
{
$accessory = factory(App\Models\Accessory::class,'accessory')->make();
$values = [
'company_id' => 3,
'name' => 'TestAccessory',
'category_id' => 40,
'manufacturer_id' => 24,
'location_id' => 38,
'order_number' => '12345',
'company_id' => $accessory->company_id,
'name' => $accessory->name,
'category_id' => $accessory->category_id,
'manufacturer_id' => $accessory->manufacturer_id,
'location_id' => $accessory->location_id,
'order_number' => $accessory->order_number,
'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00',
'qty' => '12',
'min_amt' => '6'
'purchase_cost' => $accessory->purchase_cost,
'qty' => $accessory->qty,
'min_amt' => $accessory->min_amt
];
$I->wantTo("Test Validation Succeeds");
@ -75,4 +72,11 @@ class AccessoriesCest
$I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete an accessory');
$I->amOnPage( route('delete/accessory', $I->getAccessoryId() ) );
$I->seeElement('.alert-success');
}
}

View file

@ -5,22 +5,17 @@ class AssetModelsCest
{
public function _before(FunctionalTester $I)
{
$I->amOnPage('/login');
$I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit');
$I->click('Login');
$I->amOnPage('/login');
$I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit');
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('Test Asset Model Creation');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/hardware/models/create');
$I->amOnPage(route('create/model'));
$I->seeInTitle('Create Asset Model');
$I->see('Create Asset Model', 'h1.pull-left');
}
@ -28,7 +23,7 @@ class AssetModelsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/hardware/models/create');
$I->amOnPage(route('create/model'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -38,18 +33,19 @@ class AssetModelsCest
public function passesCorrectValidation(FunctionalTester $I)
{
$model = factory(App\Models\AssetModel::class, 'assetmodel')->make();
$values = [
'name' => 'TestModel',
'manufacturer_id' => '24',
'category_id' => '40',
'model_number' => '350335',
'eol' => '12',
'notes' => 'lorem ipsum blah blah',
'requestable' => true,
'name' => $model->name,
'manufacturer_id' => $model->manufacturer_id,
'category_id' => $model->category_id,
'model_number' => $model->model_number,
'eol' => $model->eol,
'notes' => $model->notes,
'requestable' => $model->requestable,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/hardware/models/create');
$I->amOnPage(route('create/model'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('models', $values);
@ -57,4 +53,12 @@ class AssetModelsCest
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete an asset model');
// 6 is the only one without an assigned asset. This is fragile.
$I->amOnPage(route('delete/model', $I->getEmptyModelId()));
$I->seeElement('.alert-success');
}
}

View file

@ -5,16 +5,11 @@ class AssetsCest
{
public function _before(FunctionalTester $I)
{
$I->amOnPage('/login');
$I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit');
$I->click('Login');
$I->amOnPage('/login');
$I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit');
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
@ -28,7 +23,7 @@ class AssetsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/hardware/create');
$I->amOnPage(route('create/hardware'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The asset tag field is required.', '.alert-msg');
@ -38,28 +33,36 @@ class AssetsCest
public function passesCreateAndCheckout(FunctionalTester $I)
{
$asset = factory(App\Models\Asset::class,'asset')->make();
$values = [
'company_id' => 3,
'asset_tag' => '230-name-21 2',
'model_id' => 10,
'status_id' => 2,
'assigned_to' => 10,
'serial' => '350335',
'name' => 'TestModel',
'company_id' => $asset->company_id,
'asset_tag' => $asset->asset_tag,
'model_id' => $asset->model_id,
'status_id' => $asset->status_id,
'assigned_to' => $I->getUserId(),
'serial' => $asset->serial,
'name' => $asset->name,
'purchase_date' => '2016-01-01',
'supplier_id' => 12,
'order_number' => '12345',
'purchase_cost' => '25.00',
'warranty_months' => '15',
'notes' => 'lorem ipsum blah blah',
'rtd_location_id' => 38,
'requestable' => true,
'supplier_id' => $asset->supplier_id,
'order_number' => $asset->order_number,
'purchase_cost' => $asset->purchase_cost,
'warranty_months' => $asset->warranty_months,
'notes' => $asset->notes,
'rtd_location_id' => $asset->rtd_location_id,
'requestable' => $asset->requestable,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/hardware/create');
$I->amOnPage(route('create/hardware'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('assets', $values);
$I->dontSeeElement('.alert-danger'); // We should check for success, but we can't because of the stupid ajaxy way I did things. FIXME when the asset form is rewritten.
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete an asset');
$I->amOnPage(route('delete/hardware', $I->getAssetId()));
$I->seeElement('.alert-success');
}
}

View file

@ -20,7 +20,7 @@ class CategoryCest
{
$I->wantTo('Test Category Creation');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/categories/create');
$I->amOnPage(route('create/category'));
$I->seeInTitle('Create Category');
$I->see('Create Category', 'h1.pull-left');
}
@ -28,7 +28,7 @@ class CategoryCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/categories/create');
$I->amOnPage(route('create/category'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -37,18 +37,25 @@ class CategoryCest
public function passesCorrectValidation(FunctionalTester $I)
{
$category = factory(App\Models\Category::class, 'asset-category')->make();
$values = [
'name' => 'TestModel',
'category_type' => 'accessory',
'eula_text' => 'lorem ipsum blah blah',
'require_acceptance' => true,
'checkin_email' => true,
'name' => $category->name,
'category_type' => $category->category_type,
'eula_text' => $category->eula_text,
'require_acceptance' => $category->require_acceptance,
'checkin_email' => $category->checkin_email,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/categories/create');
$I->amOnPage(route('create/category'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('categories', $values);
$I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a category');
$I->amOnPage(route('delete/category', $I->getEmptyCategoryId()));
$I->seeElement('.alert-success');
}
}

View file

@ -11,16 +11,12 @@ class CompaniesCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('Test Company Creation');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/companies/create');
$I->amOnPage(route('create/company'));
$I->seeInTitle('Create Company');
$I->see('Create Company', 'h1.pull-left');
}
@ -28,7 +24,7 @@ class CompaniesCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/companies/create');
$I->amOnPage(route('create/company'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -36,11 +32,12 @@ class CompaniesCest
public function passesCorrectValidation(FunctionalTester $I)
{
$company = factory(App\Models\Company::class, 'company')->make();
$values = [
'name' => 'TestCompany'
'name' => $company->name
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/companies/create');
$I->amOnPage(route('create/company'));
$I->fillField('name', 'TestCompany');
$I->submitForm('form#create-form', $values);
$I->seeRecord('companies', $values);

View file

@ -11,16 +11,12 @@ class ComponentsCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create components form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/components/create');
$I->amOnPage(route('create/component'));
$I->dontSee('Create Component', '.page-header');
$I->see('Create Component', 'h1.pull-left');
}
@ -28,7 +24,7 @@ class ComponentsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/components/create');
$I->amOnPage(route('create/component'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class ComponentsCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/components/create');
$I->amOnPage(route('create/component'));
$I->fillField('name', 't2');
$I->fillField('qty', '-15');
$I->fillField('min_amt', '-15');
@ -51,24 +47,31 @@ class ComponentsCest
public function passesCorrectValidation(FunctionalTester $I)
{
$component = factory(App\Models\Component::class, 'component')->make();
$values = [
'name' => 'TestComponent',
'category_id' => 41,
'location_id' => '38',
'qty' => '12',
'min_amt' => '6',
'serial' => '3062436032621632326-325632523',
'company_id' => 3,
'order_number' => '12345',
'name' => $component->name,
'category_id' => $component->category_id,
'location_id' => $component->location_id,
'qty' => $component->qty,
'min_amt' => $component->min_amt,
'serial' => $component->serial,
'company_id' => $component->company_id,
'order_number' => $component->order_number,
'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00',
'purchase_cost' => $component->purchase_cost,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/components/create');
$I->amOnPage(route('create/component'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('components', $values);
$I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a component');
$I->amOnPage(route('delete/component', $I->getComponentId()));
$I->seeElement('.alert-success');
}
}

View file

@ -11,16 +11,12 @@ class ConsumablesCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create consumables form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/consumables/create');
$I->amOnPage(route('create/consumable'));
$I->dontSee('Create Consumable', '.page-header');
$I->see('Create Consumable', 'h1.pull-left');
}
@ -28,7 +24,7 @@ class ConsumablesCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/consumables/create');
$I->amOnPage(route('create/consumable'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class ConsumablesCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/consumables/create');
$I->amOnPage(route('create/consumable'));
$I->fillField('name', 't2');
$I->fillField('qty', '-15');
$I->fillField('min_amt', '-15');
@ -52,22 +48,30 @@ class ConsumablesCest
public function passesCorrectValidation(FunctionalTester $I)
{
$consumable = factory(App\Models\Consumable::class, 'consumable')->make();
$values = [
'company_id' => 3,
'name' => 'TestConsumable',
'category_id' => 43,
'model_number' => '032-356',
'item_no' => '32503',
'order_number' => '12345',
'company_id' => $consumable->company_id,
'name' => $consumable->name,
'category_id' => $consumable->category_id,
'model_number' => $consumable->model_number,
'item_no' => $consumable->item_no,
'order_number' => $consumable->order_number,
'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00',
'qty' => '12',
'min_amt' => '6',
'purchase_cost' => $consumable->purchase_cost,
'qty' => $consumable->qty,
'min_amt' => $consumable->min_amt,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/consumables/create');
$I->amOnPage(route('create/consumable'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('consumables', $values);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a consumable');
$I->amOnPage(route('delete/consumable', $I->getConsumableId()));
$I->seeElement('.alert-success');
}
}

View file

@ -11,16 +11,12 @@ class DepreciationCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('Test Depreciation Creation');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/depreciations/create');
$I->amOnPage(route('create/depreciations'));
$I->seeInTitle('Create Depreciation');
$I->dontSee('Create Depreciation', '.page-header');
$I->see('Create Depreciation', 'h1.pull-left');
@ -29,7 +25,7 @@ class DepreciationCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/depreciations/create');
$I->amOnPage(route('create/depreciations'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class DepreciationCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/depreciations/create');
$I->amOnPage(route('create/depreciations'));
$I->fillField('name', 't2');
$I->click('Save');
$I->seeElement('.alert-danger');
@ -48,14 +44,22 @@ class DepreciationCest
public function passesCorrectValidation(FunctionalTester $I)
{
$depreciation = factory(App\Models\Depreciation::class, 'depreciation')->make();
$values = [
'name' => 'TestDepreciation',
'months' => '15'
'name' => $depreciation->name,
'months' => $depreciation->months
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/depreciations/create');
$I->amOnPage(route('create/depreciations'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('depreciations', $values);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a depreciation');
$I->amOnPage(route('delete/depreciations', $I->getDepreciationId()));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\Group;
class GroupsCest
{
public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class GroupsCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create groups form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/groups/create');
$I->amOnPage(route('create/group'));
$I->dontSee('Create New Group', '.page-header');
$I->see('Create New Group', 'h1.pull-left');
}
@ -28,7 +26,7 @@ class GroupsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/groups/create');
$I->amOnPage(route('create/group'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class GroupsCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/groups/create');
$I->amOnPage(route('create/group'));
$I->fillField('name', 't2');
$I->click('Save');
$I->seeElement('.alert-danger');
@ -47,11 +45,18 @@ class GroupsCest
public function passesCorrectValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/groups/create');
$I->amOnPage(route('create/group'));
$I->fillField('name', 'TestGroup');
$I->click('Save');
$I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a group');
$I->amOnPage(route('delete/group', Group::doesntHave('users')->first()->id));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\License;
class licensesCest
{
public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class licensesCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create licenses form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/licenses/create');
$I->amOnPage(route('create/licenses'));
$I->dontSee('Create License', '.page-header');
$I->see('Create License', 'h1.pull-left');
}
@ -28,7 +26,7 @@ class licensesCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/licenses/create');
$I->amOnPage(route('create/licenses'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -39,7 +37,7 @@ class licensesCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/licenses/create');
$I->amOnPage(route('create/licenses'));
$I->fillField('name', 't2');
$I->fillField('serial', '13a-');
$I->fillField('seats', '-15');
@ -52,32 +50,40 @@ class licensesCest
public function passesCorrectValidation(FunctionalTester $I)
{
$license = factory(App\Models\License::class, 'license')->make();
$values = [
'name' => 'Test Software',
'serial' => '946346-436346-346436',
'seats' => '12',
'company_id' => 3,
'manufacturer_id' => 24,
'license_name' => 'Marco Polo',
'license_email' => 'g@m.com',
'name' => $license->name,
'serial' => $license->serial,
'seats' => $license->seats,
'company_id' => $license->company_id,
'manufacturer_id' => $license->manufacturer_id,
'license_name' => $license->license_name,
'license_email' => $license->license_email,
'reassignable' => true,
'supplier_id' => 11,
'order_number' => '12345',
'purchase_cost' => '25.00',
'supplier_id' => $license->supplier_id,
'order_number' => $license->order_number,
'purchase_cost' => $license->purchase_cost,
'purchase_date' => '2016-01-01',
'expiration_date' => '2018-01-01',
'termination_date' => '2020-01-01',
'purchase_order' => '234562',
'purchase_order' => $license->purchase_order,
'maintained' => true,
'notes' => 'lorem ipsum omicron delta phi'
'notes' => $license->notes
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/licenses/create');
$I->amOnPage(route('create/licenses'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('licenses', $values);
$I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a license');
$I->amOnPage(route('delete/license', License::doesntHave('assignedUsers')->first()->id));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\Location;
class LocationsCest
{
public function _before(FunctionalTester $I)
@ -12,17 +14,13 @@ class LocationsCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
/* Create Form */
$I->wantTo('Test Location Creation');
$I->lookForwardTo('Finding no Failures');
$I->amOnPage('/admin/settings/locations/create');
$I->amOnPage(route('create/location'));
$I->dontSee('Create Location', '.page-header');
$I->see('Create Location', 'h1.pull-left');
}
@ -30,7 +28,7 @@ class LocationsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/locations/create');
$I->amOnPage(route('create/location'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -39,7 +37,7 @@ class LocationsCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short values");
$I->amOnPage('/admin/settings/locations/create');
$I->amOnPage(route('create/location'));
$I->fillField('name', 't2');
$I->fillField('address', 't2da');
$I->fillField('city', 't2');
@ -54,21 +52,29 @@ class LocationsCest
}
public function passesCorrectValidation(FunctionalTester $I)
{
$location = factory(App\Models\Location::class, 'location')->make();
$values = [
'name' => 'Test Location',
'parent_id' => 26,
'currency' => 'YEN',
'address' => '046t46 South Street',
'address2' => 'Apt 356',
'city' => 'Sutherland',
'state' => 'BV',
'country' => 'AF',
'zip' => '30266',
'name' => $location->name,
'parent_id' => $I->getLocationId(),
'currency' => $location->currency,
'address' => $location->address,
'address2' => $location->address2,
'city' => $location->city,
'state' => $location->state,
'country' => $location->country,
'zip' => $location->zip,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/locations/create');
$I->amOnPage(route('create/location'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('locations', $values);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a location');
$I->amOnPage(route('delete/location', Location::doesntHave('assets')->doesntHave('assignedAssets')->first()->id));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\Manufacturer;
class ManufacturersCest
{
public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class ManufacturersCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('Test Manufacturer Creation');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/manufacturers/create');
$I->amOnPage(route('create/manufacturer'));
$I->seeInTitle('Create Manufacturer');
$I->see('Create Manufacturer', 'h1.pull-left');
}
@ -28,7 +26,7 @@ class ManufacturersCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/manufacturers/create');
$I->amOnPage(route('create/manufacturer'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class ManufacturersCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/manufacturers/create');
$I->amOnPage(route('create/manufacturer'));
$I->fillField('name', 't');
$I->click('Save');
$I->seeElement('.alert-danger');
@ -45,13 +43,25 @@ class ManufacturersCest
}
public function passesCorrectValidation(FunctionalTester $I)
{
$manufacturer = factory(App\Models\Manufacturer::class, 'manufacturer')->make();
$values = [
'name' => 'Testufacturer'
'name' => $manufacturer->name
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/manufacturers/create');
$I->amOnPage(route('create/manufacturer'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('manufacturers', $values);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a manufacturer');
$I->amOnPage(route('delete/manufacturer', Manufacturer::doesntHave('models')
->doesntHave('accessories')
->doesntHave('consumables')
->doesntHave('licenses')->first()->id
));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\Statuslabel;
class StatusLabelsCest
{
public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class StatusLabelsCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create statuslabels form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/statuslabels/create');
$I->amOnPage(route('create/statuslabel'));
$I->dontSee('Create Status Label', '.page-header');
$I->see('Create Status Label', 'h1.pull-left');
}
@ -28,7 +26,7 @@ class StatusLabelsCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/statuslabels/create');
$I->amOnPage(route('create/statuslabel'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -36,27 +34,35 @@ class StatusLabelsCest
public function passesCorrectValidation(FunctionalTester $I)
{
$status = factory(App\Models\Statuslabel::class, 'pending')->make();
$submitValues = [
'name' => 'Test Status',
'name' => 'Testing Status',
'statuslabel_types' => 'pending',
'color' => '#b46262',
'notes' => 'lorem ipsum something else',
'notes' => $status->notes,
'show_in_nav' => true,
];
$recordValues = [
'name' => 'Test Status',
'pending' => 1,
'deployable' => 0,
'archived' => 0,
'name' => 'Testing Status',
'pending' => $status->pending,
'deployable' => $status->archived,
'archived' => $status->deployable,
'color' => '#b46262',
'notes' => 'lorem ipsum something else',
'notes' => $status->notes,
'show_in_nav' => true,
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/statuslabels/create');
$I->amOnPage(route('create/statuslabel'));
$I->submitForm('form#create-form', $submitValues);
$I->seeRecord('status_labels', $recordValues);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a Status Label');
$I->amOnPage(route('delete/statuslabel', Statuslabel::doesntHave('assets')->first()->id));
$I->seeElement('.alert-success');
}
}

View file

@ -1,6 +1,8 @@
<?php
use App\Models\Supplier;
class SuppliersCest
{
public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class SuppliersCest
$I->click('Login');
}
public function _after(FunctionalTester $I)
{
}
// tests
public function tryToTest(FunctionalTester $I)
{
$I->wantTo('ensure that the create settings/suppliers form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/suppliers/create');
$I->amOnPage(route('create/supplier'));
$I->dontSee('Create Supplier', '.page-header');
$I->see('Create Supplier', 'h1.pull-left');
}
@ -28,7 +26,7 @@ class SuppliersCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/suppliers/create');
$I->amOnPage(route('create/supplier'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class SuppliersCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/suppliers/create');
$I->amOnPage(route('create/supplier'));
$I->fillField('name', 't2');
$I->click('Save');
$I->seeElement('.alert-danger');
@ -45,25 +43,33 @@ class SuppliersCest
}
public function passesCorrectValidation(FunctionalTester $I)
{
$supplier = factory(App\Models\Supplier::class, 'supplier')->make();
$values = [
'name' => 'Test Supplier',
'address' => '046t46 South Street',
'address2' => 'Apt 356',
'city' => 'Sutherland',
'state' => 'BV',
'country' => 'AF',
'zip' => '30266',
'contact' => 'Mr. Smith',
'phone' => '032626236 x35',
'fax' => '342 33 6647 3555',
'email' => 'p@roar.com',
'url' => 'http://snipeitapp.com',
'notes' => 'lorem ipsum indigo something'
'name' => $supplier->name,
'address' => $supplier->address,
'address2' => $supplier->address2,
'city' => $supplier->city,
'state' => $supplier->state,
'country' => $supplier->country,
'zip' => $supplier->zip,
'contact' => $supplier->contact,
'phone' => $supplier->phone,
'fax' => $supplier->fax,
'email' => $supplier->email,
'url' => $supplier->url,
'notes' => $supplier->notes
];
$I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/suppliers/create');
$I->amOnPage(route('create/supplier'));
$I->submitForm('form#create-form', $values);
$I->seeRecord('suppliers', $values);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a supplier');
$I->amOnPage(route('delete/supplier', Supplier::doesntHave('assets')->doesntHave('licenses')->first()->id));
$I->seeElement('.alert-success');
}
}

View file

@ -1,5 +1,7 @@
<?php
use App\Models\User;
class UsersCest
{
public function _before(\FunctionalTester $I)
@ -9,17 +11,12 @@ class UsersCest
$I->fillField('password', 'snipeit');
$I->click('Login');
}
public function _after(\FunctionalTester $I)
{
}
// tests
public function tryToTest(\FunctionalTester $I)
{
$I->wantTo('ensure that the create users form loads without errors');
$I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/users/create');
$I->amOnPage(route('create/user'));
$I->dontSee('Create User', '.page-header');
$I->see('Create User', 'h1.pull-left');
}
@ -27,7 +24,7 @@ class UsersCest
public function failsEmptyValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/users/create');
$I->amOnPage(route('create/user'));
$I->click('Save');
$I->seeElement('.alert-danger');
$I->see('The first name field is required.', '.alert-msg');
@ -38,7 +35,7 @@ class UsersCest
public function failsShortValidation(FunctionalTester $I)
{
$I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/users/create');
$I->amOnPage(route('create/user'));
$I->fillField('first_name', 't2');
$I->fillField('last_name', 't2');
$I->fillField('username', 'a'); // Must be 2 chars
@ -52,42 +49,56 @@ class UsersCest
}
public function passesCorrectValidation(FunctionalTester $I)
{
$user = factory(App\Models\User::class, 'valid-user')->make();
$submitValues = [
'first_name' => 'John',
'last_name' => 'Smdt',
'username' => 'jsmdt',
'password' => 'Sutherland',
'password_confirm' => 'Sutherland',
'email' => 'g@roar.com',
'company_id' => 3,
'locale' => 'en-GB',
'employee_num' => '1636 636',
'jobtitle' => 'Robot',
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'username' => $user->username,
'password' => $user->password,
'password_confirm' => $user->password,
'email' => $user->email,
'company_id' => $user->company_id,
'locale' => $user->locale,
'employee_num' => $user->employee_num,
'jobtitle' => $user->jobtitle,
'manager_id' => 19,
'location_id' => 67,
'phone' => '35235 33535 x5',
'phone' => $user->phone,
'activated' => true,
'notes' => 'lorem ipsum indigo something'
'notes' => $user->notes
];
$storedValues = [
'first_name' => 'John',
'last_name' => 'Smdt',
'username' => 'jsmdt',
'email' => 'g@roar.com',
'company_id' => 3,
'locale' => 'en-GB',
'employee_num' => '1636 636',
'jobtitle' => 'Robot',
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'username' => $user->username,
'email' => $user->email,
'company_id' => $user->company_id,
'locale' => $user->locale,
'employee_num' => $user->employee_num,
'jobtitle' => $user->jobtitle,
'manager_id' => 19,
'location_id' => 67,
'phone' => '35235 33535 x5',
'phone' => $user->phone,
'activated' => true,
'notes' => 'lorem ipsum indigo something'
'notes' => $user->notes
];
$I->amOnPage('/admin/users/create');
$I->amOnPage(route('create/user'));
$I->wantTo("Test Validation Succeeds");
$I->submitForm('form#userForm', $submitValues);
$I->seeRecord('users', $storedValues);
$I->seeElement('.alert-success');
}
public function allowsDelete(FunctionalTester $I)
{
$I->wantTo('Ensure I can delete a user');
$I->amOnPage(route('delete/user', User::doesntHave('assets')
->doesntHave('accessories')
->doesntHave('consumables')
->doesntHave('licenses')
->where('username', '!=', 'snipeit')
->first()->id
));
$I->seeElement('.alert-success');
}
}