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')); 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 // Redirect to the license management page
return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.assoc_users')); 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'); 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() public function licenses()
{ {
return $this->hasMany('\App\Models\License', 'manufacturer_id'); 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) { $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->catchPhrase, 'name' => $faker->catchPhrase,
@ -22,10 +27,12 @@ $factory->defineAs(App\Models\Asset::class, 'asset', function (Faker\Generator $
'asset_tag' => $faker->unixTime('now'), 'asset_tag' => $faker->unixTime('now'),
'notes' => $faker->sentence, 'notes' => $faker->sentence,
'purchase_date' => $faker->dateTime(), 'purchase_date' => $faker->dateTime(),
'purchase_cost' => $faker->randomFloat(2),
'order_number' => $faker->numberBetween(1000000,50000000), 'order_number' => $faker->numberBetween(1000000,50000000),
'supplier_id' => $faker->numberBetween(1,5), 'supplier_id' => $faker->numberBetween(1,5),
'requestable' => $faker->numberBetween(0,1), '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), 'category_id' => $faker->numberBetween(1,9),
'model_number' => $faker->numberBetween(1000000,50000000), 'model_number' => $faker->numberBetween(1000000,50000000),
'eol' => 1, 'eol' => 1,
'notes' => $faker->paragraph(),
'requestable' => $faker->boolean(),
]; ];
}); });
$factory->defineAs(App\Models\Location::class, 'location', function (Faker\Generator $faker) { $factory->defineAs(App\Models\Location::class, 'location', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->city, 'name' => $faker->catchPhrase,
'city' => $faker->city, 'address' => $faker->streetAddress,
'state' => $faker->stateAbbr, 'address2' => $faker->secondaryAddress,
'country' => $faker->countryCode, 'city' => $faker->city,
'currency' => $faker->currencyCode, 'state' => $faker->stateAbbr,
]; 'country' => $faker->countryCode,
'currency' => $faker->currencyCode,
'zip' => $faker->postcode
];
}); });
$factory->defineAs(App\Models\Category::class, 'asset-category', function (Faker\Generator $faker) { $factory->defineAs(App\Models\Category::class, 'asset-category', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->text(20), 'name' => $faker->text(20),
'category_type' => $faker->randomElement($array = array ('asset')), '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 [ return [
'name' => $faker->text(20), 'name' => $faker->text(20),
'category_id' => $faker->numberBetween(21,25), 'category_id' => $faker->numberBetween(21,25),
'location_id' => Location::inRandomOrder()->first()->id,
'serial' => $faker->uuid,
'qty' => $faker->numberBetween(3, 10), '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), '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) { $factory->defineAs(App\Models\Accessory::class, 'accessory', function (Faker\Generator $faker) {
return [ return [
'company_id' => Company::inRandomOrder()->first()->id,
'name' => $faker->text(20), 'name' => $faker->text(20),
'category_id' => $faker->numberBetween(11,15), 'category_id' => $faker->numberBetween(11,15),
'qty' => $faker->numberBetween(5, 10), 'manufacturer_id' => Manufacturer::inRandomOrder()->first()->id,
'location_id' => $faker->numberBetween(1,5), '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), '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) { $factory->defineAs(App\Models\Supplier::class, 'supplier', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->company, 'name' => $faker->company,
'address' => $faker->streetAddress, 'address' => $faker->streetAddress,
'city' => $faker->city, 'address2' => $faker->secondaryAddress,
'state' => $faker->stateAbbr, 'city' => $faker->city,
'country' => $faker->countryCode, 'state' => $faker->stateAbbr,
'contact' => $faker->name, 'zip' => $faker->postCode,
'phone' => $faker->phoneNumber, 'country' => $faker->countryCode,
'email' => $faker->safeEmail, '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) { $factory->defineAs(App\Models\Consumable::class, 'consumable', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->text(20), 'name' => $faker->text(20),
'company_id' => Company::inRandomOrder()->first()->id,
'category_id' => $faker->numberBetween(16, 20), '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), 'qty' => $faker->numberBetween(5, 10),
'min_amt' => $faker->numberBetween($min = 1, $max = 2), '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, 'deployable' => 0,
'pending' => 1, 'pending' => 1,
'archived' => 0, '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) { $factory->defineAs(App\Models\License::class, 'license', function (Faker\Generator $faker) {
return [ return [
'name' => $faker->catchPhrase, 'name' => $faker->catchPhrase,
'serial' => $faker->uuid, 'serial' => $faker->uuid,
'seats' => $faker->numberBetween(1, 10), 'seats' => $faker->numberBetween(1, 10),
'license_email' => $faker->safeEmail, 'license_email' => $faker->safeEmail,
'license_name' => $faker->name, 'license_name' => $faker->name,
'purchase_date' => $faker->dateTime(), 'order_number' => $faker->numberBetween(1500, 13250),
'purchase_cost' => $faker->randomFloat(2), 'purchase_order' => $faker->numberBetween(1500, 13250),
'notes' => $faker->sentence, 'purchase_date' => $faker->dateTime(),
'company_id' => \App\Models\Company::inRandomOrder()->first()->id '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) { $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) { $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 [ return [
'user_id' => $company->users()->inRandomOrder()->first()->id, 'user_id' => $company->users()->inRandomOrder()->first()->id,
'action_type' => 'checkout', '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) { $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 [ return [
'user_id' => $company->users()->inRandomOrder()->first()->id, '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) { $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 [ return [
'user_id' => $company->users()->inRandomOrder()->first()->id, 'user_id' => $company->users()->inRandomOrder()->first()->id,
'action_type' => 'checkout', '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) { $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 [ return [
'user_id' => $company->users()->inRandomOrder()->first()->id, '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) { $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 [ return [
'user_id' => $company->users()->inRandomOrder()->first()->id, '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) { $factory->defineAs(App\Models\User::class, 'valid-user', function (Faker\Generator $faker) {
return [ return [
'first_name' => $faker->firstName, 'first_name' => $faker->firstName,
'last_name' => $faker->lastName, 'last_name' => $faker->lastName,
'email' => $faker->safeEmail, 'username' => $faker->username,
'password' => $faker->password, 'password' => $faker->password,
'username' => $faker->username, 'email' => $faker->safeEmail,
'company_id' => \App\Models\Company::inRandomOrder()->first()->id '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(CompanySeeder::class);
$this->call(UserSeeder::class); $this->call(UserSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(LocationSeeder::class);
$this->call(AssetModelSeeder::class); $this->call(AssetModelSeeder::class);
$this->call(AccessorySeeder::class); $this->call(AccessorySeeder::class);
$this->call(AssetSeeder::class); $this->call(AssetSeeder::class);
@ -27,8 +29,6 @@ class DatabaseSeeder extends Seeder
$this->call(LicenseSeeder::class); $this->call(LicenseSeeder::class);
$this->call(ActionlogSeeder::class); $this->call(ActionlogSeeder::class);
$this->call(DepreciationSeeder::class); $this->call(DepreciationSeeder::class);
$this->call(ManufacturerSeeder::class);
$this->call(LocationSeeder::class);
$this->call(CustomFieldSeeder::class); $this->call(CustomFieldSeeder::class);
Model::reguard(); 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 * Inherited Methods
* @method void wantToTest($text) * @method void wantToTest($text)
* @method void wantTo($text) * @method void wantTo($text)
@ -23,4 +37,117 @@ class FunctionalTester extends \Codeception\Actor
/** /**
* Define custom actions here * 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 - \Helper\Functional
- Laravel5: - Laravel5:
environment_file: .env.tests environment_file: .env.tests
cleanup: false
- Db: - Db:
dsn: 'mysql:host=localhost;dbname=snipeittests' dsn: 'mysql:host=localhost;dbname=snipeittests'
user: 'snipeit' user: 'snipeit'

View file

@ -11,10 +11,6 @@ class AccessoriesCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
@ -53,17 +49,18 @@ class AccessoriesCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$accessory = factory(App\Models\Accessory::class,'accessory')->make();
$values = [ $values = [
'company_id' => 3, 'company_id' => $accessory->company_id,
'name' => 'TestAccessory', 'name' => $accessory->name,
'category_id' => 40, 'category_id' => $accessory->category_id,
'manufacturer_id' => 24, 'manufacturer_id' => $accessory->manufacturer_id,
'location_id' => 38, 'location_id' => $accessory->location_id,
'order_number' => '12345', 'order_number' => $accessory->order_number,
'purchase_date' => '2016-01-01', 'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00', 'purchase_cost' => $accessory->purchase_cost,
'qty' => '12', 'qty' => $accessory->qty,
'min_amt' => '6' 'min_amt' => $accessory->min_amt
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
@ -75,4 +72,11 @@ class AccessoriesCest
$I->dontSee('&lt;span class=&quot;'); $I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success'); $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) public function _before(FunctionalTester $I)
{ {
$I->amOnPage('/login'); $I->amOnPage('/login');
$I->fillField('username', 'snipeit'); $I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit'); $I->fillField('password', 'snipeit');
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('Test Asset Model Creation'); $I->wantTo('Test Asset Model Creation');
$I->lookForwardTo('seeing it load without errors'); $I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/hardware/models/create'); $I->amOnPage(route('create/model'));
$I->seeInTitle('Create Asset Model'); $I->seeInTitle('Create Asset Model');
$I->see('Create Asset Model', 'h1.pull-left'); $I->see('Create Asset Model', 'h1.pull-left');
} }
@ -28,7 +23,7 @@ class AssetModelsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/hardware/models/create'); $I->amOnPage(route('create/model'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -38,18 +33,19 @@ class AssetModelsCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$model = factory(App\Models\AssetModel::class, 'assetmodel')->make();
$values = [ $values = [
'name' => 'TestModel', 'name' => $model->name,
'manufacturer_id' => '24', 'manufacturer_id' => $model->manufacturer_id,
'category_id' => '40', 'category_id' => $model->category_id,
'model_number' => '350335', 'model_number' => $model->model_number,
'eol' => '12', 'eol' => $model->eol,
'notes' => 'lorem ipsum blah blah', 'notes' => $model->notes,
'requestable' => true, 'requestable' => $model->requestable,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/hardware/models/create'); $I->amOnPage(route('create/model'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('models', $values); $I->seeRecord('models', $values);
@ -57,4 +53,12 @@ class AssetModelsCest
$I->seeElement('.alert-success'); $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) public function _before(FunctionalTester $I)
{ {
$I->amOnPage('/login'); $I->amOnPage('/login');
$I->fillField('username', 'snipeit'); $I->fillField('username', 'snipeit');
$I->fillField('password', 'snipeit'); $I->fillField('password', 'snipeit');
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
@ -28,7 +23,7 @@ class AssetsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/hardware/create'); $I->amOnPage(route('create/hardware'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The asset tag field is required.', '.alert-msg'); $I->see('The asset tag field is required.', '.alert-msg');
@ -38,28 +33,36 @@ class AssetsCest
public function passesCreateAndCheckout(FunctionalTester $I) public function passesCreateAndCheckout(FunctionalTester $I)
{ {
$asset = factory(App\Models\Asset::class,'asset')->make();
$values = [ $values = [
'company_id' => 3, 'company_id' => $asset->company_id,
'asset_tag' => '230-name-21 2', 'asset_tag' => $asset->asset_tag,
'model_id' => 10, 'model_id' => $asset->model_id,
'status_id' => 2, 'status_id' => $asset->status_id,
'assigned_to' => 10, 'assigned_to' => $I->getUserId(),
'serial' => '350335', 'serial' => $asset->serial,
'name' => 'TestModel', 'name' => $asset->name,
'purchase_date' => '2016-01-01', 'purchase_date' => '2016-01-01',
'supplier_id' => 12, 'supplier_id' => $asset->supplier_id,
'order_number' => '12345', 'order_number' => $asset->order_number,
'purchase_cost' => '25.00', 'purchase_cost' => $asset->purchase_cost,
'warranty_months' => '15', 'warranty_months' => $asset->warranty_months,
'notes' => 'lorem ipsum blah blah', 'notes' => $asset->notes,
'rtd_location_id' => 38, 'rtd_location_id' => $asset->rtd_location_id,
'requestable' => true, 'requestable' => $asset->requestable,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/hardware/create'); $I->amOnPage(route('create/hardware'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('assets', $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. $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->wantTo('Test Category Creation');
$I->lookForwardTo('seeing it load without errors'); $I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/categories/create'); $I->amOnPage(route('create/category'));
$I->seeInTitle('Create Category'); $I->seeInTitle('Create Category');
$I->see('Create Category', 'h1.pull-left'); $I->see('Create Category', 'h1.pull-left');
} }
@ -28,7 +28,7 @@ class CategoryCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/categories/create'); $I->amOnPage(route('create/category'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -37,18 +37,25 @@ class CategoryCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$category = factory(App\Models\Category::class, 'asset-category')->make();
$values = [ $values = [
'name' => 'TestModel', 'name' => $category->name,
'category_type' => 'accessory', 'category_type' => $category->category_type,
'eula_text' => 'lorem ipsum blah blah', 'eula_text' => $category->eula_text,
'require_acceptance' => true, 'require_acceptance' => $category->require_acceptance,
'checkin_email' => true, 'checkin_email' => $category->checkin_email,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/categories/create'); $I->amOnPage(route('create/category'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('categories', $values); $I->seeRecord('categories', $values);
$I->dontSee('&lt;span class=&quot;'); $I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success'); $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'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('Test Company Creation'); $I->wantTo('Test Company Creation');
$I->lookForwardTo('seeing it load without errors'); $I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/companies/create'); $I->amOnPage(route('create/company'));
$I->seeInTitle('Create Company'); $I->seeInTitle('Create Company');
$I->see('Create Company', 'h1.pull-left'); $I->see('Create Company', 'h1.pull-left');
} }
@ -28,7 +24,7 @@ class CompaniesCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/companies/create'); $I->amOnPage(route('create/company'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -36,11 +32,12 @@ class CompaniesCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$company = factory(App\Models\Company::class, 'company')->make();
$values = [ $values = [
'name' => 'TestCompany' 'name' => $company->name
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/companies/create'); $I->amOnPage(route('create/company'));
$I->fillField('name', 'TestCompany'); $I->fillField('name', 'TestCompany');
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('companies', $values); $I->seeRecord('companies', $values);

View file

@ -11,16 +11,12 @@ class ComponentsCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create components form loads without errors'); $I->wantTo('ensure that the create components form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create Component', '.page-header');
$I->see('Create Component', 'h1.pull-left'); $I->see('Create Component', 'h1.pull-left');
} }
@ -28,7 +24,7 @@ class ComponentsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/components/create'); $I->amOnPage(route('create/component'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class ComponentsCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/components/create'); $I->amOnPage(route('create/component'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->fillField('qty', '-15'); $I->fillField('qty', '-15');
$I->fillField('min_amt', '-15'); $I->fillField('min_amt', '-15');
@ -51,24 +47,31 @@ class ComponentsCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$component = factory(App\Models\Component::class, 'component')->make();
$values = [ $values = [
'name' => 'TestComponent', 'name' => $component->name,
'category_id' => 41, 'category_id' => $component->category_id,
'location_id' => '38', 'location_id' => $component->location_id,
'qty' => '12', 'qty' => $component->qty,
'min_amt' => '6', 'min_amt' => $component->min_amt,
'serial' => '3062436032621632326-325632523', 'serial' => $component->serial,
'company_id' => 3, 'company_id' => $component->company_id,
'order_number' => '12345', 'order_number' => $component->order_number,
'purchase_date' => '2016-01-01', 'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00', 'purchase_cost' => $component->purchase_cost,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/components/create'); $I->amOnPage(route('create/component'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('components', $values); $I->seeRecord('components', $values);
$I->dontSee('&lt;span class=&quot;'); $I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success'); $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'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create consumables form loads without errors'); $I->wantTo('ensure that the create consumables form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create Consumable', '.page-header');
$I->see('Create Consumable', 'h1.pull-left'); $I->see('Create Consumable', 'h1.pull-left');
} }
@ -28,7 +24,7 @@ class ConsumablesCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/consumables/create'); $I->amOnPage(route('create/consumable'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class ConsumablesCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/consumables/create'); $I->amOnPage(route('create/consumable'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->fillField('qty', '-15'); $I->fillField('qty', '-15');
$I->fillField('min_amt', '-15'); $I->fillField('min_amt', '-15');
@ -52,22 +48,30 @@ class ConsumablesCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$consumable = factory(App\Models\Consumable::class, 'consumable')->make();
$values = [ $values = [
'company_id' => 3, 'company_id' => $consumable->company_id,
'name' => 'TestConsumable', 'name' => $consumable->name,
'category_id' => 43, 'category_id' => $consumable->category_id,
'model_number' => '032-356', 'model_number' => $consumable->model_number,
'item_no' => '32503', 'item_no' => $consumable->item_no,
'order_number' => '12345', 'order_number' => $consumable->order_number,
'purchase_date' => '2016-01-01', 'purchase_date' => '2016-01-01',
'purchase_cost' => '25.00', 'purchase_cost' => $consumable->purchase_cost,
'qty' => '12', 'qty' => $consumable->qty,
'min_amt' => '6', 'min_amt' => $consumable->min_amt,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/consumables/create'); $I->amOnPage(route('create/consumable'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('consumables', $values); $I->seeRecord('consumables', $values);
$I->seeElement('.alert-success'); $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'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('Test Depreciation Creation'); $I->wantTo('Test Depreciation Creation');
$I->lookForwardTo('seeing it load without errors'); $I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/depreciations/create'); $I->amOnPage(route('create/depreciations'));
$I->seeInTitle('Create Depreciation'); $I->seeInTitle('Create Depreciation');
$I->dontSee('Create Depreciation', '.page-header'); $I->dontSee('Create Depreciation', '.page-header');
$I->see('Create Depreciation', 'h1.pull-left'); $I->see('Create Depreciation', 'h1.pull-left');
@ -29,7 +25,7 @@ class DepreciationCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/depreciations/create'); $I->amOnPage(route('create/depreciations'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -39,7 +35,7 @@ class DepreciationCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/depreciations/create'); $I->amOnPage(route('create/depreciations'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
@ -48,14 +44,22 @@ class DepreciationCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$depreciation = factory(App\Models\Depreciation::class, 'depreciation')->make();
$values = [ $values = [
'name' => 'TestDepreciation', 'name' => $depreciation->name,
'months' => '15' 'months' => $depreciation->months
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/depreciations/create'); $I->amOnPage(route('create/depreciations'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('depreciations', $values); $I->seeRecord('depreciations', $values);
$I->seeElement('.alert-success'); $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 <?php
use App\Models\Group;
class GroupsCest class GroupsCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class GroupsCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create groups form loads without errors'); $I->wantTo('ensure that the create groups form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create New Group', '.page-header');
$I->see('Create New Group', 'h1.pull-left'); $I->see('Create New Group', 'h1.pull-left');
} }
@ -28,7 +26,7 @@ class GroupsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/groups/create'); $I->amOnPage(route('create/group'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class GroupsCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/groups/create'); $I->amOnPage(route('create/group'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
@ -47,11 +45,18 @@ class GroupsCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/groups/create'); $I->amOnPage(route('create/group'));
$I->fillField('name', 'TestGroup'); $I->fillField('name', 'TestGroup');
$I->click('Save'); $I->click('Save');
$I->dontSee('&lt;span class=&quot;'); $I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success'); $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 <?php
use App\Models\License;
class licensesCest class licensesCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class licensesCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create licenses form loads without errors'); $I->wantTo('ensure that the create licenses form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create License', '.page-header');
$I->see('Create License', 'h1.pull-left'); $I->see('Create License', 'h1.pull-left');
} }
@ -28,7 +26,7 @@ class licensesCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/licenses/create'); $I->amOnPage(route('create/licenses'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -39,7 +37,7 @@ class licensesCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/licenses/create'); $I->amOnPage(route('create/licenses'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->fillField('serial', '13a-'); $I->fillField('serial', '13a-');
$I->fillField('seats', '-15'); $I->fillField('seats', '-15');
@ -52,32 +50,40 @@ class licensesCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$license = factory(App\Models\License::class, 'license')->make();
$values = [ $values = [
'name' => 'Test Software', 'name' => $license->name,
'serial' => '946346-436346-346436', 'serial' => $license->serial,
'seats' => '12', 'seats' => $license->seats,
'company_id' => 3, 'company_id' => $license->company_id,
'manufacturer_id' => 24, 'manufacturer_id' => $license->manufacturer_id,
'license_name' => 'Marco Polo', 'license_name' => $license->license_name,
'license_email' => 'g@m.com', 'license_email' => $license->license_email,
'reassignable' => true, 'reassignable' => true,
'supplier_id' => 11, 'supplier_id' => $license->supplier_id,
'order_number' => '12345', 'order_number' => $license->order_number,
'purchase_cost' => '25.00', 'purchase_cost' => $license->purchase_cost,
'purchase_date' => '2016-01-01', 'purchase_date' => '2016-01-01',
'expiration_date' => '2018-01-01', 'expiration_date' => '2018-01-01',
'termination_date' => '2020-01-01', 'termination_date' => '2020-01-01',
'purchase_order' => '234562', 'purchase_order' => $license->purchase_order,
'maintained' => true, 'maintained' => true,
'notes' => 'lorem ipsum omicron delta phi' 'notes' => $license->notes
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/licenses/create'); $I->amOnPage(route('create/licenses'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('licenses', $values); $I->seeRecord('licenses', $values);
$I->dontSee('&lt;span class=&quot;'); $I->dontSee('&lt;span class=&quot;');
$I->seeElement('.alert-success'); $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 <?php
use App\Models\Location;
class LocationsCest class LocationsCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -12,17 +14,13 @@ class LocationsCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
/* Create Form */ /* Create Form */
$I->wantTo('Test Location Creation'); $I->wantTo('Test Location Creation');
$I->lookForwardTo('Finding no Failures'); $I->lookForwardTo('Finding no Failures');
$I->amOnPage('/admin/settings/locations/create'); $I->amOnPage(route('create/location'));
$I->dontSee('Create Location', '.page-header'); $I->dontSee('Create Location', '.page-header');
$I->see('Create Location', 'h1.pull-left'); $I->see('Create Location', 'h1.pull-left');
} }
@ -30,7 +28,7 @@ class LocationsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/locations/create'); $I->amOnPage(route('create/location'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -39,7 +37,7 @@ class LocationsCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short values"); $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('name', 't2');
$I->fillField('address', 't2da'); $I->fillField('address', 't2da');
$I->fillField('city', 't2'); $I->fillField('city', 't2');
@ -54,21 +52,29 @@ class LocationsCest
} }
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$location = factory(App\Models\Location::class, 'location')->make();
$values = [ $values = [
'name' => 'Test Location', 'name' => $location->name,
'parent_id' => 26, 'parent_id' => $I->getLocationId(),
'currency' => 'YEN', 'currency' => $location->currency,
'address' => '046t46 South Street', 'address' => $location->address,
'address2' => 'Apt 356', 'address2' => $location->address2,
'city' => 'Sutherland', 'city' => $location->city,
'state' => 'BV', 'state' => $location->state,
'country' => 'AF', 'country' => $location->country,
'zip' => '30266', 'zip' => $location->zip,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/locations/create'); $I->amOnPage(route('create/location'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('locations', $values); $I->seeRecord('locations', $values);
$I->seeElement('.alert-success'); $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 <?php
use App\Models\Manufacturer;
class ManufacturersCest class ManufacturersCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class ManufacturersCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('Test Manufacturer Creation'); $I->wantTo('Test Manufacturer Creation');
$I->lookForwardTo('seeing it load without errors'); $I->lookForwardTo('seeing it load without errors');
$I->amOnPage('/admin/settings/manufacturers/create'); $I->amOnPage(route('create/manufacturer'));
$I->seeInTitle('Create Manufacturer'); $I->seeInTitle('Create Manufacturer');
$I->see('Create Manufacturer', 'h1.pull-left'); $I->see('Create Manufacturer', 'h1.pull-left');
} }
@ -28,7 +26,7 @@ class ManufacturersCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/manufacturers/create'); $I->amOnPage(route('create/manufacturer'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class ManufacturersCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/manufacturers/create'); $I->amOnPage(route('create/manufacturer'));
$I->fillField('name', 't'); $I->fillField('name', 't');
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
@ -45,13 +43,25 @@ class ManufacturersCest
} }
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$manufacturer = factory(App\Models\Manufacturer::class, 'manufacturer')->make();
$values = [ $values = [
'name' => 'Testufacturer' 'name' => $manufacturer->name
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/manufacturers/create'); $I->amOnPage(route('create/manufacturer'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('manufacturers', $values); $I->seeRecord('manufacturers', $values);
$I->seeElement('.alert-success'); $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 <?php
use App\Models\Statuslabel;
class StatusLabelsCest class StatusLabelsCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class StatusLabelsCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create statuslabels form loads without errors'); $I->wantTo('ensure that the create statuslabels form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create Status Label', '.page-header');
$I->see('Create Status Label', 'h1.pull-left'); $I->see('Create Status Label', 'h1.pull-left');
} }
@ -28,7 +26,7 @@ class StatusLabelsCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/statuslabels/create'); $I->amOnPage(route('create/statuslabel'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -36,27 +34,35 @@ class StatusLabelsCest
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$status = factory(App\Models\Statuslabel::class, 'pending')->make();
$submitValues = [ $submitValues = [
'name' => 'Test Status', 'name' => 'Testing Status',
'statuslabel_types' => 'pending', 'statuslabel_types' => 'pending',
'color' => '#b46262', 'color' => '#b46262',
'notes' => 'lorem ipsum something else', 'notes' => $status->notes,
'show_in_nav' => true, 'show_in_nav' => true,
]; ];
$recordValues = [ $recordValues = [
'name' => 'Test Status', 'name' => 'Testing Status',
'pending' => 1, 'pending' => $status->pending,
'deployable' => 0, 'deployable' => $status->archived,
'archived' => 0, 'archived' => $status->deployable,
'color' => '#b46262', 'color' => '#b46262',
'notes' => 'lorem ipsum something else', 'notes' => $status->notes,
'show_in_nav' => true, 'show_in_nav' => true,
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/statuslabels/create'); $I->amOnPage(route('create/statuslabel'));
$I->submitForm('form#create-form', $submitValues); $I->submitForm('form#create-form', $submitValues);
$I->seeRecord('status_labels', $recordValues); $I->seeRecord('status_labels', $recordValues);
$I->seeElement('.alert-success'); $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 <?php
use App\Models\Supplier;
class SuppliersCest class SuppliersCest
{ {
public function _before(FunctionalTester $I) public function _before(FunctionalTester $I)
@ -11,16 +13,12 @@ class SuppliersCest
$I->click('Login'); $I->click('Login');
} }
public function _after(FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(FunctionalTester $I) public function tryToTest(FunctionalTester $I)
{ {
$I->wantTo('ensure that the create settings/suppliers form loads without errors'); $I->wantTo('ensure that the create settings/suppliers form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create Supplier', '.page-header');
$I->see('Create Supplier', 'h1.pull-left'); $I->see('Create Supplier', 'h1.pull-left');
} }
@ -28,7 +26,7 @@ class SuppliersCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/settings/suppliers/create'); $I->amOnPage(route('create/supplier'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The name field is required.', '.alert-msg'); $I->see('The name field is required.', '.alert-msg');
@ -37,7 +35,7 @@ class SuppliersCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $I->wantTo("Test Validation Fails with short name");
$I->amOnPage('/admin/settings/suppliers/create'); $I->amOnPage(route('create/supplier'));
$I->fillField('name', 't2'); $I->fillField('name', 't2');
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
@ -45,25 +43,33 @@ class SuppliersCest
} }
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$supplier = factory(App\Models\Supplier::class, 'supplier')->make();
$values = [ $values = [
'name' => 'Test Supplier', 'name' => $supplier->name,
'address' => '046t46 South Street', 'address' => $supplier->address,
'address2' => 'Apt 356', 'address2' => $supplier->address2,
'city' => 'Sutherland', 'city' => $supplier->city,
'state' => 'BV', 'state' => $supplier->state,
'country' => 'AF', 'country' => $supplier->country,
'zip' => '30266', 'zip' => $supplier->zip,
'contact' => 'Mr. Smith', 'contact' => $supplier->contact,
'phone' => '032626236 x35', 'phone' => $supplier->phone,
'fax' => '342 33 6647 3555', 'fax' => $supplier->fax,
'email' => 'p@roar.com', 'email' => $supplier->email,
'url' => 'http://snipeitapp.com', 'url' => $supplier->url,
'notes' => 'lorem ipsum indigo something' 'notes' => $supplier->notes
]; ];
$I->wantTo("Test Validation Succeeds"); $I->wantTo("Test Validation Succeeds");
$I->amOnPage('/admin/settings/suppliers/create'); $I->amOnPage(route('create/supplier'));
$I->submitForm('form#create-form', $values); $I->submitForm('form#create-form', $values);
$I->seeRecord('suppliers', $values); $I->seeRecord('suppliers', $values);
$I->seeElement('.alert-success'); $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 <?php
use App\Models\User;
class UsersCest class UsersCest
{ {
public function _before(\FunctionalTester $I) public function _before(\FunctionalTester $I)
@ -9,17 +11,12 @@ class UsersCest
$I->fillField('password', 'snipeit'); $I->fillField('password', 'snipeit');
$I->click('Login'); $I->click('Login');
} }
public function _after(\FunctionalTester $I)
{
}
// tests // tests
public function tryToTest(\FunctionalTester $I) public function tryToTest(\FunctionalTester $I)
{ {
$I->wantTo('ensure that the create users form loads without errors'); $I->wantTo('ensure that the create users form loads without errors');
$I->lookForwardTo('seeing it load 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->dontSee('Create User', '.page-header');
$I->see('Create User', 'h1.pull-left'); $I->see('Create User', 'h1.pull-left');
} }
@ -27,7 +24,7 @@ class UsersCest
public function failsEmptyValidation(FunctionalTester $I) public function failsEmptyValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with blank elements"); $I->wantTo("Test Validation Fails with blank elements");
$I->amOnPage('/admin/users/create'); $I->amOnPage(route('create/user'));
$I->click('Save'); $I->click('Save');
$I->seeElement('.alert-danger'); $I->seeElement('.alert-danger');
$I->see('The first name field is required.', '.alert-msg'); $I->see('The first name field is required.', '.alert-msg');
@ -38,7 +35,7 @@ class UsersCest
public function failsShortValidation(FunctionalTester $I) public function failsShortValidation(FunctionalTester $I)
{ {
$I->wantTo("Test Validation Fails with short name"); $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('first_name', 't2');
$I->fillField('last_name', 't2'); $I->fillField('last_name', 't2');
$I->fillField('username', 'a'); // Must be 2 chars $I->fillField('username', 'a'); // Must be 2 chars
@ -52,42 +49,56 @@ class UsersCest
} }
public function passesCorrectValidation(FunctionalTester $I) public function passesCorrectValidation(FunctionalTester $I)
{ {
$user = factory(App\Models\User::class, 'valid-user')->make();
$submitValues = [ $submitValues = [
'first_name' => 'John', 'first_name' => $user->first_name,
'last_name' => 'Smdt', 'last_name' => $user->last_name,
'username' => 'jsmdt', 'username' => $user->username,
'password' => 'Sutherland', 'password' => $user->password,
'password_confirm' => 'Sutherland', 'password_confirm' => $user->password,
'email' => 'g@roar.com', 'email' => $user->email,
'company_id' => 3, 'company_id' => $user->company_id,
'locale' => 'en-GB', 'locale' => $user->locale,
'employee_num' => '1636 636', 'employee_num' => $user->employee_num,
'jobtitle' => 'Robot', 'jobtitle' => $user->jobtitle,
'manager_id' => 19, 'manager_id' => 19,
'location_id' => 67, 'location_id' => 67,
'phone' => '35235 33535 x5', 'phone' => $user->phone,
'activated' => true, 'activated' => true,
'notes' => 'lorem ipsum indigo something' 'notes' => $user->notes
]; ];
$storedValues = [ $storedValues = [
'first_name' => 'John', 'first_name' => $user->first_name,
'last_name' => 'Smdt', 'last_name' => $user->last_name,
'username' => 'jsmdt', 'username' => $user->username,
'email' => 'g@roar.com', 'email' => $user->email,
'company_id' => 3, 'company_id' => $user->company_id,
'locale' => 'en-GB', 'locale' => $user->locale,
'employee_num' => '1636 636', 'employee_num' => $user->employee_num,
'jobtitle' => 'Robot', 'jobtitle' => $user->jobtitle,
'manager_id' => 19, 'manager_id' => 19,
'location_id' => 67, 'location_id' => 67,
'phone' => '35235 33535 x5', 'phone' => $user->phone,
'activated' => true, '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->wantTo("Test Validation Succeeds");
$I->submitForm('form#userForm', $submitValues); $I->submitForm('form#userForm', $submitValues);
$I->seeRecord('users', $storedValues); $I->seeRecord('users', $storedValues);
$I->seeElement('.alert-success'); $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');
}
} }