mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
commit
c34650458f
|
@ -14,9 +14,9 @@ services:
|
||||||
|
|
||||||
# list any PHP version you want to test against
|
# list any PHP version you want to test against
|
||||||
php:
|
php:
|
||||||
- 7.1.8
|
|
||||||
- 7.2
|
- 7.2
|
||||||
- 7.3.0
|
- 7.3.0
|
||||||
|
- 7.4
|
||||||
|
|
||||||
|
|
||||||
# execute any number of scripts before the test run, custom env's are available as variables
|
# execute any number of scripts before the test run, custom env's are available as variables
|
||||||
|
|
|
@ -67,6 +67,7 @@ class LocationsController extends Controller
|
||||||
{
|
{
|
||||||
$this->authorize('create', Location::class);
|
$this->authorize('create', Location::class);
|
||||||
$location = new Location();
|
$location = new Location();
|
||||||
|
$location->id = null; // This is required to make Laravels different validation work, it errors if the parameter doesn't exist (maybe a bug)?
|
||||||
$location->name = $request->input('name');
|
$location->name = $request->input('name');
|
||||||
$location->parent_id = $request->input('parent_id', null);
|
$location->parent_id = $request->input('parent_id', null);
|
||||||
$location->currency = $request->input('currency', '$');
|
$location->currency = $request->input('currency', '$');
|
||||||
|
|
|
@ -23,11 +23,11 @@ class DatabaseSeeder extends Seeder
|
||||||
|
|
||||||
$this->call(CompanySeeder::class);
|
$this->call(CompanySeeder::class);
|
||||||
$this->call(CategorySeeder::class);
|
$this->call(CategorySeeder::class);
|
||||||
|
$this->call(LocationSeeder::class);
|
||||||
$this->call(UserSeeder::class);
|
$this->call(UserSeeder::class);
|
||||||
$this->call(DepreciationSeeder::class);
|
$this->call(DepreciationSeeder::class);
|
||||||
$this->call(DepartmentSeeder::class);
|
$this->call(DepartmentSeeder::class);
|
||||||
$this->call(ManufacturerSeeder::class);
|
$this->call(ManufacturerSeeder::class);
|
||||||
$this->call(LocationSeeder::class);
|
|
||||||
$this->call(SupplierSeeder::class);
|
$this->call(SupplierSeeder::class);
|
||||||
$this->call(AssetModelSeeder::class);
|
$this->call(AssetModelSeeder::class);
|
||||||
$this->call(DepreciationSeeder::class);
|
$this->call(DepreciationSeeder::class);
|
||||||
|
|
|
@ -77,7 +77,6 @@
|
||||||
@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required' => 'false'])
|
@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_location', 'style' => 'display:none;', 'required' => 'false'])
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@include ('partials.forms.edit.serial', ['fieldname'=> 'serials[1]','translated_serial' => trans('admin/hardware/form.serial')])
|
|
||||||
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')])
|
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/hardware/form.name')])
|
||||||
@include ('partials.forms.edit.purchase_date')
|
@include ('partials.forms.edit.purchase_date')
|
||||||
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
|
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
|
||||||
|
|
|
@ -24,6 +24,8 @@ class AssetsCest
|
||||||
{
|
{
|
||||||
$I->wantTo("Test Validation Fails with blank elements");
|
$I->wantTo("Test Validation Fails with blank elements");
|
||||||
$I->amOnPage(route('hardware.create'));
|
$I->amOnPage(route('hardware.create'));
|
||||||
|
// Settings factory can enable auto prefixes, which generate a random asset id. Lets clear it out for the sake of this test.
|
||||||
|
$I->fillField('#asset_tag', '');
|
||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
$I->see('The asset tag field is required.', '.alert-msg');
|
$I->see('The asset tag field is required.', '.alert-msg');
|
||||||
$I->see('The model id field is required.', '.alert-msg');
|
$I->see('The model id field is required.', '.alert-msg');
|
||||||
|
@ -40,7 +42,7 @@ class AssetsCest
|
||||||
]);
|
]);
|
||||||
$userId = $I->getUserId();
|
$userId = $I->getUserId();
|
||||||
$values = [
|
$values = [
|
||||||
'asset_tag' => $asset->asset_tag,
|
'asset_tags[1]' => $asset->asset_tag,
|
||||||
'assigned_user' => $userId,
|
'assigned_user' => $userId,
|
||||||
'company_id' => $asset->company_id,
|
'company_id' => $asset->company_id,
|
||||||
'model_id' => $asset->model_id,
|
'model_id' => $asset->model_id,
|
||||||
|
@ -51,7 +53,7 @@ class AssetsCest
|
||||||
'purchase_date' => '2016-01-01',
|
'purchase_date' => '2016-01-01',
|
||||||
'requestable' => $asset->requestable,
|
'requestable' => $asset->requestable,
|
||||||
'rtd_location_id' => $asset->rtd_location_id,
|
'rtd_location_id' => $asset->rtd_location_id,
|
||||||
'serial' => $asset->serial,
|
'serials[1]' => $asset->serial,
|
||||||
'status_id' => $asset->status_id,
|
'status_id' => $asset->status_id,
|
||||||
'supplier_id' => $asset->supplier_id,
|
'supplier_id' => $asset->supplier_id,
|
||||||
'warranty_months' => $asset->warranty_months,
|
'warranty_months' => $asset->warranty_months,
|
||||||
|
@ -67,7 +69,7 @@ class AssetsCest
|
||||||
'notes' => $asset->notes,
|
'notes' => $asset->notes,
|
||||||
'order_number' => $asset->order_number,
|
'order_number' => $asset->order_number,
|
||||||
'purchase_cost' => $asset->purchase_cost,
|
'purchase_cost' => $asset->purchase_cost,
|
||||||
'purchase_date' => Carbon::parse('2016-01-01'),
|
'purchase_date' => '2016-01-01',
|
||||||
'requestable' => $asset->requestable,
|
'requestable' => $asset->requestable,
|
||||||
'rtd_location_id' => $asset->rtd_location_id,
|
'rtd_location_id' => $asset->rtd_location_id,
|
||||||
'serial' => $asset->serial,
|
'serial' => $asset->serial,
|
||||||
|
@ -80,7 +82,7 @@ class AssetsCest
|
||||||
$I->amOnPage(route('hardware.create'));
|
$I->amOnPage(route('hardware.create'));
|
||||||
$I->submitForm('form#create-form', $values);
|
$I->submitForm('form#create-form', $values);
|
||||||
$I->seeRecord('assets', $seenValues);
|
$I->seeRecord('assets', $seenValues);
|
||||||
$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->seeResponseCodeIs(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
public function allowsDelete(FunctionalTester $I)
|
||||||
|
|
|
@ -39,10 +39,10 @@ class GroupsCest
|
||||||
$I->wantTo("Test Validation Fails with short name");
|
$I->wantTo("Test Validation Fails with short name");
|
||||||
$I->amOnPage(route('groups.create'));
|
$I->amOnPage(route('groups.create'));
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
||||||
$I->fillField('name', 't2');
|
$I->fillField('name', 't');
|
||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
$I->seeElement('.alert-danger');
|
$I->seeElement('.alert-danger');
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
$I->see('The name must be at least 2 characters', '.alert-msg');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
public function passesCorrectValidation(FunctionalTester $I)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class UsersCest
|
||||||
$I->fillField('password', '12345');
|
$I->fillField('password', '12345');
|
||||||
$I->click('Save');
|
$I->click('Save');
|
||||||
$I->seeElement('.alert-danger');
|
$I->seeElement('.alert-danger');
|
||||||
$I->see('The password must be at least 10 characters', '.alert-msg');
|
$I->see('The password must be at least 8 characters', '.alert-msg');
|
||||||
|
|
||||||
}
|
}
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
public function passesCorrectValidation(FunctionalTester $I)
|
||||||
|
|
|
@ -42,10 +42,10 @@ class AssetModelTest extends BaseTest
|
||||||
public function testAnAssetModelContainsAssets()
|
public function testAnAssetModelContainsAssets()
|
||||||
{
|
{
|
||||||
$assetModel = $this->createValidAssetModel();
|
$assetModel = $this->createValidAssetModel();
|
||||||
factory(Asset::class)->create([
|
$this->createValidAsset([
|
||||||
'model_id' => $assetModel->id,
|
'model_id' => $assetModel->id,
|
||||||
]);
|
]);
|
||||||
$this->assertEquals(1,$assetModel->assets()->count());
|
$this->assertEquals(1, $assetModel->assets()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAnAssetModelHasACategory()
|
public function testAnAssetModelHasACategory()
|
||||||
|
|
|
@ -77,7 +77,11 @@ class AssetTest extends BaseTest
|
||||||
*/
|
*/
|
||||||
public function testWarrantyExpiresAttribute()
|
public function testWarrantyExpiresAttribute()
|
||||||
{
|
{
|
||||||
$asset = factory(Asset::class)->states('laptop-mbp')->create(['model_id' => $this->createValidAssetModel()->id]);
|
$asset = factory(Asset::class)->states('laptop-mbp')->create([
|
||||||
|
'model_id' => $this->createValidAssetModel()->id,
|
||||||
|
'supplier_id' => $this->createvalidSupplier()->id,
|
||||||
|
'rtd_location_id' => $this->createValidLocation()->id
|
||||||
|
]);
|
||||||
|
|
||||||
$asset->purchase_date = Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0);
|
$asset->purchase_date = Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0);
|
||||||
$asset->warranty_months = 24;
|
$asset->warranty_months = 24;
|
||||||
|
@ -109,7 +113,11 @@ class AssetTest extends BaseTest
|
||||||
public function testModelIdMustExist()
|
public function testModelIdMustExist()
|
||||||
{
|
{
|
||||||
$model = $this->createValidAssetModel();
|
$model = $this->createValidAssetModel();
|
||||||
$asset = factory(Asset::class)->make(['model_id' => $model->id]);
|
$asset = factory(Asset::class)->make([
|
||||||
|
'model_id' => $model->id,
|
||||||
|
'supplier_id' => $this->createValidSupplier()->id,
|
||||||
|
'rtd_location_id' => $this->createValidLocation()->id
|
||||||
|
]);
|
||||||
$asset->save();
|
$asset->save();
|
||||||
$this->assertTrue($asset->isValid());
|
$this->assertTrue($asset->isValid());
|
||||||
$newId = $model->id + 1;
|
$newId = $model->id + 1;
|
||||||
|
@ -188,7 +196,9 @@ class AssetTest extends BaseTest
|
||||||
|
|
||||||
public function testAnAssetCanHaveUploads()
|
public function testAnAssetCanHaveUploads()
|
||||||
{
|
{
|
||||||
$asset = $this->createValidAsset();
|
$asset = $this->createValidAsset([
|
||||||
|
'supplier_id' => $this->createValidSupplier()->id
|
||||||
|
]);
|
||||||
$this->assertCount(0, $asset->uploads);
|
$this->assertCount(0, $asset->uploads);
|
||||||
factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
|
factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
|
||||||
$this->assertCount(1, $asset->fresh()->uploads);
|
$this->assertCount(1, $asset->fresh()->uploads);
|
||||||
|
|
|
@ -16,7 +16,9 @@ class BaseTest extends \Codeception\TestCase\Test
|
||||||
protected function signIn($user = null)
|
protected function signIn($user = null)
|
||||||
{
|
{
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$user = factory(User::class)->states('superuser')->create();
|
$user = factory(User::class)->states('superuser')->create([
|
||||||
|
'location_id' => $this->createValidLocation()->id
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
Auth::login($user);
|
Auth::login($user);
|
||||||
|
|
||||||
|
@ -78,17 +80,24 @@ class BaseTest extends \Codeception\TestCase\Test
|
||||||
|
|
||||||
protected function createValidUser($overrides= [])
|
protected function createValidUser($overrides= [])
|
||||||
{
|
{
|
||||||
return factory(App\Models\User::class)->create($overrides);
|
return factory(App\Models\User::class)->create(
|
||||||
|
array_merge([
|
||||||
|
'location_id'=>$this->createValidLocation()->id
|
||||||
|
], $overrides)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createValidAsset($overrides = [])
|
protected function createValidAsset($overrides = [])
|
||||||
{
|
{
|
||||||
$locId = $this->createValidLocation();
|
$locId = $this->createValidLocation()->id;
|
||||||
$this->createValidAssetModel();
|
$this->createValidAssetModel();
|
||||||
return factory(\App\Models\Asset::class)->states('laptop-mbp')->create([
|
return factory(\App\Models\Asset::class)->states('laptop-mbp')->create(
|
||||||
'rtd_location_id' => $locId,
|
array_merge([
|
||||||
'location_id' => $locId
|
'rtd_location_id' => $locId,
|
||||||
], $overrides);
|
'location_id' => $locId,
|
||||||
|
'supplier_id' => $this->createValidSupplier()->id
|
||||||
|
], $overrides)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,9 @@ class CategoryTest extends BaseTest
|
||||||
$this->assertCount(5, $category->models);
|
$this->assertCount(5, $category->models);
|
||||||
|
|
||||||
$models->each(function($model) {
|
$models->each(function($model) {
|
||||||
factory(App\Models\Asset::class, 2)->create(['model_id' => $model->id]);
|
// This is intentionally run twice to generate the ten imagined assets, done this way to keep it in sync with createValidAsset rather than using the factory directly.
|
||||||
|
$this->createValidAsset(['model_id' => $model->id]);
|
||||||
|
$this->createValidAsset(['model_id' => $model->id]);
|
||||||
});
|
});
|
||||||
$this->assertEquals(10, $category->itemCount());
|
$this->assertEquals(10, $category->itemCount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,17 +31,14 @@ class CompanyTest extends BaseTest
|
||||||
public function testACompanyCanHaveUsers()
|
public function testACompanyCanHaveUsers()
|
||||||
{
|
{
|
||||||
$company = $this->createValidCompany();
|
$company = $this->createValidCompany();
|
||||||
factory(App\Models\User::class, 1)->create(['company_id'=>$company->id]);
|
$user = $this->createValidUser(['company_id'=>$company->id]);
|
||||||
$this->assertCount(1, $company->users);
|
$this->assertCount(1, $company->users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testACompanyCanHaveAssets()
|
public function testACompanyCanHaveAssets()
|
||||||
{
|
{
|
||||||
$company = $this->createValidCompany();
|
$company = $this->createValidCompany();
|
||||||
factory(App\Models\Asset::class, 1)->states('laptop-mbp')->create([
|
$this->createValidAsset(['company_id' => $company->id]);
|
||||||
'company_id' => $company->id,
|
|
||||||
'model_id' => $this->createValidAssetModel()->id
|
|
||||||
]);
|
|
||||||
$this->assertCount(1, $company->assets);
|
$this->assertCount(1, $company->assets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class LocationTest extends BaseTest
|
||||||
protected $tester;
|
protected $tester;
|
||||||
|
|
||||||
public function testPassesIfNotSelfParent() {
|
public function testPassesIfNotSelfParent() {
|
||||||
|
$this->createValidLocation(['id' => 10]);
|
||||||
|
|
||||||
$a = factory(Location::class)->make([
|
$a = factory(Location::class)->make([
|
||||||
'name' => 'Test Location',
|
'name' => 'Test Location',
|
||||||
|
|
|
@ -21,15 +21,15 @@ class NotificationTest extends BaseTest
|
||||||
|
|
||||||
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
|
||||||
{
|
{
|
||||||
$admin = factory(User::class)->states('superuser')->create();
|
$admin = factory(User::class)->states('superuser')->create();
|
||||||
Auth::login($admin);
|
Auth::login($admin);
|
||||||
$cat = $this->createValidCategory('asset-laptop-category', ['require_acceptance' => true]);
|
$cat = $this->createValidCategory('asset-laptop-category', ['require_acceptance' => true]);
|
||||||
$model = $this->createValidAssetModel('mbp-13-model', ['category_id' => $cat->id]);
|
$model = $this->createValidAssetModel('mbp-13-model', ['category_id' => $cat->id]);
|
||||||
$asset = $this->createValidAsset(['model_id' => $model->id]);
|
$asset = $this->createValidAsset(['model_id' => $model->id]);
|
||||||
$user = factory(User::class)->create();
|
$user = $this->createValidUser();
|
||||||
Notification::fake();
|
|
||||||
$asset->checkOut($user, 1);
|
|
||||||
|
|
||||||
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
Notification::fake();
|
||||||
|
$asset->checkOut($user, 1);
|
||||||
|
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue