-
+
{{ trans('admin/users/general.edit') }}
@@ -863,7 +847,7 @@
@can('update', $license)
- {{ trans('general.checkin') }}
+ {{ trans('general.checkin') }}
@endcan
|
@@ -1044,7 +1028,6 @@
data-bulk-button-id="#bulkLocationsEditButton"
data-bulk-form-id="#locationsBulkForm"
data-search="true"
- data-show-footer="true"
data-side-pagination="server"
data-show-columns="true"
data-show-fullscreen="true"
@@ -1077,7 +1060,6 @@
data-bulk-button-id="#bulkUserEditButton"
data-bulk-form-id="#usersBulkForm"
data-search="true"
- data-show-footer="true"
data-side-pagination="server"
data-show-columns="true"
data-show-fullscreen="true"
diff --git a/routes/api.php b/routes/api.php
index b51e139a41..96792a8f55 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -1302,20 +1302,6 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
)->name('api.activity.index');
}); // end reports api routes
- /**
- * Notes API routes
- */
-
- Route::group(['prefix' => 'notes'], function () {
-
- Route::post(
- '/',
- [ Api\NotesController::class,
- 'store'
- ]
- )->name('api.notes.store');
- }); // end notes api routes
-
/**
diff --git a/routes/web.php b/routes/web.php
index b67062e720..a3df05ac76 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -2,6 +2,9 @@
use App\Http\Controllers\Account;
use App\Http\Controllers\ActionlogController;
+use App\Http\Controllers\Auth\ForgotPasswordController;
+use App\Http\Controllers\Auth\LoginController;
+use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\CategoriesController;
use App\Http\Controllers\CompaniesController;
use App\Http\Controllers\DashboardController;
@@ -9,24 +12,22 @@ use App\Http\Controllers\DepartmentsController;
use App\Http\Controllers\DepreciationsController;
use App\Http\Controllers\GroupsController;
use App\Http\Controllers\HealthController;
-use App\Http\Controllers\ImportsController;
use App\Http\Controllers\LabelsController;
use App\Http\Controllers\LocationsController;
use App\Http\Controllers\ManufacturersController;
use App\Http\Controllers\ModalController;
+use App\Http\Controllers\NotesController;
use App\Http\Controllers\ProfileController;
-use App\Http\Controllers\ReportsController;
use App\Http\Controllers\ReportTemplatesController;
+use App\Http\Controllers\ReportsController;
use App\Http\Controllers\SettingsController;
use App\Http\Controllers\StatuslabelsController;
use App\Http\Controllers\SuppliersController;
use App\Http\Controllers\ViewAssetsController;
-use App\Http\Controllers\Auth\LoginController;
-use App\Http\Controllers\Auth\ForgotPasswordController;
-use App\Http\Controllers\Auth\ResetPasswordController;
use App\Livewire\Importer;
+use App\Models\ReportTemplate;
use Illuminate\Support\Facades\Route;
-use Illuminate\Support\Facades\Auth;
+use Tabuna\Breadcrumbs\Trail;
Route::group(['middleware' => 'auth'], function () {
/*
@@ -101,37 +102,27 @@ Route::group(['middleware' => 'auth'], function () {
Route::post('{manufacturers_id}/restore', [ManufacturersController::class, 'restore'] )->name('restore/manufacturer');
});
- Route::resource('manufacturers', ManufacturersController::class, [
- 'parameters' => ['manufacturer' => 'manufacturers_id'],
- ]);
+ Route::resource('manufacturers', ManufacturersController::class);
/*
* Suppliers
*/
- Route::resource('suppliers', SuppliersController::class, [
- 'parameters' => ['supplier' => 'supplier_id'],
- ]);
+ Route::resource('suppliers', SuppliersController::class);
/*
* Depreciations
*/
- Route::resource('depreciations', DepreciationsController::class, [
- 'parameters' => ['depreciation' => 'depreciation_id'],
- ]);
+ Route::resource('depreciations', DepreciationsController::class);
/*
* Status Labels
*/
- Route::resource('statuslabels', StatuslabelsController::class, [
- 'parameters' => ['statuslabel' => 'statuslabel_id'],
- ]);
+ Route::resource('statuslabels', StatuslabelsController::class);
/*
* Departments
*/
- Route::resource('departments', DepartmentsController::class, [
- 'parameters' => ['department' => 'department_id'],
- ]);
+ Route::resource('departments', DepartmentsController::class);
});
/*
@@ -178,46 +169,137 @@ Route::group(['middleware' => 'auth'], function () {
*/
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser']], function () {
- Route::get('settings', [SettingsController::class, 'getSettings'])->name('settings.general.index');
- Route::post('settings', [SettingsController::class, 'postSettings'])->name('settings.general.save');
- Route::get('branding', [SettingsController::class, 'getBranding'])->name('settings.branding.index');
- Route::post('branding', [SettingsController::class, 'postBranding'])->name('settings.branding.save');
+ Route::get('settings', [SettingsController::class, 'getSettings'])
+ ->name('settings.general.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.general_title'), route('settings.general.index')));
- Route::get('security', [SettingsController::class, 'getSecurity'])->name('settings.security.index');
- Route::post('security', [SettingsController::class, 'postSecurity'])->name('settings.security.save');
+ Route::post('settings', [SettingsController::class, 'postSettings'])
+ ->name('settings.general.save');
- Route::get('groups', [GroupsController::class, 'index'])->name('settings.groups.index');
+ Route::get('branding', [SettingsController::class, 'getBranding'])
+ ->name('settings.branding.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.branding_title'), route('settings.branding.index')));
- Route::get('localization', [SettingsController::class, 'getLocalization'])->name('settings.localization.index');
- Route::post('localization', [SettingsController::class, 'postLocalization'])->name('settings.localization.save');
+ Route::post('branding', [SettingsController::class, 'postBranding'])
+ ->name('settings.branding.save');
- Route::get('notifications', [SettingsController::class, 'getAlerts'])->name('settings.alerts.index');
- Route::post('notifications', [SettingsController::class, 'postAlerts'])->name('settings.alerts.save');
+ Route::get('security', [SettingsController::class, 'getSecurity'])
+ ->name('settings.security.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.security_title'), route('settings.security.index')));
- Route::get('slack', [SettingsController::class, 'getSlack'])->name('settings.slack.index');
- Route::post('slack', [SettingsController::class, 'postSlack'])->name('settings.slack.save');
+ Route::post('security', [SettingsController::class, 'postSecurity'])
+ ->name('settings.security.save');
- Route::get('asset_tags', [SettingsController::class, 'getAssetTags'])->name('settings.asset_tags.index');
- Route::post('asset_tags', [SettingsController::class, 'postAssetTags'])->name('settings.asset_tags.save');
+ Route::get('localization', [SettingsController::class, 'getLocalization'])
+ ->name('settings.localization.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.localization_title'), route('settings.localization.index')));
- Route::get('labels', [SettingsController::class, 'getLabels'])->name('settings.labels.index');
- Route::post('labels', [SettingsController::class, 'postLabels'])->name('settings.labels.save');
+ Route::post('localization', [SettingsController::class, 'postLocalization'])
+ ->name('settings.localization.save');
- Route::get('ldap', [SettingsController::class, 'getLdapSettings'])->name('settings.ldap.index');
- Route::post('ldap', [SettingsController::class, 'postLdapSettings'])->name('settings.ldap.save');
+ Route::get('notifications', [SettingsController::class, 'getAlerts'])
+ ->name('settings.alerts.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.alert_title'), route('settings.alerts.index')));
- Route::get('phpinfo', [SettingsController::class, 'getPhpInfo'])->name('settings.phpinfo.index');
+ Route::post('notifications', [SettingsController::class, 'postAlerts'])
+ ->name('settings.alerts.save');
- Route::get('oauth', [SettingsController::class, 'api'])->name('settings.oauth.index');
+ Route::get('slack', [SettingsController::class, 'getSlack'])
+ ->name('settings.slack.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.webhook_title'), route('settings.slack.index')));
+
+ Route::post('slack', [SettingsController::class, 'postSlack'])
+ ->name('settings.slack.save');
+
+ Route::get('asset_tags', [SettingsController::class, 'getAssetTags'])
+ ->name('settings.asset_tags.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.asset_tag_title'), route('settings.asset_tags.index')));
+
+ Route::post('asset_tags', [SettingsController::class, 'postAssetTags'])
+ ->name('settings.asset_tags.save');
+
+ Route::get('labels', [SettingsController::class, 'getLabels'])
+ ->name('settings.labels.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.labels_title'), route('settings.labels.index')));
+
+ Route::post('labels', [SettingsController::class, 'postLabels'])
+ ->name('settings.labels.save');
+
+ Route::get('ldap', [SettingsController::class, 'getLdapSettings'])
+ ->name('settings.ldap.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.ldap_ad'), route('settings.ldap.index')));
+
+ Route::post('ldap', [SettingsController::class, 'postLdapSettings'])
+ ->name('settings.ldap.save');
+
+ Route::get('phpinfo', [SettingsController::class, 'getPhpInfo'])
+ ->name('settings.phpinfo.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.php_info'), route('settings.phpinfo.index')));
+
+ Route::get('oauth', [SettingsController::class, 'api'])
+ ->name('settings.oauth.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.oauth'), route('settings.oauth.index')));
+
+ Route::get('google', [SettingsController::class, 'getGoogleLoginSettings'])
+ ->name('settings.google.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.google_login'), route('settings.google.index')));
+
+ Route::post('google', [SettingsController::class, 'postGoogleLoginSettings'])
+ ->name('settings.google.save');
+
+ Route::get('purge', [SettingsController::class, 'getPurge'])
+ ->name('settings.purge.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.purge'), route('settings.purge.index')));
+
+ Route::post('purge', [SettingsController::class, 'postPurge'])
+ ->name('settings.purge.save');
+
+ Route::get('login-attempts', [SettingsController::class, 'getLoginAttempts'])
+ ->name('settings.logins.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.login'), route('settings.logins.index')));
+
+
+ // SAML
+ Route::get('/saml', [SettingsController::class, 'getSamlSettings'])
+ ->name('settings.saml.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.saml_title'), route('settings.saml.index')));
+
+ Route::post('/saml', [SettingsController::class, 'postSamlSettings'])
+ ->name('settings.saml.save');
- Route::get('google', [SettingsController::class, 'getGoogleLoginSettings'])->name('settings.google.index');
- Route::post('google', [SettingsController::class, 'postGoogleLoginSettings'])->name('settings.google.save');
- Route::get('purge', [SettingsController::class, 'getPurge'])->name('settings.purge.index');
- Route::post('purge', [SettingsController::class, 'postPurge'])->name('settings.purge.save');
- Route::get('login-attempts', [SettingsController::class, 'getLoginAttempts'])->name('settings.logins.index');
// Backups
Route::group(['prefix' => 'backups', 'middleware' => 'auth'], function () {
@@ -244,15 +326,25 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
return redirect(route('settings.backups.index'));
});
- Route::get('/', [SettingsController::class, 'getBackups'])->name('settings.backups.index');
+ Route::get('/', [SettingsController::class, 'getBackups'])
+ ->name('settings.backups.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.backups'), route('settings.backups.index')));
});
- Route::resource('groups', GroupsController::class, [
- 'middleware' => ['auth'],
- 'parameters' => ['group' => 'group_id'],
- ]);
+ Route::resource('groups', GroupsController::class);
- Route::get('/', [SettingsController::class, 'index'])->name('settings.index');
+
+ /**
+ * This breadcrumb is repeated for groups in the BreadcrumbServiceProvider, since groups uses resource routes
+ * and that servcie provider cannot see the breadcrumbs defined below
+ */
+ Route::get('/', [SettingsController::class, 'index'])
+ ->name('settings.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.admin'), route('settings.index')));
});
/*
@@ -264,9 +356,12 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
|
*/
-Route::get('/import',
- Importer::class
-)->middleware('auth')->name('imports.index');
+Route::get('/import', Importer::class)
+ ->middleware('auth')
+ ->name('imports.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.import'), route('imports.index')));
/*
|--------------------------------------------------------------------------
@@ -279,26 +374,54 @@ Route::get('/import',
Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
// Profile
- Route::get('profile', [ProfileController::class, 'getIndex'])->name('profile');
- Route::post('profile', [ProfileController::class, 'postIndex']);
+ Route::get('profile', [ProfileController::class, 'getIndex'])
+ ->name('profile')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.editprofile'), route('profile')));
- Route::get('menu', [ProfileController::class, 'getMenuState'])->name('account.menuprefs');
+ Route::post('profile', [ProfileController::class, 'postIndex'])
+ ->name('profile.update');
- Route::get('password', [ProfileController::class, 'password'])->name('account.password.index');
- Route::post('password', [ProfileController::class, 'passwordSave']);
+ Route::get('menu', [ProfileController::class, 'getMenuState'])
+ ->name('account.menuprefs');
- Route::get('api', [ProfileController::class, 'api'])->name('user.api');
+ Route::get('password', [ProfileController::class, 'password'])
+ ->name('account.password.index')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.changepassword'), route('account.password.index')));
+
+ Route::post('password', [ProfileController::class, 'passwordSave'])
+ ->name('account.password.update');
+
+ Route::get('api', [ProfileController::class, 'api'])
+ ->name('user.api')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.manage_api_keys'), route('user.api')));
// View Assets
- Route::get('view-assets', [ViewAssetsController::class, 'getIndex'])->name('view-assets');
+ Route::get('view-assets', [ViewAssetsController::class, 'getIndex'])
+ ->name('view-assets')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.viewassets'), route('view-assets')));
- Route::get('requested', [ViewAssetsController::class, 'getRequestedAssets'])->name('account.requested');
+ Route::get('requested', [ViewAssetsController::class, 'getRequestedAssets'])
+ ->name('account.requested')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.requested_assets_menu'), route('account.requested')));
// Profile
Route::get(
- 'requestable-assets',
- [ViewAssetsController::class, 'getRequestableIndex']
- )->name('requestable-assets');
+ 'requestable-assets', [ViewAssetsController::class, 'getRequestableIndex'])
+ ->name('requestable-assets')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.requestable_items'), route('requestable-assets')));
+
Route::post(
'request-asset/{assetId}',
[ViewAssetsController::class, 'getRequestAsset']
@@ -310,13 +433,20 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
)->name('account/request-item');
// Account Dashboard
- Route::get('/', [ViewAssetsController::class, 'getIndex'])->name('account');
+ Route::get('/', [ViewAssetsController::class, 'getIndex'])
+ ->name('account');
Route::get('accept', [Account\AcceptanceController::class, 'index'])
- ->name('account.accept');
+ ->name('account.accept')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.accept_assets_menu'), route('account.accept')));
Route::get('accept/{id}', [Account\AcceptanceController::class, 'create'])
- ->name('account.accept.item');
+ ->name('account.accept.item')
+ ->breadcrumbs(fn (Trail $trail, $id) =>
+ $trail->parent('account.accept')
+ ->push(trans('general.accept_item'), route('account.accept.item', $id)));
Route::post('accept/{id}', [Account\AcceptanceController::class, 'store'])
->name('account.store-acceptance');
@@ -340,76 +470,131 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () {
});
Route::group(['middleware' => ['auth']], function () {
- Route::get('reports/audit',
- [ReportsController::class, 'audit']
- )->name('reports.audit');
+ Route::post('notes', [NotesController::class, 'store'])->name('notes.store');
+});
+
+Route::group(['prefix' => 'reports', 'middleware' => ['auth']], function () {
+
+ Route::get('audit', [ReportsController::class, 'audit'])
+ ->name('reports.audit')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.audit_report'), route('reports.audit')));
Route::get(
- 'reports/depreciation',
- [ReportsController::class, 'getDeprecationReport']
- )->name('reports/depreciation');
- Route::get(
- 'reports/export/depreciation',
- [ReportsController::class, 'exportDeprecationReport']
- )->name('reports/export/depreciation');
- Route::get(
- 'reports/asset_maintenances',
- [ReportsController::class, 'getAssetMaintenancesReport']
- )->name('reports/asset_maintenances');
- Route::get(
- 'reports/export/asset_maintenances',
- [ReportsController::class, 'exportAssetMaintenancesReport']
- )->name('reports/export/asset_maintenances');
- Route::get(
- 'reports/licenses',
- [ReportsController::class, 'getLicenseReport']
- )->name('reports/licenses');
- Route::get(
- 'reports/export/licenses',
- [ReportsController::class, 'exportLicenseReport']
- )->name('reports/export/licenses');
+ 'depreciation', [ReportsController::class, 'getDeprecationReport'])
+ ->name('reports/depreciation')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.depreciation_report'), route('reports/depreciation')));
- Route::get('reports/accessories', [ReportsController::class, 'getAccessoryReport'])->name('reports/accessories');
- Route::get(
- 'reports/export/accessories',
- [ReportsController::class, 'exportAccessoryReport']
- )->name('reports/export/accessories');
- Route::get('reports/custom', [ReportsController::class, 'getCustomReport'])->name('reports/custom');
- Route::post('reports/custom', [ReportsController::class, 'postCustom']);
- Route::prefix('reports/templates')->name('report-templates')->group(function () {
- Route::post('/', [ReportTemplatesController::class, 'store'])->name('.store');
- Route::get('/{reportTemplate}', [ReportTemplatesController::class, 'show'])->name('.show');
- Route::get('/{reportTemplate}/edit', [ReportTemplatesController::class, 'edit'])->name('.edit');
- Route::post('/{reportTemplate}', [ReportTemplatesController::class, 'update'])->name('.update');
- Route::delete('/{reportTemplate}', [ReportTemplatesController::class, 'destroy'])->name('.destroy');
+ // Is this still used??
+ Route::get(
+ 'export/depreciation', [ReportsController::class, 'exportDeprecationReport'])
+ ->name('reports/export/depreciation')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.depreciation_report'), route('reports.audit')));
+
+ Route::get(
+ 'asset_maintenances', [ReportsController::class, 'getAssetMaintenancesReport'])
+ ->name('reports/asset_maintenances')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.asset_maintenance_report'), route('reports/asset_maintenances')));
+
+ // Is this still used?
+ Route::get('export/asset_maintenances', [ReportsController::class, 'exportAssetMaintenancesReport'])
+ ->name('reports/export/asset_maintenances')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.asset_maintenance_report'), route('reports/export/asset_maintenances')));
+
+ Route::get('licenses', [ReportsController::class, 'getLicenseReport'])
+ ->name('reports/licenses')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.license_report'), route('reports/licenses')));
+
+ Route::get('export/licenses', [ReportsController::class, 'exportLicenseReport'])
+ ->name('reports/export/licenses');
+
+ Route::get('accessories', [ReportsController::class, 'getAccessoryReport'])
+ ->name('reports/accessories');
+
+ Route::get('export/accessories', [ReportsController::class, 'exportAccessoryReport'])
+ ->name('reports/export/accessories');
+
+ Route::get('custom', [ReportsController::class, 'getCustomReport'])
+ ->name('reports/custom')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.custom_report'), route('reports/custom')));
+
+ Route::post('custom', [ReportsController::class, 'postCustom']);
+
+
+ Route::prefix('templates')
+ ->group(function () {
+
+ Route::post('/', [ReportTemplatesController::class, 'store'])
+ ->name('report-templates.store');
+
+ // The breadcrumb on this is a little odd for now since we don't have a template index
+ Route::get('/{reportTemplate}', [ReportTemplatesController::class, 'show'])
+ ->name('report-templates.show')
+ ->breadcrumbs(fn (Trail $trail, ReportTemplate $reportTemplate) =>
+ $trail->parent('reports/custom')
+ ->push($reportTemplate->name, null)
+ ->push(trans('general.customize_report'), ''));
+
+ Route::get('/{reportTemplate}/edit', [ReportTemplatesController::class, 'edit'])
+ ->name('report-templates.edit')
+ ->breadcrumbs(fn (Trail $trail, ReportTemplate $reportTemplate) =>
+ $trail->parent('reports/custom')
+ ->push($reportTemplate->name, route('report-templates.show', $reportTemplate))
+ ->push(trans('general.customize_report'), ''));
+
+
+ Route::post('/{reportTemplate}', [ReportTemplatesController::class, 'update'])
+ ->name('report-templates.update');
+
+ Route::delete('/{reportTemplate}', [ReportTemplatesController::class, 'destroy'])
+ ->name('report-templates.destroy');
});
- Route::get(
- 'reports/activity',
- [ReportsController::class, 'getActivityReport']
- )->name('reports.activity');
- Route::post('reports/activity', [ReportsController::class, 'postActivityReport']);
Route::get(
- 'reports/unaccepted_assets/{deleted?}',
- [ReportsController::class, 'getAssetAcceptanceReport']
- )->name('reports/unaccepted_assets');
+ 'activity', [ReportsController::class, 'getActivityReport'])
+ ->name('reports.activity')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.activity_report'), route('reports.activity')));
+
+ Route::post('activity', [ReportsController::class, 'postActivityReport'])
+ ->name('reports.activity.post');
+
+ Route::get('unaccepted_assets/{deleted?}', [ReportsController::class, 'getAssetAcceptanceReport'])
+ ->name('reports/unaccepted_assets')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('home')
+ ->push(trans('general.unaccepted_asset_report'), route('reports/unaccepted_assets')));
+
+ Route::post('unaccepted_assets/sent_reminder', [ReportsController::class, 'sentAssetAcceptanceReminder'])
+ ->name('reports/unaccepted_assets_sent_reminder');
+
+ Route::delete('unaccepted_assets/{acceptanceId}/delete', [ReportsController::class, 'deleteAssetAcceptance'])
+ ->name('reports/unaccepted_assets_delete');
+
Route::post(
- 'reports/unaccepted_assets/sent_reminder',
- [ReportsController::class, 'sentAssetAcceptanceReminder']
- )->name('reports/unaccepted_assets_sent_reminder');
- Route::delete(
- 'reports/unaccepted_assets/{acceptanceId}/delete',
- [ReportsController::class, 'deleteAssetAcceptance']
- )->name('reports/unaccepted_assets_delete');
- Route::post(
- 'reports/unaccepted_assets/{deleted?}',
- [ReportsController::class, 'postAssetAcceptanceReport']
- )->name('reports/export/unaccepted_assets');
+ 'unaccepted_assets/{deleted?}', [ReportsController::class, 'postAssetAcceptanceReport'])
+ ->name('reports/export/unaccepted_assets');
+
});
+
Route::get(
'auth/signin',
[LoginController::class, 'legacyAuthRedirect']
@@ -521,14 +706,6 @@ Route::group(['middleware' => 'web'], function () {
Route::get('google/callback', 'App\Http\Controllers\GoogleAuthController@handleGoogleCallback')->name('google.callback');
- Route::get(
- '/',
- [
- 'as' => 'home',
- 'middleware' => ['auth'],
- 'uses' => 'DashboardController@getIndex' ]
- );
-
// need to keep GET /logout for SAML SLO
Route::get(
'logout',
@@ -554,4 +731,7 @@ Route::withoutMiddleware(['web'])->get(
Route::middleware(['auth'])->get(
'/',
[DashboardController::class, 'index']
-)->name('home');
+)->name('home')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->push('Home', route('home'))
+ );
diff --git a/routes/web/accessories.php b/routes/web/accessories.php
index 1f28892a0e..cf73e26e0a 100644
--- a/routes/web/accessories.php
+++ b/routes/web/accessories.php
@@ -53,6 +53,5 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function ()
});
Route::resource('accessories', Accessories\AccessoriesController::class, [
- 'middleware' => ['auth'],
- 'parameters' => ['accessory' => 'accessory_id'],
+ 'middleware' => ['auth']
]);
diff --git a/routes/web/fields.php b/routes/web/fields.php
index cdd8fda5d7..7500053c76 100644
--- a/routes/web/fields.php
+++ b/routes/web/fields.php
@@ -33,14 +33,17 @@ Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () {
)->name('fieldsets.associate');
Route::resource('fieldsets', CustomFieldsetsController::class, [
- 'parameters' => ['fieldset' => 'field_id', 'field' => 'field_id']
+ 'parameters' => [
+ 'fieldset' => 'fieldset',
+ 'field' => 'field_id'
+ ]
]);
});
-Route::resource('fields', CustomFieldsController::class, [
- 'middleware' => ['auth'],
- 'parameters' => ['field' => 'field_id', 'fieldset' => 'fieldset_id'],
-]);
+Route::resource('fields', CustomFieldsController::class,
+ ['middleware' => ['auth'],
+ 'except' => ['show']
+ ]);
diff --git a/routes/web/hardware.php b/routes/web/hardware.php
index ee888aa1db..3b65f730ed 100644
--- a/routes/web/hardware.php
+++ b/routes/web/hardware.php
@@ -6,7 +6,10 @@ use App\Http\Controllers\Assets\BulkAssetsController;
use App\Http\Controllers\Assets\AssetCheckoutController;
use App\Http\Controllers\Assets\AssetCheckinController;
use App\Http\Controllers\Assets\AssetFilesController;
+use App\Models\Setting;
+use Tabuna\Breadcrumbs\Trail;
use Illuminate\Support\Facades\Route;
+use App\Models\Asset;
/*
|--------------------------------------------------------------------------
@@ -24,47 +27,59 @@ Route::group(
function () {
- Route::get('bulkaudit',
- [AssetsController::class, 'quickScan']
- )->name('assets.bulkaudit');
+ Route::get('bulkaudit', [AssetsController::class, 'quickScan'])
+ ->name('assets.bulkaudit')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans('general.bulkaudit'), route('asset.import-history'))
+ );
- Route::get('quickscancheckin',
- [AssetsController::class, 'quickScanCheckin']
- )->name('hardware/quickscancheckin');
+ Route::get('quickscancheckin', [AssetsController::class, 'quickScanCheckin'])
+ ->name('hardware/quickscancheckin')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push('Quickscan Checkin', route('hardware/quickscancheckin'))
+ );
- // Asset Maintenances
- Route::resource('maintenances',
- AssetMaintenancesController::class, [
- 'parameters' => ['maintenance' => 'maintenance_id', 'asset' => 'asset_id'],
- ]);
+ Route::get('requested', [AssetsController::class, 'getRequestedIndex'])
+ ->name('assets.requested')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans('admin/hardware/general.requested'), route('assets.requested'))
+ );
- Route::get('requested', [
- AssetsController::class, 'getRequestedIndex']
- )->name('assets.requested');
-
- Route::get('scan',
- [AssetsController::class, 'scan']
- )->name('asset.scan');
-
- Route::get('audit/due',
- [AssetsController::class, 'dueForAudit']
- )->name('assets.audit.due');
+ Route::get('audit/due', [AssetsController::class, 'dueForAudit'])
+ ->name('assets.audit.due')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans_choice('general.audit_due_days', Setting::getSettings()->audit_warning_days, ['days' => Setting::getSettings()->audit_warning_days]), route('assets.audit.due'))
+ );
Route::get('checkins/due',
[AssetsController::class, 'dueForCheckin']
- )->name('assets.checkins.due');
+ )->name('assets.checkins.due')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans_choice('general.checkin_due_days', Setting::getSettings()->due_checkin_days, ['days' => Setting::getSettings()->due_checkin_days]), route('assets.audit.due'))
+ );
- Route::get('audit/{id}',
- [AssetsController::class, 'audit']
- )->name('asset.audit.create');
+ Route::get('audit/{asset}', [AssetsController::class, 'audit'])
+ ->name('asset.audit.create')
+ ->breadcrumbs(fn (Trail $trail, Asset $asset) =>
+ $trail->parent('hardware.show', $asset)
+ ->push(trans('general.audit'))
+ );
- Route::post('audit/{id}',
+ Route::post('audit/{asset}',
[AssetsController::class, 'auditStore']
)->name('asset.audit.store');
- Route::get('history',
- [AssetsController::class, 'getImportHistory']
- )->name('asset.import-history');
+ Route::get('history', [AssetsController::class, 'getImportHistory'])
+ ->name('asset.import-history')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans('general.import-history'), route('asset.import-history'))
+ );
Route::post('history',
[AssetsController::class, 'postImportHistory']
@@ -85,19 +100,25 @@ Route::group(
Route::get('{assetId}/label',
[AssetsController::class, 'getLabel']
)->name('label/hardware');
-
- Route::get('{assetId}/checkout',
- [AssetCheckoutController::class, 'create']
- )->name('hardware.checkout.create');
+ Route::get('{asset}/checkout', [AssetCheckoutController::class, 'create'])
+ ->name('hardware.checkout.create')
+ ->breadcrumbs(fn (Trail $trail, Asset $asset) =>
+ $trail->parent('hardware.show', $asset)
+ ->push(trans('admin/hardware/general.checkout'), route('hardware.index'))
+ );
Route::post('{assetId}/checkout',
[AssetCheckoutController::class, 'store']
)->name('hardware.checkout.store');
- Route::get('{assetId}/checkin/{backto?}',
+ Route::get('{asset}/checkin/{backto?}',
[AssetCheckinController::class, 'create']
- )->name('hardware.checkin.create');
+ )->name('hardware.checkin.create')
+ ->breadcrumbs(fn (Trail $trail, Asset $asset) =>
+ $trail->parent('hardware.show', $asset)
+ ->push(trans('admin/hardware/general.checkin'), route('hardware.index'))
+ );
Route::post('{assetId}/checkin/{backto?}',
[AssetCheckinController::class, 'store']
@@ -105,32 +126,32 @@ Route::group(
// Redirect old legacy /asset_id/view urls to the resource route version
Route::get('{assetId}/view', function ($assetId) {
- return redirect()->route('hardware.show', ['hardware' => $assetId]);
+ return redirect()->route('hardware.show', $assetId);
});
- Route::get('{assetId}/qr_code',
+ Route::get('{asset}/qr_code',
[AssetsController::class, 'getQrCode']
- )->name('qr_code/hardware');
+ )->name('qr_code/hardware')->withTrashed();
- Route::get('{assetId}/barcode',
+ Route::get('{asset}/barcode',
[AssetsController::class, 'getBarCode']
- )->name('barcode/hardware');
+ )->name('barcode/hardware')->withTrashed();
- Route::post('{assetId}/restore',
+ Route::post('{asset}/restore',
[AssetsController::class, 'getRestore']
- )->name('restore/hardware');
+ )->name('restore/hardware')->withTrashed();
- Route::post('{assetId}/upload',
+ Route::post('{asset}/upload',
[AssetFilesController::class, 'store']
- )->name('upload/asset');
+ )->name('upload/asset')->withTrashed();
- Route::get('{assetId}/showfile/{fileId}/{download?}',
+ Route::get('{asset}/showfile/{fileId}/{download?}',
[AssetFilesController::class, 'show']
- )->name('show/assetfile');
+ )->name('show/assetfile')->withTrashed();
- Route::delete('{assetId}/showfile/{fileId}/delete',
+ Route::delete('{asset}/showfile/{fileId}/delete',
[AssetFilesController::class, 'destroy']
- )->name('delete/assetfile');
+ )->name('delete/assetfile')->withTrashed();
Route::post(
'bulkedit',
@@ -153,9 +174,12 @@ Route::group(
)->name('hardware/bulksave');
// Bulk checkout / checkin
- Route::get('bulkcheckout',
- [BulkAssetsController::class, 'showCheckout']
- )->name('hardware.bulkcheckout.show');
+ Route::get('bulkcheckout', [BulkAssetsController::class, 'showCheckout'])
+ ->name('hardware.bulkcheckout.show')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('hardware.index')
+ ->push(trans('admin/hardware/general.bulk_checkout'), route('hardware.index'))
+ );
Route::post('bulkcheckout',
[BulkAssetsController::class, 'storeCheckout']
@@ -163,16 +187,17 @@ Route::group(
});
-Route::resource('hardware',
- AssetsController::class,
- [
- 'middleware' => ['auth'],
- 'parameters' => ['asset' => 'asset_id',
- 'names' => [
- 'show' => 'view',
- ],
- ],
-]);
+Route::resource('hardware',
+ AssetsController::class,
+ ['middleware' => ['auth']
+])->parameters(['hardware' => 'asset'])->withTrashed();
+
+
+// Asset Maintenances
+Route::resource('maintenances',
+ AssetMaintenancesController::class, [
+ 'parameters' => ['maintenance' => 'maintenance', 'asset' => 'asset_id'],
+ ]);
Route::get('ht/{any?}',
[AssetsController::class, 'getAssetByTag']
diff --git a/routes/web/kits.php b/routes/web/kits.php
index 6b687f0bff..abd2d75266 100644
--- a/routes/web/kits.php
+++ b/routes/web/kits.php
@@ -1,21 +1,17 @@
['auth'],
- 'parameters' => ['kit' => 'kit_id'],
-]);
-
-Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function () {
+Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {
// Route::get('licenses',
// [Kits\PredefinedKitsController::class, 'indexLicenses']
// )->name('kits.licenses.index');
- Route::post('licenses',
+ Route::put('licenses',
[Kits\PredefinedKitsController::class, 'storeLicense']
)->name('kits.licenses.store');
@@ -23,9 +19,11 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function (
[Kits\PredefinedKitsController::class, 'updateLicense']
)->name('kits.licenses.update');
- Route::get('licenses/{license_id}/edit',
- [Kits\PredefinedKitsController::class, 'editLicense']
- )->name('kits.licenses.edit');
+ Route::get('licenses/{license_id}/edit', [Kits\PredefinedKitsController::class, 'editLicense'])
+ ->name('kits.licenses.edit')
+ ->breadcrumbs(fn (Trail $trail) =>
+ $trail->parent('settings.index')
+ ->push(trans('admin/settings/general.backups'), route('kits.licenses.edit')));
Route::delete('licenses/{license_id}',
[Kits\PredefinedKitsController::class, 'detachLicense']
@@ -35,7 +33,7 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function (
Route::put('models/{model_id}',
[Kits\PredefinedKitsController::class, 'updateModel']
- )/* ->parameters([2 => 'kit_id', 1 => 'model_id'])*/->name('kits.models.update');
+ )->name('kits.models.update');
Route::get('models/{model_id}/edit',
[Kits\PredefinedKitsController::class, 'editModel']
@@ -63,18 +61,24 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function (
[Kits\PredefinedKitsController::class, 'updateAccessory']
)/*->parameters([2 => 'kit_id', 1 => 'accessory_id'])*/->name('kits.accessories.update');
- Route::get('accessories/{accessory_id}/edit',
- [Kits\PredefinedKitsController::class, 'editAccessory']
- )->name('kits.accessories.edit');
+ Route::get('accessories/{accessory_id}/edit', [Kits\PredefinedKitsController::class, 'editAccessory'])
+ ->name('kits.accessories.edit');
- Route::delete('accessories/{accessory_id}',
- [Kits\PredefinedKitsController::class, 'detachAccessory']
- )->name('kits.accessories.detach');
- Route::get('checkout',
- [Kits\CheckoutKitController::class, 'showCheckout']
- )->name('kits.checkout.show');
+ Route::delete('accessories/{accessory_id}', [Kits\PredefinedKitsController::class, 'detachAccessory'])
+ ->name('kits.accessories.detach');
- Route::post('checkout',
- [Kits\CheckoutKitController::class, 'store']
- )->name('kits.checkout.store');
+ Route::get('checkout', [Kits\CheckoutKitController::class, 'showCheckout'])
+ ->name('kits.checkout.show')
+ ->breadcrumbs(fn (Trail $trail, PredefinedKit $kit) =>
+ $trail->parent('kits.show', $kit)
+ ->push(trans('general.checkout'), route('kits.checkout.show', $kit)));
+
+ Route::post('checkout', [Kits\CheckoutKitController::class, 'store'])
+ ->name('kits.checkout.store');
}); // kits
+
+// Predefined Kit Management
+Route::resource('kits', Kits\PredefinedKitsController::class, [
+ 'middleware' => ['auth'],
+]);
+
diff --git a/routes/web/licenses.php b/routes/web/licenses.php
index 7212a47648..39762c95c5 100644
--- a/routes/web/licenses.php
+++ b/routes/web/licenses.php
@@ -2,6 +2,9 @@
use App\Http\Controllers\Licenses;
use Illuminate\Support\Facades\Route;
+use App\Models\License;
+use App\Models\LicenseSeat;
+use Tabuna\Breadcrumbs\Trail;
// Licenses
Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {
@@ -10,16 +13,25 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {
Route::get('{licenseId}/freecheckout',
[Licenses\LicensesController::class, 'getFreeLicense']
)->name('licenses.freecheckout');
- Route::get('{licenseId}/checkout/{seatId?}',
- [Licenses\LicenseCheckoutController::class, 'create']
- )->name('licenses.checkout');
+
+ Route::get('{license}/checkout/{seatId?}', [Licenses\LicenseCheckoutController::class, 'create'])
+ ->name('licenses.checkout')
+ ->breadcrumbs(fn (Trail $trail, License $license) =>
+ $trail->parent('licenses.show', $license)
+ ->push(trans('general.checkout'), route('licenses.checkout', $license))
+ );
+
Route::post(
'{licenseId}/checkout/{seatId?}',
[Licenses\LicenseCheckoutController::class, 'store']
); //name() would duplicate here, so we skip it.
- Route::get('{licenseSeatId}/checkin/{backto?}',
- [Licenses\LicenseCheckinController::class, 'create']
- )->name('licenses.checkin');
+
+ Route::get('{licenseSeat}/checkin/{backto?}', [Licenses\LicenseCheckinController::class, 'create'])
+ ->name('licenses.checkin')
+ ->breadcrumbs(fn (Trail $trail, LicenseSeat $licenseSeat) =>
+ $trail->parent('licenses.show', $licenseSeat->license)
+ ->push(trans('general.checkin'), route('licenses.checkin', $licenseSeat))
+ );
Route::post('{licenseId}/checkin/{backto?}',
[Licenses\LicenseCheckinController::class, 'store']
@@ -59,5 +71,4 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {
Route::resource('licenses', Licenses\LicensesController::class, [
'middleware' => ['auth'],
- 'parameters' => ['license' => 'license_id'],
]);
diff --git a/routes/web/models.php b/routes/web/models.php
index 37e54995b8..2325846ea6 100644
--- a/routes/web/models.php
+++ b/routes/web/models.php
@@ -10,33 +10,33 @@ use Illuminate\Support\Facades\Route;
Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {
- Route::post('{modelID}/upload',
+ Route::post('{model}/upload',
[AssetModelsFilesController::class, 'store']
- )->name('upload/models');
+ )->name('upload/models')->withTrashed();
- Route::get('{modelID}/showfile/{fileId}/{download?}',
+ Route::get('{model}/showfile/{fileId}/{download?}',
[AssetModelsFilesController::class, 'show']
- )->name('show/modelfile');
+ )->name('show/modelfile')->withTrashed();
- Route::delete('{modelID}/showfile/{fileId}/delete',
+ Route::delete('{model}/showfile/{fileId}/delete',
[AssetModelsFilesController::class, 'destroy']
- )->name('delete/modelfile');
+ )->name('delete/modelfile')->withTrashed();
Route::get(
- '{modelId}/clone',
+ '{model}/clone',
[
AssetModelsController::class,
'getClone'
]
- )->name('models.clone.create');
+ )->name('models.clone.create')->withTrashed();
Route::post(
- '{modelId}/clone',
+ '{model}/clone',
[
AssetModelsController::class,
'postCreate'
]
- )->name('models.clone.store');
+ )->name('models.clone.store')->withTrashed();
Route::get(
'{modelId}/view',
@@ -92,5 +92,4 @@ Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {
Route::resource('models', AssetModelsController::class, [
'middleware' => ['auth'],
- 'parameters' => ['model' => 'model_id'],
-]);
+])->withTrashed();
diff --git a/routes/web/users.php b/routes/web/users.php
index e6aaf644ae..ced9c379a9 100644
--- a/routes/web/users.php
+++ b/routes/web/users.php
@@ -33,20 +33,20 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
)->name('users.export');
Route::get(
- '{userId}/clone',
+ '{user}/clone',
[
Users\UsersController::class,
'getClone'
]
- )->name('users.clone.show');
+ )->name('users.clone.show')->withTrashed();
Route::post(
- '{userId}/clone',
+ '{user}/clone',
[
Users\UsersController::class,
'postCreate'
]
- )->name('users.clone.store');
+ )->name('users.clone.store')->withTrashed();
Route::post(
'{userId}/restore',
@@ -65,12 +65,12 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
)->name('unsuspend/user');
Route::post(
- '{userId}/upload',
+ '{user}/upload',
[
Users\UserFilesController::class,
'store'
]
- )->name('upload/user');
+ )->name('upload/user')->withTrashed();
Route::delete(
'{userId}/deletefile/{fileId}',
@@ -81,12 +81,12 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
)->name('userfile.destroy');
Route::get(
- '{userId}/showfile/{fileId}',
+ '{user}/showfile/{fileId}',
[
Users\UserFilesController::class,
'show'
]
- )->name('show/userfile');
+ )->name('show/userfile')->withTrashed();
Route::post(
'{userId}/password',
@@ -145,12 +145,8 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {
]
)->name('users/bulkeditsave');
- // pulling this out of the resource because I need route model binding in the request
- Route::match(['put', 'patch'], '/{user}', [Users\UsersController::class, 'update'])->name('users.update');
});
Route::resource('users', Users\UsersController::class, [
- 'middleware' => ['auth'],
- 'parameters' => ['user' => 'user_id'],
- 'except' => ['update']
-]);
+ 'middleware' => ['auth']
+])->withTrashed();
diff --git a/snipeit.sh b/snipeit.sh
index cce33de362..121c34280e 100755
--- a/snipeit.sh
+++ b/snipeit.sh
@@ -428,7 +428,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -465,7 +465,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -502,7 +502,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -543,7 +543,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php php-mcrypt php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
+ PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php php php-curl php-mysql php-gd php-ldap php-zip php-mbstring php-xml php-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -584,7 +584,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -628,7 +628,7 @@ case $distro in
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.28.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="cron mariadb-server mariadb-client apache2 libapache2-mod-php8.28.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
@@ -688,12 +688,11 @@ EOL
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-mcrypt php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
+ PACKAGES="mariadb-server mariadb-client apache2 libapache2-mod-php8.2 php8.2 php8.2-curl php8.2-mysql php8.2-gd php8.2-ldap php8.2-zip php8.2-mbstring php8.2-xml php8.2-bcmath curl git unzip"
install_packages
echo "* Configuring Apache."
create_virtualhost
- log "phpenmod mcrypt"
log "phpenmod mbstring"
log "a2enmod rewrite"
log "a2ensite $APP_NAME.conf"
@@ -728,7 +727,7 @@ EOL
amazon-linux-extras install -y php8.2
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml php-process php-zip php-sodium"
+ PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-ldap php-json php-simplexml php-process php-zip php-sodium"
install_packages
echo "* Configuring Apache."
@@ -769,7 +768,7 @@ EOL
log "yum-config-manager --enable remi-php82"
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml php-process php-zip"
+ PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-ldap php-json php-simplexml php-process php-zip"
install_packages
echo "* Configuring Apache."
@@ -812,7 +811,7 @@ EOL
progress
echo "* Installing Apache httpd, PHP, MariaDB and other requirements."
- PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-mcrypt php-ldap php-json php-simplexml php-process php-zip"
+ PACKAGES="httpd mariadb-server git unzip php php-mysqlnd php-bcmath php-embedded php-gd php-mbstring php-ldap php-json php-simplexml php-process php-zip"
install_packages
echo "* Configuring Apache."
diff --git a/tests/Feature/Accessories/Ui/ShowAccessoryTest.php b/tests/Feature/Accessories/Ui/ShowAccessoryTest.php
index f9f2e566c1..288ec9a50c 100644
--- a/tests/Feature/Accessories/Ui/ShowAccessoryTest.php
+++ b/tests/Feature/Accessories/Ui/ShowAccessoryTest.php
@@ -12,7 +12,7 @@ class ShowAccessoryTest extends TestCase
public function testRequiresPermissionToViewAccessory()
{
$this->actingAs(User::factory()->create())
- ->get(route('accessories.show', Accessory::factory()->create()->id))
+ ->get(route('accessories.show', Accessory::factory()->create()))
->assertForbidden();
}
@@ -25,8 +25,8 @@ class ShowAccessoryTest extends TestCase
$userForCompanyB = User::factory()->for($companyB)->viewAccessories()->create();
$this->actingAs($userForCompanyB)
- ->get(route('accessories.show', $accessoryForCompanyA->id))
- ->assertForbidden();
+ ->get(route('accessories.show', $accessoryForCompanyA))
+ ->assertStatus(302);
}
public function testCanViewAccessory()
@@ -34,7 +34,7 @@ class ShowAccessoryTest extends TestCase
$accessory = Accessory::factory()->create();
$this->actingAs(User::factory()->viewAccessories()->create())
- ->get(route('accessories.show', $accessory->id))
+ ->get(route('accessories.show', $accessory))
->assertOk()
->assertViewIs('accessories.view')
->assertViewHas(['accessory' => $accessory]);
@@ -43,7 +43,7 @@ class ShowAccessoryTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('accessories.show', Accessory::factory()->create()->id))
+ ->get(route('accessories.show', Accessory::factory()->create()))
->assertOk();
}
diff --git a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php
index 1c6fe8a496..8c482b4f14 100644
--- a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php
+++ b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php
@@ -16,7 +16,7 @@ class UpdateAccessoryTest extends TestCase
public function testRequiresPermissionToSeeEditAccessoryPage()
{
$this->actingAs(User::factory()->create())
- ->get(route('accessories.edit', Accessory::factory()->create()->id))
+ ->get(route('accessories.edit', Accessory::factory()->create()))
->assertForbidden();
}
diff --git a/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php b/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php
index 8b4104adcb..739112f59e 100644
--- a/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php
+++ b/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php
@@ -11,7 +11,7 @@ class ShowAssetModelsTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('models.show', AssetModel::factory()->create()->id))
+ ->get(route('models.show', AssetModel::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php b/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php
index d0dbb2ffc0..6fdd1bbcfc 100644
--- a/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php
+++ b/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php
@@ -24,7 +24,7 @@ class UpdateAssetModelsTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('models.edit', AssetModel::factory()->create()->id))
+ ->get(route('models.edit', AssetModel::factory()->create()))
->assertOk();
}
@@ -55,15 +55,15 @@ class UpdateAssetModelsTest extends TestCase
$this->assertTrue(AssetModel::where('name', 'Test Model')->exists());
$response = $this->actingAs(User::factory()->superuser()->create())
- ->from(route('models.edit', ['model' => $model->id]))
- ->put(route('models.update', ['model' => $model]), [
+ ->from(route('models.edit', $model))
+ ->put(route('models.update', $model), [
'name' => 'Test Model Edited',
'category_id' => Category::factory()->forAccessories()->create()->id,
])
->assertSessionHasErrors(['category_type'])
->assertInvalid(['category_type'])
->assertStatus(302)
- ->assertRedirect(route('models.edit', ['model' => $model->id]));
+ ->assertRedirect(route('models.edit', $model));
$this->followRedirects($response)->assertSee(trans('general.error'));
$this->assertFalse(AssetModel::where('name', 'Test Model Edited')->exists());
diff --git a/tests/Feature/Assets/Ui/AssetLabelTest.php b/tests/Feature/Assets/Ui/AssetLabelTest.php
new file mode 100644
index 0000000000..ddf57828bf
--- /dev/null
+++ b/tests/Feature/Assets/Ui/AssetLabelTest.php
@@ -0,0 +1,36 @@
+count(20)->create();
+ $id_array = $assets->pluck('id')->toArray();
+
+ $this->actingAs(User::factory()->viewAssets()->create())->post('/hardware/bulkedit', [
+ 'ids' => $id_array,
+ 'bulk_actions' => 'labels',
+ ])->assertStatus(200);
+ }
+
+ public function testRedirectOfNoAssetsSelected()
+ {
+ $id_array = [];
+ $this->actingAs(User::factory()->viewAssets()->create())
+ ->from(route('hardware.index'))
+ ->post('/hardware/bulkedit', [
+ 'ids' => $id_array,
+ 'bulk_actions' => 'Labels',
+ ])->assertStatus(302)
+ ->assertRedirect(route('hardware.index'));
+ }
+
+}
diff --git a/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php b/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
index d1375c5393..38c69f3b99 100644
--- a/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
+++ b/tests/Feature/Assets/Ui/BulkDeleteAssetsTest.php
@@ -162,5 +162,28 @@ class BulkDeleteAssetsTest extends TestCase
);
}
+ public function testBulkDeleteAssignedAssetTriggersError(){
+ $user = User::factory()->viewAssets()->deleteAssets()->editAssets()->create();
+ $asset = Asset::factory()->create([
+ 'id' => 5,
+ 'assigned_to' => $user->id,
+ 'asset_tag' => '12345',
+ ]);
+
+ $response = $this->actingAs($user)
+ ->from(route('hardware/bulkedit'))
+ ->post('/hardware/bulkdelete', [
+ 'ids' => [$asset->id],
+ 'bulk_actions' => 'delete',
+ ]);
+
+ $this->assertEquals(302, $response->getStatusCode());
+ $this->assertEquals(route('hardware.index'), $response->headers->get('Location'));
+
+
+ $errorMessage = session('error');
+ $expectedMessage = trans_choice('admin/hardware/message.delete.assigned_to_error',1, ['asset_tag' => $asset->asset_tag]);
+ $this->assertEquals($expectedMessage, $errorMessage);
+ }
}
diff --git a/tests/Feature/Assets/Ui/EditAssetTest.php b/tests/Feature/Assets/Ui/EditAssetTest.php
index 27f00b5313..328067e893 100644
--- a/tests/Feature/Assets/Ui/EditAssetTest.php
+++ b/tests/Feature/Assets/Ui/EditAssetTest.php
@@ -27,7 +27,7 @@ class EditAssetTest extends TestCase
{
$asset = Asset::factory()->create();
$user = User::factory()->editAssets()->create();
- $response = $this->actingAs($user)->get(route('hardware.edit', $asset->id));
+ $response = $this->actingAs($user)->get(route('hardware.edit', $asset));
$response->assertStatus(200);
}
@@ -63,7 +63,7 @@ class EditAssetTest extends TestCase
'model_id' => AssetModel::factory()->create()->id,
])
->assertStatus(302)
- ->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
$this->assertDatabaseHas('assets', ['asset_tag' => 'New Asset Tag']);
}
@@ -81,8 +81,8 @@ class EditAssetTest extends TestCase
$currentTimestamp = now();
$this->actingAs(User::factory()->viewAssets()->editAssets()->create())
- ->from(route('hardware.edit', $asset->id))
- ->put(route('hardware.update', $asset->id), [
+ ->from(route('hardware.edit', $asset))
+ ->put(route('hardware.update', $asset), [
'status_id' => $achived_status->id,
'model_id' => $asset->model_id,
'asset_tags' => $asset->asset_tag,
diff --git a/tests/Feature/Assets/Ui/ShowAssetTest.php b/tests/Feature/Assets/Ui/ShowAssetTest.php
new file mode 100644
index 0000000000..23b6c8f31e
--- /dev/null
+++ b/tests/Feature/Assets/Ui/ShowAssetTest.php
@@ -0,0 +1,26 @@
+create();
+
+ $asset->model_id = null;
+ $asset->forceSave();
+
+ $asset->refresh();
+
+ $this->assertNull($asset->fresh()->model_id, 'This test needs model_id to be null to be helpful.');
+
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('hardware.show', $asset))
+ ->assertOk();
+ }
+}
diff --git a/tests/Feature/Categories/Api/CreateCategoriesTest.php b/tests/Feature/Categories/Api/CreateCategoriesTest.php
index fc464242af..2a4a0661a6 100644
--- a/tests/Feature/Categories/Api/CreateCategoriesTest.php
+++ b/tests/Feature/Categories/Api/CreateCategoriesTest.php
@@ -27,6 +27,7 @@ class CreateCategoriesTest extends TestCase
'name' => 'Test Category',
'eula_text' => 'Test EULA',
'category_type' => 'accessory',
+ 'notes' => 'Test Note',
])
->assertOk()
->assertStatusMessageIs('success')
@@ -38,6 +39,7 @@ class CreateCategoriesTest extends TestCase
$category = Category::find($response['payload']['id']);
$this->assertEquals('Test Category', $category->name);
$this->assertEquals('Test EULA', $category->eula_text);
+ $this->assertEquals('Test Note', $category->notes);
$this->assertEquals('accessory', $category->category_type);
}
diff --git a/tests/Feature/Categories/Api/UpdateCategoriesTest.php b/tests/Feature/Categories/Api/UpdateCategoriesTest.php
index 1a784c1179..6d6bc8da10 100644
--- a/tests/Feature/Categories/Api/UpdateCategoriesTest.php
+++ b/tests/Feature/Categories/Api/UpdateCategoriesTest.php
@@ -17,6 +17,7 @@ class UpdateCategoriesTest extends TestCase
->patchJson(route('api.categories.update', $category), [
'name' => 'Test Category',
'eula_text' => 'Test EULA',
+ 'notes' => 'Test Note',
])
->assertOk()
->assertStatusMessageIs('success')
@@ -27,6 +28,7 @@ class UpdateCategoriesTest extends TestCase
$category->refresh();
$this->assertEquals('Test Category', $category->name, 'Name was not updated');
$this->assertEquals('Test EULA', $category->eula_text, 'EULA was not updated');
+ $this->assertEquals('Test Note', $category->notes, 'Note was not updated');
}
@@ -39,6 +41,7 @@ class UpdateCategoriesTest extends TestCase
'name' => 'Test Category',
'eula_text' => 'Test EULA',
'category_type' => 'accessory',
+ 'note' => 'Test Note',
])
->assertOk()
->assertStatusMessageIs('error')
@@ -48,6 +51,7 @@ class UpdateCategoriesTest extends TestCase
$category->refresh();
$this->assertNotEquals('Test Category', $category->name, 'Name was not updated');
$this->assertNotEquals('Test EULA', $category->eula_text, 'EULA was not updated');
+ $this->assertNotEquals('Test Note', $category->notes, 'Note was not updated');
$this->assertNotEquals('accessory', $category->category_type, 'EULA was not updated');
}
diff --git a/tests/Feature/Categories/Ui/CreateCategoriesTest.php b/tests/Feature/Categories/Ui/CreateCategoriesTest.php
index 45e821d9d9..694b61c613 100644
--- a/tests/Feature/Categories/Ui/CreateCategoriesTest.php
+++ b/tests/Feature/Categories/Ui/CreateCategoriesTest.php
@@ -33,11 +33,12 @@ class CreateCategoriesTest extends TestCase
$this->actingAs(User::factory()->superuser()->create())
->post(route('categories.store'), [
'name' => 'Test Category',
- 'category_type' => 'asset'
+ 'category_type' => 'asset',
+ 'notes' => 'Test Note',
])
->assertRedirect(route('categories.index'));
- $this->assertTrue(Category::where('name', 'Test Category')->exists());
+ $this->assertTrue(Category::where('name', 'Test Category')->where('notes', 'Test Note')->exists());
}
public function testUserCannotCreateCategoriesWithInvalidType()
@@ -48,7 +49,7 @@ class CreateCategoriesTest extends TestCase
->from(route('categories.create'))
->post(route('categories.store'), [
'name' => 'Test Category',
- 'category_type' => 'invalid'
+ 'category_type' => 'invalid',
])
->assertRedirect(route('categories.create'));
diff --git a/tests/Feature/Categories/Ui/ShowCategoryTest.php b/tests/Feature/Categories/Ui/ShowCategoryTest.php
index dd22b1d751..93a9cc0af2 100644
--- a/tests/Feature/Categories/Ui/ShowCategoryTest.php
+++ b/tests/Feature/Categories/Ui/ShowCategoryTest.php
@@ -11,7 +11,7 @@ class ShowCategoryTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('categories.show', Category::factory()->create()->id))
+ ->get(route('categories.show', Category::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Categories/Ui/UpdateCategoriesTest.php b/tests/Feature/Categories/Ui/UpdateCategoriesTest.php
index 901b779582..ea5cc63388 100644
--- a/tests/Feature/Categories/Ui/UpdateCategoriesTest.php
+++ b/tests/Feature/Categories/Ui/UpdateCategoriesTest.php
@@ -23,7 +23,7 @@ class UpdateCategoriesTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('categories.edit', Category::factory()->create()->id))
+ ->get(route('categories.edit', Category::factory()->create()))
->assertOk();
}
@@ -32,7 +32,7 @@ class UpdateCategoriesTest extends TestCase
$this->actingAs(User::factory()->superuser()->create())
->post(route('categories.store'), [
'name' => 'Test Category',
- 'category_type' => 'asset'
+ 'category_type' => 'asset',
])
->assertStatus(302)
->assertSessionHasNoErrors()
@@ -47,15 +47,16 @@ class UpdateCategoriesTest extends TestCase
$this->assertTrue(Category::where('name', 'Test Category')->exists());
$response = $this->actingAs(User::factory()->superuser()->create())
- ->put(route('categories.update', ['category' => $category]), [
+ ->put(route('categories.update', $category), [
'name' => 'Test Category Edited',
+ 'notes' => 'Test Note Edited',
])
->assertStatus(302)
->assertSessionHasNoErrors()
->assertRedirect(route('categories.index'));
$this->followRedirects($response)->assertSee('Success');
- $this->assertTrue(Category::where('name', 'Test Category Edited')->exists());
+ $this->assertTrue(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
}
@@ -65,17 +66,18 @@ class UpdateCategoriesTest extends TestCase
$this->assertTrue(Category::where('name', 'Test Category')->exists());
$response = $this->actingAs(User::factory()->superuser()->create())
- ->from(route('categories.edit', ['category' => $category->id]))
- ->put(route('categories.update', ['category' => $category]), [
+ ->from(route('categories.edit', $category->id))
+ ->put(route('categories.update', $category), [
'name' => 'Test Category Edited',
'category_type' => 'accessory',
+ 'notes' => 'Test Note Edited',
])
->assertSessionHasNoErrors()
->assertStatus(302)
->assertRedirect(route('categories.index'));
$this->followRedirects($response)->assertSee('Success');
- $this->assertTrue(Category::where('name', 'Test Category Edited')->exists());
+ $this->assertTrue(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
}
@@ -85,18 +87,19 @@ class UpdateCategoriesTest extends TestCase
$category = Category::where('name', 'Laptops')->first();
$response = $this->actingAs(User::factory()->superuser()->create())
- ->from(route('categories.edit', ['category' => $category->id]))
- ->put(route('categories.update', ['category' => $category]), [
+ ->from(route('categories.edit', $category))
+ ->put(route('categories.update', $category), [
'name' => 'Test Category Edited',
'category_type' => 'accessory',
+ 'notes' => 'Test Note Edited',
])
->assertSessionHasErrors(['category_type'])
->assertInvalid(['category_type'])
->assertStatus(302)
- ->assertRedirect(route('categories.edit', ['category' => $category->id]));
+ ->assertRedirect(route('categories.edit', $category));
$this->followRedirects($response)->assertSee(trans('general.error'));
- $this->assertFalse(Category::where('name', 'Test Category Edited')->exists());
+ $this->assertFalse(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists());
}
diff --git a/tests/Feature/Checkins/Ui/AssetCheckinTest.php b/tests/Feature/Checkins/Ui/AssetCheckinTest.php
index 7428b7ab74..9c7b371e2b 100644
--- a/tests/Feature/Checkins/Ui/AssetCheckinTest.php
+++ b/tests/Feature/Checkins/Ui/AssetCheckinTest.php
@@ -18,16 +18,14 @@ class AssetCheckinTest extends TestCase
public function testCheckingInAssetRequiresCorrectPermission()
{
$this->actingAs(User::factory()->create())
- ->post(route('hardware.checkin.store', [
- 'assetId' => Asset::factory()->assignedToUser()->create()->id,
- ]))
+ ->post(route('hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]))
->assertForbidden();
}
public function testCannotCheckInAssetThatIsNotCheckedOut()
{
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
+ ->post(route('hardware.checkin.store', [Asset::factory()->create()]))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.index'));
@@ -36,7 +34,7 @@ class AssetCheckinTest extends TestCase
public function testCannotStoreAssetCheckinThatIsNotCheckedOut()
{
$this->actingAs(User::factory()->checkinAssets()->create())
- ->get(route('hardware.checkin.store', ['assetId' => Asset::factory()->create()->id]))
+ ->get(route('hardware.checkin.store', [Asset::factory()->create()]))
->assertStatus(302)
->assertSessionHas('error')
->assertRedirect(route('hardware.index'));
@@ -68,7 +66,7 @@ class AssetCheckinTest extends TestCase
$this->actingAs(User::factory()->checkinAssets()->create())
->post(
- route('hardware.checkin.store', ['assetId' => $asset->id]),
+ route('hardware.checkin.store', [$asset]),
[
'name' => 'Changed Name',
'status_id' => $status->id,
@@ -101,7 +99,7 @@ class AssetCheckinTest extends TestCase
]);
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
+ ->post(route('hardware.checkin.store', [$asset]));
$this->assertTrue($asset->refresh()->location()->is($rtdLocation));
}
@@ -112,7 +110,7 @@ class AssetCheckinTest extends TestCase
$asset = Asset::factory()->assignedToUser()->create();
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]), [
+ ->post(route('hardware.checkin.store', [$asset]), [
'location_id' => $location->id,
'update_default_location' => 0
]);
@@ -128,7 +126,7 @@ class AssetCheckinTest extends TestCase
$this->assertNotNull($asset->licenseseats->first()->assigned_to);
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
+ ->post(route('hardware.checkin.store', [$asset]));
$this->assertNull($asset->refresh()->licenseseats->first()->assigned_to);
}
@@ -141,7 +139,7 @@ class AssetCheckinTest extends TestCase
]);
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
+ ->post(route('hardware.checkin.store', [$asset]));
$this->assertNull($asset->refresh()->rtd_location_id);
$this->assertEquals($asset->location_id, $asset->rtd_location_id);
@@ -154,7 +152,7 @@ class AssetCheckinTest extends TestCase
$acceptance = CheckoutAcceptance::factory()->for($asset, 'checkoutable')->pending()->create();
$this->actingAs(User::factory()->checkinAssets()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]));
+ ->post(route('hardware.checkin.store', [$asset]));
$this->assertFalse($acceptance->exists(), 'Acceptance was not deleted');
}
@@ -165,8 +163,7 @@ class AssetCheckinTest extends TestCase
$this->actingAs(User::factory()->checkinAssets()->create())
->post(route(
- 'hardware.checkin.store',
- ['assetId' => Asset::factory()->assignedToUser()->create()->id]
+ 'hardware.checkin.store', [Asset::factory()->assignedToUser()->create()]
), [
'checkin_at' => '2023-01-02',
'note' => 'hello'
@@ -185,10 +182,10 @@ class AssetCheckinTest extends TestCase
$asset->forceSave();
$this->actingAs(User::factory()->admin()->create())
- ->get(route('hardware.checkin.create', ['assetId' => $asset->id]))
+ ->get(route('hardware.checkin.create', [$asset]))
->assertStatus(302)
->assertSessionHas('error')
- ->assertRedirect(route('hardware.show',['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid()
@@ -198,10 +195,10 @@ class AssetCheckinTest extends TestCase
$asset->forceSave();
$this->actingAs(User::factory()->admin()->create())
- ->post(route('hardware.checkin.store', ['assetId' => $asset->id]))
+ ->post(route('hardware.checkin.store', $asset))
->assertStatus(302)
->assertSessionHas('error')
- ->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
public function testAssetCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex()
@@ -228,6 +225,6 @@ class AssetCheckinTest extends TestCase
])
->assertStatus(302)
->assertSessionHasNoErrors()
- ->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
}
diff --git a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php
index 6c2ef084fc..7da3879ea7 100644
--- a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php
+++ b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php
@@ -16,9 +16,7 @@ class ComponentCheckinTest extends TestCase
$componentAsset = DB::table('components_assets')->where('component_id', $component->id)->first();
$this->actingAs(User::factory()->create())
- ->post(route('components.checkin.store', [
- 'componentID' => $componentAsset->id,
- ]))
+ ->post(route('components.checkin.store', $componentAsset->id))
->assertForbidden();
}
@@ -67,6 +65,6 @@ class ComponentCheckinTest extends TestCase
])
->assertStatus(302)
->assertSessionHasNoErrors()
- ->assertRedirect(route('components.show', ['component' => $component->id]));
+ ->assertRedirect(route('components.show', $component));
}
}
diff --git a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php
index ff121bc4de..19b0d1ce72 100644
--- a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php
@@ -25,7 +25,7 @@ class AccessoryCheckoutTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('accessories.checkout.show', Accessory::factory()->create()->id))
+ ->get(route('accessories.checkout.show', Accessory::factory()->create()))
->assertOk();
}
@@ -241,7 +241,7 @@ class AccessoryCheckoutTest extends TestCase
])
->assertStatus(302)
->assertSessionHasNoErrors()
- ->assertRedirect(route('accessories.show', ['accessory' => $accessory->id]));
+ ->assertRedirect(route('accessories.show', $accessory));
}
public function testAccessoryCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
@@ -258,6 +258,6 @@ class AccessoryCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('users.show', ['user' => $user]));
+ ->assertRedirect(route('users.show', $user));
}
}
diff --git a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php
index 74658a6fa3..f364064a1d 100644
--- a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php
@@ -260,10 +260,10 @@ class AssetCheckoutTest extends TestCase
$asset->forceSave();
$this->actingAs(User::factory()->admin()->create())
- ->get(route('hardware.checkout.create', ['assetId' => $asset->id]))
+ ->get(route('hardware.checkout.create', $asset))
->assertStatus(302)
->assertSessionHas('error')
- ->assertRedirect(route('hardware.show',['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
@@ -294,7 +294,7 @@ class AssetCheckoutTest extends TestCase
])
->assertStatus(302)
->assertSessionHasNoErrors()
- ->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget()
@@ -328,7 +328,7 @@ class AssetCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('hardware.show', ['hardware' => $target]));
+ ->assertRedirect(route('hardware.show', $target));
}
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsLocationTarget()
diff --git a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
index 507b26243f..18568d1985 100644
--- a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php
@@ -76,7 +76,7 @@ class ComponentsCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('components.show', ['component' => $component->id]));
+ ->assertRedirect(route('components.show', $component));
}
public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
@@ -92,6 +92,6 @@ class ComponentsCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('hardware.show', ['hardware' => $asset]));
+ ->assertRedirect(route('hardware.show', $asset));
}
}
diff --git a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php
index dd77e19c5d..2c74e4d0cb 100644
--- a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php
@@ -130,7 +130,7 @@ class ConsumableCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('consumables.show', ['consumable' => $consumable->id]));
+ ->assertRedirect(route('consumables.show', $consumable));
}
public function testConsumableCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget()
@@ -146,7 +146,7 @@ class ConsumableCheckoutTest extends TestCase
'assigned_qty' => 1,
])
->assertStatus(302)
- ->assertRedirect(route('users.show', ['user' => $user]));
+ ->assertRedirect(route('users.show', $user));
}
}
diff --git a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php
index 22bdb6b5db..1750b75647 100644
--- a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php
+++ b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php
@@ -24,7 +24,7 @@ class LicenseCheckoutTest extends TestCase
$licenseSeat = LicenseSeat::factory()->create();
$this->actingAs($admin)
- ->post("/licenses/{$licenseSeat->license->id}/checkout", [
+ ->post(route('licenses.checkout', $licenseSeat->license), [
'checkout_to_type' => 'asset',
'assigned_to' => null,
'asset_id' => $asset->id,
@@ -47,7 +47,7 @@ class LicenseCheckoutTest extends TestCase
$licenseSeat = LicenseSeat::factory()->create();
$this->actingAs($admin)
- ->post("/licenses/{$licenseSeat->license->id}/checkout", [
+ ->post(route('licenses.checkout', $licenseSeat->license), [
'checkout_to_type' => 'user',
'assigned_to' => $admin->id,
'asset_id' => null,
@@ -69,8 +69,8 @@ class LicenseCheckoutTest extends TestCase
$license = License::factory()->create();
$this->actingAs(User::factory()->admin()->create())
- ->from(route('licenses.checkout', ['licenseId' => $license->id]))
- ->post(route('licenses.checkout', ['licenseId' => $license->id]), [
+ ->from(route('licenses.checkout', $license))
+ ->post(route('licenses.checkout', $license), [
'assigned_to' => User::factory()->create()->id,
'redirect_option' => 'index',
'assigned_qty' => 1,
@@ -84,13 +84,13 @@ class LicenseCheckoutTest extends TestCase
$license = License::factory()->create();
$this->actingAs(User::factory()->admin()->create())
- ->from(route('licenses.checkout', ['licenseId' => $license->id]))
- ->post(route('licenses.checkout' , ['licenseId' => $license->id]), [
+ ->from(route('licenses.checkout', $license))
+ ->post(route('licenses.checkout', $license), [
'assigned_to' => User::factory()->create()->id,
'redirect_option' => 'item',
])
->assertStatus(302)
- ->assertRedirect(route('licenses.show', ['license' => $license->id]));
+ ->assertRedirect(route('licenses.show', $license));
}
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget()
@@ -99,13 +99,13 @@ class LicenseCheckoutTest extends TestCase
$license = License::factory()->create();
$this->actingAs(User::factory()->admin()->create())
- ->from(route('licenses.checkout', ['licenseId' => $license->id]))
+ ->from(route('licenses.checkout', $license))
->post(route('licenses.checkout' , $license), [
'assigned_to' => $user->id,
'redirect_option' => 'target',
])
->assertStatus(302)
- ->assertRedirect(route('users.show', ['user' => $user->id]));
+ ->assertRedirect(route('users.show', $user));
}
public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsAssetTarget()
{
@@ -113,12 +113,12 @@ class LicenseCheckoutTest extends TestCase
$license = License::factory()->create();
$this->actingAs(User::factory()->admin()->create())
- ->from(route('licenses.checkout', ['licenseId' => $license->id]))
+ ->from(route('licenses.checkout', $license))
->post(route('licenses.checkout' , $license), [
'asset_id' => $asset->id,
'redirect_option' => 'target',
])
->assertStatus(302)
- ->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
+ ->assertRedirect(route('hardware.show', $asset));
}
}
diff --git a/tests/Feature/Companies/Ui/EditCompanyTest.php b/tests/Feature/Companies/Ui/EditCompanyTest.php
index 7dcbc7908a..febc717045 100644
--- a/tests/Feature/Companies/Ui/EditCompanyTest.php
+++ b/tests/Feature/Companies/Ui/EditCompanyTest.php
@@ -11,7 +11,7 @@ class EditCompanyTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('companies.edit', Company::factory()->create()->id))
+ ->get(route('companies.edit', Company::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Companies/Ui/ShowCompanyTest.php b/tests/Feature/Companies/Ui/ShowCompanyTest.php
index 1c41f6ab2b..de7429d40e 100644
--- a/tests/Feature/Companies/Ui/ShowCompanyTest.php
+++ b/tests/Feature/Companies/Ui/ShowCompanyTest.php
@@ -11,7 +11,7 @@ class ShowCompanyTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('companies.show', Company::factory()->create()->id))
+ ->get(route('companies.show', Company::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Components/Api/DeleteComponentsTest.php b/tests/Feature/Components/Api/DeleteComponentTest.php
similarity index 83%
rename from tests/Feature/Components/Api/DeleteComponentsTest.php
rename to tests/Feature/Components/Api/DeleteComponentTest.php
index e95fe34559..80d22d389e 100644
--- a/tests/Feature/Components/Api/DeleteComponentsTest.php
+++ b/tests/Feature/Components/Api/DeleteComponentTest.php
@@ -9,7 +9,7 @@ use Tests\Concerns\TestsFullMultipleCompaniesSupport;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
-class DeleteComponentsTest extends TestCase implements TestsFullMultipleCompaniesSupport, TestsPermissionsRequirement
+class DeleteComponentTest extends TestCase implements TestsFullMultipleCompaniesSupport, TestsPermissionsRequirement
{
public function testRequiresPermission()
{
@@ -63,4 +63,13 @@ class DeleteComponentsTest extends TestCase implements TestsFullMultipleCompanie
$this->assertSoftDeleted($component);
}
+
+ public function testCannotDeleteComponentIfCheckedOut()
+ {
+ $component = Component::factory()->checkedOutToAsset()->create();
+
+ $this->actingAsForApi(User::factory()->deleteComponents()->create())
+ ->deleteJson(route('api.components.destroy', $component))
+ ->assertStatusMessageIs('error');
+ }
}
diff --git a/tests/Feature/Components/Ui/DeleteComponentTest.php b/tests/Feature/Components/Ui/DeleteComponentTest.php
index a0b8131532..31d62f65dd 100644
--- a/tests/Feature/Components/Ui/DeleteComponentTest.php
+++ b/tests/Feature/Components/Ui/DeleteComponentTest.php
@@ -40,6 +40,16 @@ class DeleteComponentTest extends TestCase implements TestsFullMultipleCompanies
$this->assertSoftDeleted($component);
}
+ public function testCannotDeleteComponentIfCheckedOut()
+ {
+ $component = Component::factory()->checkedOutToAsset()->create();
+
+ $this->actingAs(User::factory()->deleteComponents()->create())
+ ->delete(route('components.destroy', $component->id))
+ ->assertSessionHas('error')
+ ->assertRedirect(route('components.index'));
+ }
+
public function testDeletingComponentRemovesComponentImage()
{
Storage::fake('public');
diff --git a/tests/Feature/Components/Ui/EditComponentTest.php b/tests/Feature/Components/Ui/EditComponentTest.php
index 2570343907..4e4b992330 100644
--- a/tests/Feature/Components/Ui/EditComponentTest.php
+++ b/tests/Feature/Components/Ui/EditComponentTest.php
@@ -11,7 +11,7 @@ class EditComponentTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('components.edit', Component::factory()->create()->id))
+ ->get(route('components.edit', Component::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Components/Ui/ShowComponentTest.php b/tests/Feature/Components/Ui/ShowComponentTest.php
index 50a17ee059..6ee2ca2863 100644
--- a/tests/Feature/Components/Ui/ShowComponentTest.php
+++ b/tests/Feature/Components/Ui/ShowComponentTest.php
@@ -11,7 +11,7 @@ class ShowComponentTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('components.show', Component::factory()->create()->id))
+ ->get(route('components.show', Component::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Console/SendAcceptanceReminderTest.php b/tests/Feature/Console/SendAcceptanceReminderTest.php
index 9743a9db49..ee28e09355 100644
--- a/tests/Feature/Console/SendAcceptanceReminderTest.php
+++ b/tests/Feature/Console/SendAcceptanceReminderTest.php
@@ -43,9 +43,13 @@ class SendAcceptanceReminderTest extends TestCase
CheckoutAcceptance::factory()->pending()->create([
'assigned_to_id' => $userA->id,
]);
-
+ $headers = ['ID', 'Name'];
+ $rows = [
+ [$userA->id, $userA->present()->fullName()],
+ ];
$this->artisan('snipeit:acceptance-reminder')
- ->expectsOutput($userA->present()->fullName().' has no email address.')
+ ->expectsOutput("The following users do not have an email address:")
+ ->expectsTable($headers, $rows)
->assertExitCode(0);
Mail::assertNotSent(UnacceptedAssetReminderMail::class);
diff --git a/tests/Feature/Consumables/Ui/EditConsumableTest.php b/tests/Feature/Consumables/Ui/EditConsumableTest.php
index 6b75db127f..308b7647b6 100644
--- a/tests/Feature/Consumables/Ui/EditConsumableTest.php
+++ b/tests/Feature/Consumables/Ui/EditConsumableTest.php
@@ -11,7 +11,7 @@ class EditConsumableTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('consumables.show', Consumable::factory()->create()->id))
+ ->get(route('consumables.show', Consumable::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php
index 66fc9a11f3..dbb13b9ce7 100644
--- a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php
+++ b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php
@@ -29,7 +29,7 @@ class UpdateConsumableTest extends TestCase
$userForCompanyB = User::factory()->editConsumables()->for($companyB)->create();
$this->actingAs($userForCompanyB)
- ->get(route('consumables.edit', $consumableForCompanyA->id))
+ ->get(route('consumables.edit', $consumableForCompanyA))
->assertRedirect(route('consumables.index'));
}
@@ -51,10 +51,10 @@ class UpdateConsumableTest extends TestCase
$userForCompanyB = User::factory()->editConsumables()->for($companyB)->create();
$this->actingAs($userForCompanyB)
- ->put(route('consumables.update', $consumableForCompanyA->id), [
+ ->put(route('consumables.update', $consumableForCompanyA), [
//
])
- ->assertForbidden();
+ ->assertStatus(302);
}
public function testCannotSetQuantityToAmountLowerThanWhatIsCheckedOut()
@@ -99,7 +99,7 @@ class UpdateConsumableTest extends TestCase
];
$this->actingAs(User::factory()->createConsumables()->editConsumables()->create())
- ->put(route('consumables.update', $consumable->id), $data + [
+ ->put(route('consumables.update', $consumable), $data + [
'redirect_option' => 'index',
'category_type' => 'consumable',
])
diff --git a/tests/Feature/Departments/Api/CreateDepartmentsTest.php b/tests/Feature/Departments/Api/CreateDepartmentsTest.php
index a8725c5ff2..e0f975dd7f 100644
--- a/tests/Feature/Departments/Api/CreateDepartmentsTest.php
+++ b/tests/Feature/Departments/Api/CreateDepartmentsTest.php
@@ -20,4 +20,23 @@ class CreateDepartmentsTest extends TestCase
->assertForbidden();
}
+ public function testCanCreateDepartment()
+ {
+ $response = $this->actingAsForApi(User::factory()->superuser()->create())
+ ->postJson(route('api.departments.store'), [
+ 'name' => 'Test Department',
+ 'notes' => 'Test Note',
+ ])
+ ->assertOk()
+ ->assertStatusMessageIs('success')
+ ->assertStatus(200)
+ ->json();
+
+ $this->assertTrue(Department::where('name', 'Test Department')->exists());
+
+ $department = Department::find($response['payload']['id']);
+ $this->assertEquals('Test Department', $department->name);
+ $this->assertEquals('Test Note', $department->notes);
+ }
+
}
diff --git a/tests/Feature/Departments/Api/UpdateDepartmentsTest.php b/tests/Feature/Departments/Api/UpdateDepartmentsTest.php
index 2a6401e7f1..b4eb38301a 100644
--- a/tests/Feature/Departments/Api/UpdateDepartmentsTest.php
+++ b/tests/Feature/Departments/Api/UpdateDepartmentsTest.php
@@ -25,6 +25,7 @@ class UpdateDepartmentsTest extends TestCase
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.departments.update', $department), [
'name' => 'Test Department',
+ 'notes' => 'Test Note',
])
->assertOk()
->assertStatusMessageIs('success')
@@ -33,6 +34,7 @@ class UpdateDepartmentsTest extends TestCase
$department->refresh();
$this->assertEquals('Test Department', $department->name, 'Name was not updated');
+ $this->assertEquals('Test Note', $department->notes, 'Note was not updated');
}
diff --git a/tests/Feature/Departments/Ui/CreateDepartmentsTest.php b/tests/Feature/Departments/Ui/CreateDepartmentsTest.php
index 08dc12ba09..f20a2c7b6a 100644
--- a/tests/Feature/Departments/Ui/CreateDepartmentsTest.php
+++ b/tests/Feature/Departments/Ui/CreateDepartmentsTest.php
@@ -34,11 +34,12 @@ class CreateDepartmentsTest extends TestCase
$this->actingAs(User::factory()->superuser()->create())
->post(route('departments.store'), [
'name' => 'Test Department',
- 'company_id' => Company::factory()->create()->id
+ 'company_id' => Company::factory()->create()->id,
+ 'notes' => 'Test Note',
])
->assertRedirect(route('departments.index'));
- $this->assertTrue(Department::where('name', 'Test Department')->exists());
+ $this->assertTrue(Department::where('name', 'Test Department')->where('notes', 'Test Note')->exists());
}
diff --git a/tests/Feature/Departments/Ui/ShowDepartmentTest.php b/tests/Feature/Departments/Ui/ShowDepartmentTest.php
index d8a007bde3..f1373ccc2a 100644
--- a/tests/Feature/Departments/Ui/ShowDepartmentTest.php
+++ b/tests/Feature/Departments/Ui/ShowDepartmentTest.php
@@ -11,7 +11,7 @@ class ShowDepartmentTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('departments.show', Department::factory()->create()->id))
+ ->get(route('departments.show', Department::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php b/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php
index 71f7cfe477..83e52bf7c0 100644
--- a/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php
+++ b/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php
@@ -22,7 +22,7 @@ class UpdateDepartmentsTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('departments.edit', Department::factory()->create()->id))
+ ->get(route('departments.edit', Department::factory()->create()))
->assertOk();
}
@@ -32,15 +32,16 @@ class UpdateDepartmentsTest extends TestCase
$this->assertTrue(Department::where('name', 'Test Department')->exists());
$response = $this->actingAs(User::factory()->superuser()->create())
- ->put(route('departments.update', ['department' => $department]), [
+ ->put(route('departments.update', $department), [
'name' => 'Test Department Edited',
+ 'notes' => 'Test Note Edited',
])
->assertStatus(302)
->assertSessionHasNoErrors()
->assertRedirect(route('departments.index'));
$this->followRedirects($response)->assertSee('Success');
- $this->assertTrue(Department::where('name', 'Test Department Edited')->exists());
+ $this->assertTrue(Department::where('name', 'Test Department Edited')->where('notes', 'Test Note Edited')->exists());
}
diff --git a/tests/Feature/Groups/Api/StoreGroupTest.php b/tests/Feature/Groups/Api/StoreGroupTest.php
index ebcbff71c5..484c921a6c 100644
--- a/tests/Feature/Groups/Api/StoreGroupTest.php
+++ b/tests/Feature/Groups/Api/StoreGroupTest.php
@@ -21,6 +21,7 @@ class StoreGroupTest extends TestCase
$this->actingAsForApi(User::factory()->superuser()->create())
->postJson(route('api.groups.store'), [
'name' => 'My Awesome Group',
+ 'notes' => 'My Awesome Note',
'permissions' => [
'admin' => '1',
'import' => '1',
@@ -29,7 +30,7 @@ class StoreGroupTest extends TestCase
])
->assertOk();
- $group = Group::where('name', 'My Awesome Group')->first();
+ $group = Group::where('name', 'My Awesome Group')->where('notes', 'My Awesome Note')->first();
$this->assertNotNull($group);
$this->assertEquals('1', $group->decodePermissions()['admin']);
diff --git a/tests/Feature/Groups/Ui/CreateGroupTest.php b/tests/Feature/Groups/Ui/CreateGroupTest.php
index 56b3a76053..796905c50f 100644
--- a/tests/Feature/Groups/Ui/CreateGroupTest.php
+++ b/tests/Feature/Groups/Ui/CreateGroupTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Groups\Ui;
+use App\Models\Group;
use App\Models\User;
use Tests\TestCase;
@@ -13,4 +14,18 @@ class CreateGroupTest extends TestCase
->get(route('groups.create'))
->assertOk();
}
+
+ public function testUserCanCreateGroup()
+ {
+ $this->assertFalse(Group::where('name', 'Test Group')->exists());
+
+ $this->actingAs(User::factory()->superuser()->create())
+ ->post(route('groups.store'), [
+ 'name' => 'Test Group',
+ 'notes' => 'Test Note',
+ ])
+ ->assertRedirect(route('groups.index'));
+
+ $this->assertTrue(Group::where('name', 'Test Group')->where('notes', 'Test Note')->exists());
+ }
}
diff --git a/tests/Feature/Groups/Ui/UpdateGroupTest.php b/tests/Feature/Groups/Ui/UpdateGroupTest.php
index c68d7cb84b..edb2368726 100644
--- a/tests/Feature/Groups/Ui/UpdateGroupTest.php
+++ b/tests/Feature/Groups/Ui/UpdateGroupTest.php
@@ -14,4 +14,22 @@ class UpdateGroupTest extends TestCase
->get(route('groups.edit', Group::factory()->create()->id))
->assertOk();
}
+
+ public function testUserCanEditGroups()
+ {
+ $group = Group::factory()->create(['name' => 'Test Group']);
+ $this->assertTrue(Group::where('name', 'Test Group')->exists());
+
+ $response = $this->actingAs(User::factory()->superuser()->create())
+ ->put(route('groups.update', ['group' => $group]), [
+ 'name' => 'Test Group Edited',
+ 'notes' => 'Test Note Edited',
+ ])
+ ->assertStatus(302)
+ ->assertSessionHasNoErrors()
+ ->assertRedirect(route('groups.index'));
+
+ $this->followRedirects($response)->assertSee('Success');
+ $this->assertTrue(Group::where('name', 'Test Group Edited')->where('notes', 'Test Note Edited')->exists());
+ }
}
diff --git a/tests/Feature/Importing/Ui/ImportTest.php b/tests/Feature/Importing/Ui/ImportTest.php
index 2caaa4c097..b549dc415d 100644
--- a/tests/Feature/Importing/Ui/ImportTest.php
+++ b/tests/Feature/Importing/Ui/ImportTest.php
@@ -45,4 +45,24 @@ class ImportTest extends TestCase
]);
$this->assertEquals($evil_string, $results->json()['files'][0]['first_row'][0]);
}
+
+ public function testStoreInternationalAssetMisparse(): void
+ {
+ $evil_maker = function ($arr) {
+ $results = '';
+ foreach ($arr as $thing) {
+ $results .= chr($thing);
+ }
+ return $results;
+ };
+
+ // 0xC0 makes it 'not unicode', and 0xFF makes it 'likely WINDOWS-1251', and 0x98 at the end makes it 'not-valid-Windows-1251'
+ $evil_content = $evil_maker([0xC0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0x03, 0x98]);
+
+ $this->actingAsForApi(User::factory()->superuser()->create());
+ $results = $this->post(route('api.imports.store'), ['files' => [UploadedFile::fake()->createWithContent("myname.csv", $evil_content)]])
+ ->assertStatus(422)
+ ->assertStatusMessageIs('error')
+ ->assertMessagesAre(trans('admin/hardware/message.import.transliterate_failure', ["encoding" => "windows-1251"]));
+ }
}
diff --git a/tests/Feature/Licenses/Ui/UpdateLicenseTest.php b/tests/Feature/Licenses/Ui/UpdateLicenseTest.php
index c3d1446d50..7b1b5b29e3 100644
--- a/tests/Feature/Licenses/Ui/UpdateLicenseTest.php
+++ b/tests/Feature/Licenses/Ui/UpdateLicenseTest.php
@@ -11,7 +11,7 @@ class UpdateLicenseTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('licenses.update', License::factory()->create()->id))
+ ->get(route('licenses.edit', License::factory()->create()->id))
->assertOk();
}
}
diff --git a/tests/Feature/Locations/Api/CreateLocationsTest.php b/tests/Feature/Locations/Api/CreateLocationsTest.php
index 171508b725..0a75517f31 100644
--- a/tests/Feature/Locations/Api/CreateLocationsTest.php
+++ b/tests/Feature/Locations/Api/CreateLocationsTest.php
@@ -16,6 +16,26 @@ class CreateLocationsTest extends TestCase
->assertForbidden();
}
+
+ public function testCanCreateLocation()
+ {
+ $response = $this->actingAsForApi(User::factory()->superuser()->create())
+ ->postJson(route('api.locations.store'), [
+ 'name' => 'Test Location',
+ 'notes' => 'Test Note',
+ ])
+ ->assertOk()
+ ->assertStatusMessageIs('success')
+ ->assertStatus(200)
+ ->json();
+
+ $this->assertTrue(Location::where('name', 'Test Location')->exists());
+
+ $department = Location::find($response['payload']['id']);
+ $this->assertEquals('Test Location', $department->name);
+ $this->assertEquals('Test Note', $department->notes);
+ }
+
public function testCannotCreateNewLocationsWithTheSameName()
{
$location = Location::factory()->create();
diff --git a/tests/Feature/Locations/Api/UpdateLocationsTest.php b/tests/Feature/Locations/Api/UpdateLocationsTest.php
index a3dd8c228c..a169ba87bf 100644
--- a/tests/Feature/Locations/Api/UpdateLocationsTest.php
+++ b/tests/Feature/Locations/Api/UpdateLocationsTest.php
@@ -22,7 +22,8 @@ class UpdateLocationsTest extends TestCase
$this->actingAsForApi(User::factory()->superuser()->create())
->patchJson(route('api.locations.update', $location), [
- 'name' => 'Test Location',
+ 'name' => 'Test Updated Location',
+ 'notes' => 'Test Updated Note',
])
->assertOk()
->assertStatusMessageIs('success')
@@ -30,7 +31,8 @@ class UpdateLocationsTest extends TestCase
->json();
$location->refresh();
- $this->assertEquals('Test Location', $location->name, 'Name was not updated');
+ $this->assertEquals('Test Updated Location', $location->name, 'Name was not updated');
+ $this->assertEquals('Test Updated Note', $location->notes, 'Note was not updated');
}
diff --git a/tests/Feature/Locations/Ui/CreateLocationsTest.php b/tests/Feature/Locations/Ui/CreateLocationsTest.php
index 2e2e1e0aa9..794ee06c67 100644
--- a/tests/Feature/Locations/Ui/CreateLocationsTest.php
+++ b/tests/Feature/Locations/Ui/CreateLocationsTest.php
@@ -33,11 +33,11 @@ class CreateLocationsTest extends TestCase
$this->actingAs(User::factory()->superuser()->create())
->post(route('locations.store'), [
'name' => 'Test Location',
- 'company_id' => Company::factory()->create()->id
+ 'notes' => 'Test Note',
])
->assertRedirect(route('locations.index'));
- $this->assertTrue(Location::where('name', 'Test Location')->exists());
+ $this->assertTrue(Location::where('name', 'Test Location')->where('notes', 'Test Note')->exists());
}
public function testUserCannotCreateLocationsWithInvalidParent()
diff --git a/tests/Feature/Locations/Ui/ShowLocationTest.php b/tests/Feature/Locations/Ui/ShowLocationTest.php
index 6afb7dfe53..394ed73f4c 100644
--- a/tests/Feature/Locations/Ui/ShowLocationTest.php
+++ b/tests/Feature/Locations/Ui/ShowLocationTest.php
@@ -11,7 +11,7 @@ class ShowLocationTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('locations.show', Location::factory()->create()->id))
+ ->get(route('locations.show', Location::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Locations/Ui/UpdateLocationsTest.php b/tests/Feature/Locations/Ui/UpdateLocationsTest.php
index 6cead815bc..22d9ce5770 100644
--- a/tests/Feature/Locations/Ui/UpdateLocationsTest.php
+++ b/tests/Feature/Locations/Ui/UpdateLocationsTest.php
@@ -21,7 +21,7 @@ class UpdateLocationsTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('locations.update', Location::factory()->create()->id))
+ ->get(route('locations.edit', Location::factory()->create()))
->assertOk();
}
@@ -33,13 +33,14 @@ class UpdateLocationsTest extends TestCase
$response = $this->actingAs(User::factory()->superuser()->create())
->put(route('locations.update', ['location' => $location]), [
'name' => 'Test Location Edited',
+ 'notes' => 'Test Note Edited',
])
->assertStatus(302)
->assertSessionHasNoErrors()
->assertRedirect(route('locations.index'));
$this->followRedirects($response)->assertSee('Success');
- $this->assertTrue(Location::where('name', 'Test Location Edited')->exists());
+ $this->assertTrue(Location::where('name', 'Test Location Edited')->where('notes', 'Test Note Edited')->exists());
}
public function testUserCannotEditLocationsToMakeThemTheirOwnParent()
@@ -47,8 +48,8 @@ class UpdateLocationsTest extends TestCase
$location = Location::factory()->create();
$response = $this->actingAs(User::factory()->superuser()->create())
- ->from(route('locations.edit', ['location' => $location->id]))
- ->put(route('locations.update', ['location' => $location]), [
+ ->from(route('locations.edit', $location))
+ ->put(route('locations.update', $location), [
'name' => 'Test Location',
'parent_id' => $location->id,
])
@@ -62,7 +63,7 @@ class UpdateLocationsTest extends TestCase
{
$location = Location::factory()->create();
$response = $this->actingAs(User::factory()->superuser()->create())
- ->from(route('locations.edit', ['location' => $location->id]))
+ ->from(route('locations.edit', $location))
->put(route('locations.update', ['location' => $location]), [
'name' => 'Test Location',
'parent_id' => '100000000'
diff --git a/tests/Feature/Manufacturers/Api/CreateManufacturersTest.php b/tests/Feature/Manufacturers/Api/CreateManufacturersTest.php
new file mode 100644
index 0000000000..9dc953148e
--- /dev/null
+++ b/tests/Feature/Manufacturers/Api/CreateManufacturersTest.php
@@ -0,0 +1,39 @@
+actingAsForApi(User::factory()->create())
+ ->postJson(route('api.departments.store'))
+ ->assertForbidden();
+ }
+
+ public function testCanCreateManufacturer()
+ {
+ $response = $this->actingAsForApi(User::factory()->superuser()->create())
+ ->postJson(route('api.manufacturers.store'), [
+ 'name' => 'Test Manufacturer',
+ 'notes' => 'Test Note',
+ ])
+ ->assertOk()
+ ->assertStatusMessageIs('success')
+ ->assertStatus(200)
+ ->json();
+
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->where('notes', 'Test Note')->exists());
+
+ $manufacturer = Manufacturer::find($response['payload']['id']);
+ $this->assertEquals('Test Manufacturer', $manufacturer->name);
+ $this->assertEquals('Test Note', $manufacturer->notes);
+ }
+
+}
diff --git a/tests/Feature/Manufacturers/Api/UpdateManufacturersTest.php b/tests/Feature/Manufacturers/Api/UpdateManufacturersTest.php
new file mode 100644
index 0000000000..f40052f2b2
--- /dev/null
+++ b/tests/Feature/Manufacturers/Api/UpdateManufacturersTest.php
@@ -0,0 +1,50 @@
+actingAs(User::factory()->create())
+ ->post(route('manufacturers.store'), [
+ 'name' => 'Test Manufacturer',
+ ])
+ ->assertStatus(403)
+ ->assertForbidden();
+ }
+
+ public function testPageRenders()
+ {
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('manufacturers.edit', Manufacturer::factory()->create()->id))
+ ->assertOk();
+ }
+
+ public function testUserCanEditManufacturers()
+ {
+ $department = Manufacturer::factory()->create(['name' => 'Test Manufacturer']);
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->exists());
+
+ $response = $this->actingAs(User::factory()->superuser()->create())
+ ->put(route('manufacturers.update', ['manufacturer' => $department]), [
+ 'name' => 'Test Manufacturer Edited',
+ 'notes' => 'Test Note Edited',
+ ])
+ ->assertStatus(302)
+ ->assertSessionHasNoErrors()
+ ->assertRedirect(route('manufacturers.index'));
+
+ $this->followRedirects($response)->assertSee('Success');
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer Edited')->where('notes', 'Test Note Edited')->exists());
+
+ }
+
+
+
+}
diff --git a/tests/Feature/Manufacturers/Ui/CreateManufacturerTest.php b/tests/Feature/Manufacturers/Ui/CreateManufacturerTest.php
index 133b271ea3..4eb9d4fb7e 100644
--- a/tests/Feature/Manufacturers/Ui/CreateManufacturerTest.php
+++ b/tests/Feature/Manufacturers/Ui/CreateManufacturerTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Manufacturers\Ui;
use App\Models\User;
+use App\Models\Manufacturer;
use Tests\TestCase;
class CreateManufacturerTest extends TestCase
@@ -13,4 +14,19 @@ class CreateManufacturerTest extends TestCase
->get(route('manufacturers.create'))
->assertOk();
}
+
+ public function testUserCanCreateManufacturer()
+ {
+ $this->assertFalse(Manufacturer::where('name', 'Test Manufacturer')->exists());
+
+ $this->actingAs(User::factory()->superuser()->create())
+ ->post(route('manufacturers.store'), [
+ 'name' => 'Test Manufacturer',
+ 'notes' => 'Test Note',
+ ])
+ ->assertRedirect(route('manufacturers.index'));
+
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->where('notes', 'Test Note')->exists());
+ }
+
}
diff --git a/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php b/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php
index 890feb1238..9a40819a10 100644
--- a/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php
+++ b/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php
@@ -11,7 +11,7 @@ class ShowManufacturerTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('manufacturers.show', Manufacturer::factory()->create()->id))
+ ->get(route('manufacturers.show', Manufacturer::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php b/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php
index e2f7724fa3..9d5861300f 100644
--- a/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php
+++ b/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php
@@ -11,7 +11,26 @@ class UpdateManufacturerTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('manufacturers.edit', Manufacturer::factory()->create()->id))
+ ->get(route('manufacturers.edit', Manufacturer::factory()->create()))
->assertOk();
}
+
+ public function testUserCanEditManufacturers()
+ {
+ $manufacturer = Manufacturer::factory()->create(['name' => 'Test Manufacturer']);
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->exists());
+
+ $response = $this->actingAs(User::factory()->superuser()->create())
+ ->put(route('manufacturers.update', $manufacturer), [
+ 'name' => 'Test Manufacturer Edited',
+ 'notes' => 'Test Note Edited',
+ ])
+ ->assertStatus(302)
+ ->assertSessionHasNoErrors()
+ ->assertRedirect(route('manufacturers.index'));
+
+ $this->followRedirects($response)->assertSee('Success');
+ $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer Edited')->where('notes', 'Test Note Edited')->exists());
+ }
+
}
diff --git a/tests/Feature/Notes/AssetNotesTest.php b/tests/Feature/Notes/AssetNotesTest.php
deleted file mode 100644
index c666cb9e3f..0000000000
--- a/tests/Feature/Notes/AssetNotesTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-create();
-
- $this->actingAsForApi(User::factory()->create())
- ->postJson(route('api.notes.store'), [
- 'note' => 'New Note!',
- 'type' => 'asset',
- 'id' => $asset->id,
- ])
- ->assertForbidden();
- }
-
- public function testValidation()
- {
- $asset = Asset::factory()->create();
-
- $this->actingAsForApi(User::factory()->editAssets()->create())
- ->postJson(route('api.notes.store'), [
- // 'note' => '',
- 'type' => 'a_type_not_asset',
- 'id' => $asset->id,
- ])
- ->assertOk()
- ->assertStatusMessageIs('error')
- ->assertJsonValidationErrors(['note', 'type'], 'messages');
- }
-
- public function testRequiresExistingAsset()
- {
- $this->actingAsForApi(User::factory()->editAssets()->create())
- ->postJson(route('api.notes.store'), [
- 'note' => 'New Note!',
- 'type' => 'asset',
- 'id' => 999_999,
- ])
- ->assertStatusMessageIs('error')
- ->assertMessagesAre('Asset not found');
- }
-
- public function testCanAddNoteToAsset()
- {
- Event::fake([NoteAdded::class]);
-
- $asset = Asset::factory()->create();
- $user = User::factory()->editAssets()->create();
-
- $this->actingAsForApi($user)
- ->postJson(route('api.notes.store'), [
- 'note' => 'New Note!',
- 'type' => 'asset',
- 'id' => $asset->id,
- ])
- ->assertOk()
- ->assertStatusMessageIs('success');
-
- Event::assertDispatchedTimes(NoteAdded::class, 1);
- Event::assertDispatched(NoteAdded::class, function (NoteAdded $event) use ($asset, $user) {
- return $event->itemNoteAddedOn->is($asset)
- && $event->note === 'New Note!'
- && $event->noteAddedBy->is($user);
- });
- }
-}
diff --git a/tests/Feature/Notes/CreateNotesTest.php b/tests/Feature/Notes/CreateNotesTest.php
new file mode 100644
index 0000000000..a2caae6459
--- /dev/null
+++ b/tests/Feature/Notes/CreateNotesTest.php
@@ -0,0 +1,70 @@
+actingAs(User::factory()->create())
+ ->post(route('notes.store'))
+ ->assertForbidden();
+ }
+
+ public function testValidation()
+ {
+ $asset = Asset::factory()->create();
+
+ $this->actingAs(User::factory()->editAssets()->create())
+ ->post(route('notes.store'), [
+ 'id' => $asset->id,
+ // should be more...
+ ])
+ ->assertSessionHas('errors');
+ }
+
+ public function testAssetMustExist()
+ {
+ $this->actingAs(User::factory()->editAssets()->create())
+ ->post(route('notes.store'), [
+ 'id' => 999_999,
+ 'type' => 'asset',
+ 'note' => 'my note',
+ ])
+ ->assertStatus(302);
+ }
+
+ public function testCanCreateNoteForAsset()
+ {
+ $actor = User::factory()->editAssets()->create();
+
+ $asset = Asset::factory()->create();
+
+ $this->actingAs($actor)
+ ->withHeader('User-Agent', 'Custom User Agent For Test')
+ ->post(route('notes.store'), [
+ '_token' => '_token-to-simulate-request-from-gui',
+ 'id' => $asset->id,
+ 'type' => 'asset',
+ 'note' => 'my special note',
+ ])
+ ->assertRedirect(route('hardware.show', $asset->id) . '#history')
+ ->assertSessionHas('success', trans('general.note_added'));
+
+ $this->assertDatabaseHas('action_logs', [
+ 'created_by' => $actor->id,
+ 'action_type' => 'note added',
+ 'target_id' => null,
+ 'target_type' => null,
+ 'note' => 'my special note',
+ 'item_type' => Asset::class,
+ 'item_id' => $asset->id,
+ 'action_source' => 'gui',
+ 'user_agent' => 'Custom User Agent For Test',
+ ]);
+ }
+}
diff --git a/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php
new file mode 100644
index 0000000000..deb3e07d2c
--- /dev/null
+++ b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php
@@ -0,0 +1,108 @@
+pending()->create();
+ $userWithoutPermission = User::factory()->create();
+
+ $this->actingAs($userWithoutPermission)
+ ->post($this->routeFor($checkoutAcceptance))
+ ->assertForbidden();
+
+ Mail::assertNotSent(CheckoutAssetMail::class);
+ }
+
+ public function testReminderNotSentIfAcceptanceDoesNotExist()
+ {
+ $this->actingAs(User::factory()->canViewReports()->create())
+ ->post(route('reports/unaccepted_assets_sent_reminder', [
+ 'acceptance_id' => 999999,
+ ]));
+
+ Mail::assertNotSent(CheckoutAssetMail::class);
+ }
+
+ public function testReminderNotSentIfAcceptanceAlreadyAccepted()
+ {
+ $checkoutAcceptanceAlreadyAccepted = CheckoutAcceptance::factory()->accepted()->create();
+
+ $this->actingAs(User::factory()->canViewReports()->create())
+ ->post($this->routeFor($checkoutAcceptanceAlreadyAccepted));
+
+ Mail::assertNotSent(CheckoutAssetMail::class);
+ }
+
+ public static function CheckoutAcceptancesToUsersWithoutEmailAddresses()
+ {
+ yield 'User with null email address' => [
+ function () {
+ return CheckoutAcceptance::factory()
+ ->pending()
+ ->forAssignedTo(['email' => null])
+ ->create();
+ }
+ ];
+
+ yield 'User with empty string email address' => [
+ function () {
+ return CheckoutAcceptance::factory()
+ ->pending()
+ ->forAssignedTo(['email' => ''])
+ ->create();
+ }
+ ];
+ }
+
+ #[DataProvider('CheckoutAcceptancesToUsersWithoutEmailAddresses')]
+ public function testUserWithoutEmailAddressHandledGracefully($callback)
+ {
+ $checkoutAcceptance = $callback();
+
+ $this->actingAs(User::factory()->canViewReports()->create())
+ ->post($this->routeFor($checkoutAcceptance))
+ // check we didn't crash...
+ ->assertRedirect();
+
+ Mail::assertNotSent(CheckoutAssetMail::class);
+ }
+
+ public function testReminderIsSentToUser()
+ {
+ $checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create();
+
+ $this->actingAs(User::factory()->canViewReports()->create())
+ ->post($this->routeFor($checkoutAcceptance))
+ ->assertRedirect(route('reports/unaccepted_assets'));
+
+ Mail::assertSent(CheckoutAssetMail::class, 1);
+ Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) use ($checkoutAcceptance) {
+ return $mail->hasTo($checkoutAcceptance->assignedTo->email)
+ && $mail->hasSubject(trans('mail.unaccepted_asset_reminder'));
+ });
+ }
+
+ private function routeFor(CheckoutAcceptance $checkoutAcceptance): string
+ {
+ return route('reports/unaccepted_assets_sent_reminder', [
+ 'acceptance_id' => $checkoutAcceptance->id,
+ ]);
+ }
+}
diff --git a/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php
new file mode 100644
index 0000000000..220f6543c8
--- /dev/null
+++ b/tests/Feature/Notifications/Email/ExpiringAlertsNotificationTest.php
@@ -0,0 +1,91 @@
+markIncompleteIfSqlite();
+ Mail::fake();
+
+ $this->settings->enableAlertEmail('admin@example.com');
+ $this->settings->setAlertInterval(30);
+
+ $alert_email = Setting::first()->alert_email;
+
+ $expiringAsset = Asset::factory()->create([
+ 'purchase_date' => now()->subMonths(11)->format('Y-m-d'),
+ 'warranty_months' => 12,
+ 'archived' => 0,
+ 'deleted_at' => null,
+ ]);
+
+ $expiredAsset = Asset::factory()->create([
+ 'purchase_date' => now()->subMonths(13)->format('Y-m-d'),
+ 'warranty_months' => 12,
+ 'archived' => 0,
+ 'deleted_at' => null,
+ ]);
+ $notExpiringAsset = Asset::factory()->create([
+ 'purchase_date' => now()->subMonths(10)->format('Y-m-d'),
+ 'warranty_months' => 12,
+ 'archived' => 0,
+ 'deleted_at' => null,
+ ]);
+
+ $this->artisan('snipeit:expiring-alerts')->assertExitCode(0);
+
+ Mail::assertSent(ExpiringAssetsMail::class, function($mail) use ($alert_email, $expiringAsset) {
+ return $mail->hasTo($alert_email) && $mail->assets->contains($expiringAsset);
+ });
+
+ Mail::assertNotSent(ExpiringAssetsMail::class, function($mail) use ($expiredAsset, $notExpiringAsset) {
+ return $mail->assets->contains($expiredAsset) || $mail->assets->contains($notExpiringAsset);
+ });
+ }
+
+ public function testExpiringLicensesEmailNotification()
+ {
+ $this->markIncompleteIfSqlite();
+ Mail::fake();
+ $this->settings->enableAlertEmail('admin@example.com');
+ $this->settings->setAlertInterval(60);
+
+ $alert_email = Setting::first()->alert_email;
+
+ $expiringLicense = License::factory()->create([
+ 'expiration_date' => now()->addDays(30)->format('Y-m-d'),
+ 'deleted_at' => null,
+ ]);
+
+ $expiredLicense = License::factory()->create([
+ 'expiration_date' => now()->subDays(10)->format('Y-m-d'),
+ 'deleted_at' => null,
+ ]);
+ $notExpiringLicense = License::factory()->create([
+ 'expiration_date' => now()->addMonths(3)->format('Y-m-d'),
+ 'deleted_at' => null,
+ ]);
+
+ $this->artisan('snipeit:expiring-alerts')->assertExitCode(0);
+
+ Mail::assertSent(ExpiringLicenseMail::class, function($mail) use ($alert_email, $expiringLicense) {
+ return $mail->hasTo($alert_email) && $mail->licenses->contains($expiringLicense);
+ });
+
+ Mail::assertNotSent(ExpiringLicenseMail::class, function($mail) use ($expiredLicense, $notExpiringLicense) {
+ return $mail->licenses->contains($expiredLicense) || $mail->licenses->contains($notExpiringLicense);
+ });
+ }
+}
\ No newline at end of file
diff --git a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php
index 2b108443a3..cebc8156ad 100644
--- a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php
+++ b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php
@@ -17,7 +17,7 @@ class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequi
$this->actingAs(User::factory()->create())
->post(route('report-templates.destroy', $reportTemplate->id))
- ->assertNotFound();
+ ->assertStatus(302);
$this->assertModelExists($reportTemplate);
}
@@ -28,7 +28,7 @@ class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequi
$this->actingAs(User::factory()->canViewReports()->create())
->delete(route('report-templates.destroy', $reportTemplate->id))
- ->assertNotFound();
+ ->assertStatus(302);
$this->assertModelExists($reportTemplate);
}
diff --git a/tests/Feature/ReportTemplates/EditReportTemplateTest.php b/tests/Feature/ReportTemplates/EditReportTemplateTest.php
index 88363ec8b1..d359baddde 100644
--- a/tests/Feature/ReportTemplates/EditReportTemplateTest.php
+++ b/tests/Feature/ReportTemplates/EditReportTemplateTest.php
@@ -15,7 +15,7 @@ class EditReportTemplateTest extends TestCase implements TestsPermissionsRequire
{
$this->actingAs(User::factory()->create())
->get(route('report-templates.edit', ReportTemplate::factory()->create()))
- ->assertNotFound();
+ ->assertStatus(302);
}
public function testCannotLoadEditPageForAnotherUsersReportTemplate()
@@ -25,7 +25,7 @@ class EditReportTemplateTest extends TestCase implements TestsPermissionsRequire
$this->actingAs($user)
->get(route('report-templates.edit', $reportTemplate))
- ->assertNotFound();
+ ->assertStatus(302);
}
public function testCanLoadEditReportTemplatePage()
diff --git a/tests/Feature/ReportTemplates/ShowReportTemplateTest.php b/tests/Feature/ReportTemplates/ShowReportTemplateTest.php
index 3e57db898a..748df288b5 100644
--- a/tests/Feature/ReportTemplates/ShowReportTemplateTest.php
+++ b/tests/Feature/ReportTemplates/ShowReportTemplateTest.php
@@ -15,7 +15,7 @@ class ShowReportTemplateTest extends TestCase implements TestsPermissionsRequire
{
$this->actingAs(User::factory()->create())
->get(route('report-templates.show', ReportTemplate::factory()->create()))
- ->assertNotFound();
+ ->assertStatus(302);
}
public function testCanLoadASavedReportTemplate()
@@ -38,6 +38,6 @@ class ShowReportTemplateTest extends TestCase implements TestsPermissionsRequire
$this->actingAs(User::factory()->canViewReports()->create())
->get(route('report-templates.show', $reportTemplate))
- ->assertNotFound();
+ ->assertStatus(302);
}
}
diff --git a/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php b/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php
index 9afecb0849..09c168b27e 100644
--- a/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php
+++ b/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php
@@ -15,14 +15,14 @@ class UpdateReportTemplateTest extends TestCase implements TestsPermissionsRequi
{
$this->actingAs(User::factory()->create())
->post(route('report-templates.update', ReportTemplate::factory()->create()))
- ->assertNotFound();
+ ->assertStatus(302);
}
public function testCannotUpdateAnotherUsersReportTemplate()
{
$this->actingAs(User::factory()->canViewReports()->create())
->post(route('report-templates.update', ReportTemplate::factory()->create()))
- ->assertNotFound();
+ ->assertStatus(302);
}
public function testUpdatingReportTemplateRequiresValidFields()
diff --git a/tests/Feature/Settings/ShowSetUpPageTest.php b/tests/Feature/Settings/ShowSetUpPageTest.php
index 196902ac5f..fe071491e8 100644
--- a/tests/Feature/Settings/ShowSetUpPageTest.php
+++ b/tests/Feature/Settings/ShowSetUpPageTest.php
@@ -21,6 +21,8 @@ use Tests\TestCase;
class ShowSetUpPageTest extends TestCase
{
+
+ static ?TestResponse $latestResponse;
/**
* We do not want to make actual http request on every test to check .env file
* visibility because that can be really slow especially in some cases where an
@@ -34,7 +36,8 @@ class ShowSetUpPageTest extends TestCase
Http::fake([URL::to('.env') => Http::response(null, 404)]);
}
- return $this->get('/setup');
+ self::$latestResponse = $this->get('/setup');
+ return self::$latestResponse;
}
public function testView(): void
diff --git a/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php b/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php
index 0b7389603d..96e8d75528 100644
--- a/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php
+++ b/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php
@@ -11,7 +11,7 @@ class ShowStatusLabelTest extends TestCase
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('statuslabels.show', Statuslabel::factory()->create()->id))
+ ->get(route('statuslabels.show', Statuslabel::factory()->create()))
->assertOk();
}
}
diff --git a/tests/Feature/Users/Api/DeleteUsersTest.php b/tests/Feature/Users/Api/DeleteUsersTest.php
index 9677e5f7d4..a2e43f04bc 100644
--- a/tests/Feature/Users/Api/DeleteUsersTest.php
+++ b/tests/Feature/Users/Api/DeleteUsersTest.php
@@ -37,7 +37,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
{
$user = User::factory()->deletedUser()->create();
$this->actingAsForApi(User::factory()->deleteUsers()->create())
- ->deleteJson(route('api.users.destroy', $user->id))
+ ->deleteJson(route('api.users.destroy', $user))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -51,7 +51,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$this->assertFalse($manager->isDeletable());
$this->actingAsForApi(User::factory()->deleteUsers()->create())
- ->deleteJson(route('api.users.destroy', $manager->id))
+ ->deleteJson(route('api.users.destroy', $manager))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -66,7 +66,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$this->assertFalse($manager->isDeletable());
$this->actingAsForApi(User::factory()->deleteUsers()->create())
- ->deleteJson(route('api.users.destroy', $manager->id))
+ ->deleteJson(route('api.users.destroy', $manager))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -81,7 +81,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$this->assertFalse($manager->isDeletable());
$this->actingAsForApi(User::factory()->deleteUsers()->create())
- ->deleteJson(route('api.users.destroy', $manager->id))
+ ->deleteJson(route('api.users.destroy', $manager))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -111,7 +111,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$userFromB = User::factory()->deleteUsers()->for($companyB)->create();
$this->actingAsForApi($userFromA)
- ->deleteJson(route('api.users.destroy', ['user' => $userFromB->id]))
+ ->deleteJson(route('api.users.destroy', $userFromB))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -121,7 +121,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$this->assertNull($userFromB->deleted_at);
$this->actingAsForApi($userFromB)
- ->deleteJson(route('api.users.destroy', ['user' => $userFromA->id]))
+ ->deleteJson(route('api.users.destroy', $userFromA))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('error')
@@ -131,7 +131,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp
$this->assertNull($userFromA->deleted_at);
$this->actingAsForApi($superuser)
- ->deleteJson(route('api.users.destroy', ['user' => $userFromA->id]))
+ ->deleteJson(route('api.users.destroy', $userFromA))
->assertOk()
->assertStatus(200)
->assertStatusMessageIs('success')
diff --git a/tests/Feature/Users/Ui/CloneUserTest.php b/tests/Feature/Users/Ui/CloneUserTest.php
new file mode 100644
index 0000000000..97b4babd7b
--- /dev/null
+++ b/tests/Feature/Users/Ui/CloneUserTest.php
@@ -0,0 +1,18 @@
+actingAs(User::factory()->superuser()->create())
+ ->get(route('users.clone.show', User::factory()->create()))
+ ->assertOk();
+ }
+
+
+}
diff --git a/tests/Feature/Users/Ui/DeleteUserTest.php b/tests/Feature/Users/Ui/DeleteUserTest.php
index da4c5a37ee..6d687ed0f8 100644
--- a/tests/Feature/Users/Ui/DeleteUserTest.php
+++ b/tests/Feature/Users/Ui/DeleteUserTest.php
@@ -48,6 +48,14 @@ class DeleteUserTest extends TestCase
$this->followRedirects($response)->assertSee(trans('general.error'));
}
+ public function testCanViewSoftDeletedUser()
+ {
+ $user = User::factory()->deletedUser()->viewUsers()->create();
+ $response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
+ ->get(route('users.show', $user->id))
+ ->assertStatus(200);
+ }
+
public function testFmcsPermissionsToDeleteUser()
{
diff --git a/tests/Feature/Users/Ui/ViewUserTest.php b/tests/Feature/Users/Ui/ViewUserTest.php
index 791c804897..cb21a1e9e2 100644
--- a/tests/Feature/Users/Ui/ViewUserTest.php
+++ b/tests/Feature/Users/Ui/ViewUserTest.php
@@ -20,11 +20,11 @@ class ViewUserTest extends TestCase
$user = User::factory()->for($companyB)->create();
$this->actingAs(User::factory()->editUsers()->for($companyA)->create())
- ->get(route('users.show', ['user' => $user->id]))
- ->assertStatus(403);
+ ->get(route('users.show', $user))
+ ->assertStatus(302);
$this->actingAs($superuser)
- ->get(route('users.show', ['user' => $user->id]))
+ ->get(route('users.show', $user))
->assertOk()
->assertStatus(200);
}
diff --git a/tests/Support/Settings.php b/tests/Support/Settings.php
index e171c0ab95..09d40974c1 100644
--- a/tests/Support/Settings.php
+++ b/tests/Support/Settings.php
@@ -21,12 +21,23 @@ class Settings
public function enableAlertEmail(string $email = 'notifications@afcrichmond.com'): Settings
{
- return $this->update(['alert_email' => $email]);
+ return $this->update([
+ 'alert_email' => $email,
+ 'alerts_enabled' => 1,
+ ]);
+ }
+ public function setAlertInterval(int $days): Settings
+ {
+ return $this->update([
+ 'alert_threshold' => $days,
+ ]);
}
-
public function disableAlertEmail(): Settings
{
- return $this->update(['alert_email' => null]);
+ return $this->update([
+ 'alert_email' => null,
+ 'alerts_enabled' => 0,
+ ]);
}
public function enableMultipleFullCompanySupport(): Settings
diff --git a/tests/Unit/LdapTest.php b/tests/Unit/LdapTest.php
index f3bc521635..a492b1efbc 100644
--- a/tests/Unit/LdapTest.php
+++ b/tests/Unit/LdapTest.php
@@ -2,6 +2,7 @@
namespace Tests\Unit;
+use App\Models\Setting;
use PHPUnit\Framework\Attributes\Group;
use App\Models\Ldap;
use Tests\TestCase;
@@ -206,4 +207,30 @@ class LdapTest extends TestCase
$this->assertEqualsCanonicalizing(["count" => 2], $results);
}
+ public function testNonexistentTLSFile()
+ {
+ $this->settings->enableLdap()->set(['ldap_client_tls_cert' => 'SAMPLE CERT TEXT']);
+ $certfile = Setting::get_client_side_cert_path();
+ $this->assertStringEqualsFile($certfile, 'SAMPLE CERT TEXT');
+ }
+
+ public function testStaleTLSFile()
+ {
+ file_put_contents(Setting::get_client_side_cert_path(), 'STALE CERT FILE');
+ sleep(1); // FIXME - this is going to slow down tests
+ $this->settings->enableLdap()->set(['ldap_client_tls_cert' => 'SAMPLE CERT TEXT']);
+ $certfile = Setting::get_client_side_cert_path();
+ $this->assertStringEqualsFile($certfile, 'SAMPLE CERT TEXT');
+ }
+
+ public function testFreshTLSFile()
+ {
+ $this->settings->enableLdap()->set(['ldap_client_tls_cert' => 'SAMPLE CERT TEXT']);
+ $client_side_cert_path = Setting::get_client_side_cert_path();
+ file_put_contents($client_side_cert_path, 'WEIRDLY UPDATED CERT FILE');
+ //the system should respect our cache-file, since the settings haven't been updated
+ $possibly_recached_cert_file = Setting::get_client_side_cert_path(); //this should *NOT* re-cache from the Settings
+ $this->assertStringEqualsFile($possibly_recached_cert_file, 'WEIRDLY UPDATED CERT FILE');
+ }
+
}
diff --git a/tests/Unit/Listeners/LogListenerTest.php b/tests/Unit/Listeners/LogListenerTest.php
index 5b0813c281..64dd2a3d67 100644
--- a/tests/Unit/Listeners/LogListenerTest.php
+++ b/tests/Unit/Listeners/LogListenerTest.php
@@ -3,7 +3,6 @@
namespace Tests\Unit\Listeners;
use App\Events\CheckoutableCheckedOut;
-use App\Events\NoteAdded;
use App\Listeners\LogListener;
use App\Models\Asset;
use App\Models\User;
@@ -38,19 +37,4 @@ class LogListenerTest extends TestCase
]);
}
- public function testLogsEntryOnAssetNoteCreation()
- {
- $asset = Asset::factory()->create();
- $noteAddedBy = User::factory()->create();
-
- event(new NoteAdded($asset, $noteAddedBy, 'My Cool Note!'));
-
- $this->assertDatabaseHas('action_logs', [
- 'action_type' => 'note_added',
- 'created_by' => $noteAddedBy->id,
- 'item_id' => $asset->id,
- 'item_type' => Asset::class,
- 'note' => 'My Cool Note!',
- ]);
- }
}
diff --git a/tests/Unit/NotificationTest.php b/tests/Unit/NotificationTest.php
index 3d5b3c5a76..5b420a6753 100644
--- a/tests/Unit/NotificationTest.php
+++ b/tests/Unit/NotificationTest.php
@@ -7,9 +7,7 @@ use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Category;
use Carbon\Carbon;
-use App\Notifications\CheckoutAssetNotification;
use Illuminate\Support\Facades\Mail;
-use Illuminate\Support\Facades\Notification;
use Tests\TestCase;
class NotificationTest extends TestCase
@@ -33,8 +31,8 @@ class NotificationTest extends TestCase
Mail::fake();
$asset->checkOut($user, $admin->id);
- Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($user) {
- return $mail->hasTo($user->email);
+ Mail::assertSent(CheckoutAssetMail::class, function (CheckoutAssetMail $mail) use ($user) {
+ return $mail->hasTo($user->email) && $mail->hasSubject(trans('mail.Asset_Checkout_Notification'));
});
}
public function testDefaultEulaIsSentWhenSetInCategory()
diff --git a/tests/Unit/UserTest.php b/tests/Unit/UserTest.php
index e089fc4023..d47a49934d 100644
--- a/tests/Unit/UserTest.php
+++ b/tests/Unit/UserTest.php
@@ -64,31 +64,39 @@ class UserTest extends TestCase
$this->assertEquals($expected_username, $user['username']);
}
- public function firstInitialDotLastname()
+ public function testFirstInitialDotLastname()
{
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
- $expected_username = 'n.allanovnaromanovaoshostakova';
+ $expected_username = 'nallanovna-romanova-oshostakova';
$user = User::generateFormattedNameFromFullName($fullname, 'firstinitial.lastname');
$this->assertEquals($expected_username, $user['username']);
}
- public function lastNameUnderscoreFirstInitial()
+ public function testLastNameDotFirstInitial()
{
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
- $expected_username = 'allanovnaromanovaoshostakova_n';
+ $expected_username = 'allanovna-romanova-oshostakova.n';
+ $user = User::generateFormattedNameFromFullName($fullname, 'lastname.firstinitial');
+ $this->assertEquals($expected_username, $user['username']);
+ }
+
+ public function testLastNameUnderscoreFirstInitial()
+ {
+ $fullname = "Natalia Allanovna Romanova-O'Shostakova";
+ $expected_username = 'allanovna-romanova-oshostakova_n';
$user = User::generateFormattedNameFromFullName($fullname, 'lastname_firstinitial');
$this->assertEquals($expected_username, $user['username']);
}
- public function firstNameLastName()
+ public function testFirstNameLastName()
{
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
- $expected_username = 'nataliaallanovnaromanovaoshostakova';
+ $expected_username = 'nataliaallanovna-romanova-oshostakova';
$user = User::generateFormattedNameFromFullName($fullname, 'firstnamelastname');
$this->assertEquals($expected_username, $user['username']);
}
- public function firstNameLastInitial()
+ public function testFirstNameLastInitial()
{
$fullname = "Natalia Allanovna Romanova-O'Shostakova";
$expected_username = 'nataliaa';
diff --git a/upgrade.php b/upgrade.php
index 4d67d24f22..9bd1e8ad15 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -1,4 +1,9 @@
1){
@@ -46,6 +52,9 @@ if ($argc > 1){
case '--skip-php-compatibility-checks':
$skip_php_checks = true;
break;
+ case '--skip-backup':
+ $skip_backup = true;
+ break;
case '--branch':
$arg++;
$branch = $argv[$arg];
@@ -62,7 +71,7 @@ if ($argc > 1){
}
}
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
echo "WELCOME TO THE SNIPE-IT UPGRADER! \n";
echo "--------------------------------------------------------\n\n";
echo "This script will attempt to: \n\n";
@@ -71,8 +80,9 @@ echo "- check your PHP version and extension requirements \n";
echo "- check directory permissions \n";
echo "- do a git pull to bring you to the latest version \n";
echo "- run composer install to get your vendors up to date \n";
+echo "- run a backup \n";
echo "- run migrations to get your schema up to date \n";
-echo "- clear out old cache settings\n\n";
+echo "- clear out old cache settings\e[39m\n\n";
// Fetching most current upgrade requirements from github. Read more here: https://github.com/snipe/snipe-it/pull/14127
@@ -81,29 +91,29 @@ $upgrade_requirements_raw = url_get_contents($remote_requirements_file);
$upgrade_requirements = json_decode($upgrade_requirements_raw, true);
if (! $upgrade_requirements) {
if(!$skip_php_checks){
- echo "\nERROR: Failed to retrieve remote requirements from $remote_requirements_file\n\n";
+ echo "\n\e[91mERROR: Failed to retrieve remote requirements from $remote_requirements_file \e[39m\n\n";
if ($branch_override){
- echo "NOTE: You passed a custom branch: $branch\n";
- echo " If the above URL doesn't work, that may be why. Please check you branch spelling/existence\n\n";
+ echo "\e[93mNOTE: You passed a custom branch: $branch\n";
+ echo "If the above URL doesn't work, that may be why. Please check the branch spelling/existence\e[39m\n\n";
}
if (json_last_error()) {
- print "JSON DECODE ERROR DETECTED:\n";
+ print "\e[91mJSON DECODE ERROR DETECTED:\n";
print json_last_error_msg() . "\n\n";
print "Raw curl output:\n";
- print $upgrade_requirements_raw . "\n\n";
+ print $upgrade_requirements_raw . "\e[39m\n\n";
}
- echo "We suggest correcting this, but if you can't, please verify that your requirements conform to those at that url.\n\n";
- echo " -- DANGER -- DO AT YOUR OWN RISK --\n";
- echo " IF YOU ARE SURE, re-run this script with --skip-php-compatibility-checks to skip this check.\n";
- echo " -- DANGER -- THIS COULD BREAK YOUR INSTALLATION";
- die("Exiting.\n\n");
+ echo "\e[93mWe suggest correcting this, but if you can't, please verify that your requirements conform to those at that url.\n\n";
+ echo "\e[91m-- DANGER -- DO AT YOUR OWN RISK --\n";
+ echo "IF YOU ARE SURE, re-run this script with --skip-php-compatibility-checks to skip this check.\n";
+ echo "-- DANGER -- THIS COULD BREAK YOUR INSTALLATION\e[39m\n\n";
+ die("Aborting upgrade.\n\n");
}
- echo "NOTICE: Unable to fetch upgrade requirements, but continuing because you passed --skip-php-compatibility-checks...\n";
+ echo "\e[93mNOTICE: Unable to fetch upgrade requirements, but continuing because you passed --skip-php-compatibility-checks...e[39m\n";
}
-echo "Launching using branch: $branch\n";
+echo "Launching using branch: $branch\e[39m\n";
if($upgrade_requirements){
$php_min_works = $upgrade_requirements['php_min_version'];
@@ -133,22 +143,22 @@ if ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') || (!function_exists('posix_get
$username = $pwu_data['name'];
if (($username=='root') || ($username=='admin')) {
- die("\nERROR: This script should not be run as root/admin. Exiting.\n\n");
+ die("\n".$error_icon."ERROR: This script should not be run as root/admin. Exiting.\n\n");
}
}
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
echo "STEP 1: Checking .env file: \n";
echo "- Your .env is located at ".getcwd()."/.env \n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\\n\n";
// Check the .env looks ok
$env = file('.env');
if (! $env){
- echo "\n!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ echo "\n\e[91m!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";
echo "Your .env file doesn't seem to exist in this directory or isn't readable! Please look into that.\n";
exit(1);
}
@@ -198,32 +208,32 @@ foreach ($env as $line_num => $line) {
if ($env_key == 'APP_KEY') {
if (($env_value=='') || (strlen($env_value) < 20)) {
- $env_bad .= "✘ APP_KEY ERROR in your .env on line #'.{$show_line_num}.': Your APP_KEY should not be blank. Run `php artisan key:generate` to generate one.\n";
+ $env_bad .= $error_icon." APP_KEY ERROR in your .env on line #'.{$show_line_num}.': Your APP_KEY should not be blank. Run `php artisan key:generate` to generate one.\n";
} else {
- $env_good .= "√ Your APP_KEY is not blank. \n";
+ $env_good .= $success_icon." Your APP_KEY is not blank. \n";
}
}
if ($env_key == 'APP_URL') {
if (($env_value!="null") && ($env_value!="")) {
- $env_good .= '√ Your APP_URL is not null or blank. It is set to '.$env_value."\n";
+ $env_good .= $success_icon.' Your APP_URL is not null or blank. It is set to '.$env_value."\n";
if (!str_begins(trim($env_value), 'http://') && (!str_begins($env_value, 'https://'))) {
- $env_bad .= '✘ APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should start with https:// or http://!! It is currently set to: '.$env_value;
+ $env_bad .= $error_icon.' APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should start with https:// or http://!! It is currently set to: '.$env_value;
} else {
- $env_good .= '√ Your APP_URL is set to '.$env_value.' and starts with the protocol (https:// or http://)'."\n";
+ $env_good .= $success_icon.' Your APP_URL is set to '.$env_value.' and starts with the protocol (https:// or http://)'."\n";
}
if (str_ends(trim($env_value), "/")) {
- $env_bad .= '✘ APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should NOT end with a trailing slash. It is currently set to: '.$env_value;
+ $env_bad .= $error_icon.' APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should NOT end with a trailing slash. It is currently set to: '.$env_value;
} else {
- $env_good .= '√ Your APP_URL ('.$env_value.') does not have a trailing slash.'."\n";
+ $env_good .= $success_icon.' Your APP_URL ('.$env_value.') does not have a trailing slash.'."\n";
}
} else {
- $env_bad .= "✘ APP_URL ERROR in your .env on line #".$show_line_num.": Your APP_URL CANNOT be set to null or left blank.\n";
+ $env_bad .= $error_icon." APP_URL ERROR in your .env on line #".$show_line_num.": Your APP_URL CANNOT be set to null or left blank.\n";
}
}
@@ -237,34 +247,34 @@ echo $env_good;
if ($env_bad !='') {
- echo "!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";
- echo "Your .env file is misconfigured. Upgrade cannot continue.\n";
+ echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ echo "\e[91mYour .env file is misconfigured. Upgrade cannot continue.\n";
echo "--------------------------------------------------------\n\n";
echo $env_bad;
echo "\n\n--------------------------------------------------------\n";
- echo "!!!!!!!!!!!!!!!!!!!!!!!!! ABORTING THE UPGRADER !!!!!!!!!!!!!!!!!!!!!!\n";
- echo "Please correct the issues above in ".getcwd()."/.env and try again.\n";
- echo "--------------------------------------------------------\n";
+ echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!! ABORTING THE UPGRADER !!!!!!!!!!!!!!!!!!!!!!\n";
+ echo "\e[91mPlease correct the issues above in ".getcwd()."/.env and try again.\n";
+ echo "\e[91m--------------------------------------------------------\n";
exit(1);
}
if(!$skip_php_checks){
- echo "\n--------------------------------------------------------\n";
- echo "STEP 2: Checking PHP requirements: (Required PHP >=". $php_min_works. " - <".$php_max_wontwork.") \n";
- echo "--------------------------------------------------------\n\n";
+ echo "\n\e[95m--------------------------------------------------------\n";
+ echo "STEP 2: Checking PHP requirements: (Required PHP >=". $php_min_works. " - <".$php_max_wontwork.") \e[39m\n";
+ echo "--------------------------------------------------------\e[39m\n\n";
if ((version_compare(phpversion(), $php_min_works, '>=')) && (version_compare(phpversion(), $php_max_wontwork, '<'))) {
- echo "√ Current PHP version: (" . phpversion() . ") is at least " . $php_min_works . " and less than ".$php_max_wontwork."! Continuing... \n";
+ echo $success_icon." Current PHP version: (" . phpversion() . ") is at least " . $php_min_works . " and less than ".$php_max_wontwork."! Continuing... \n";
echo sprintf("FYI: The php.ini used by this PHP is: %s\n\n", get_cfg_var('cfg_file_path'));
} else {
- echo "!!!!!!!!!!!!!!!!!!!!!!!!! PHP VERSION ERROR !!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!! PHP VERSION ERROR !!!!!!!!!!!!!!!!!!!!!!!!!\n";
echo "This version of PHP (".phpversion().") is NOT compatible with Snipe-IT.\n";
echo "Snipe-IT requires PHP versions between ".$php_min_works." and ".$php_max_wontwork.".\n";
echo "Please install a compatible version of PHP and re-run this script again. \n";
- echo "!!!!!!!!!!!!!!!!!!!!!!!!! ABORTING THE UPGRADER !!!!!!!!!!!!!!!!!!!!!!\n";
+ echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!! ABORTING THE UPGRADER !!!!!!!!!!!!!!!!!!!!!!\n";
exit(1);
}
}
@@ -318,7 +328,7 @@ foreach ($required_exts_array as $required_ext) {
foreach ($require_either as $require_either_value) {
if (in_array($require_either_value, $loaded_exts_array)) {
- $ext_installed .= '√ '.$require_either_value." is installed!\n";
+ $ext_installed .= $success_icon.' '.$require_either_value." is installed!\n";
$has_one_required_ext = true;
break;
}
@@ -326,20 +336,20 @@ foreach ($required_exts_array as $required_ext) {
// If no match, add it to the string for errors
if (!$has_one_required_ext) {
- $ext_missing .= '✘ MISSING PHP EXTENSION: '.str_replace("|", " OR ", $required_ext)."\n";
+ $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.str_replace("|", " OR ", $required_ext)."\n";
break;
}
// If this isn't an either/or option, just add it to the string of errors conventionally
} elseif (!in_array($required_ext, $recommended_exts_array)){
- $ext_missing .= '✘ MISSING PHP EXTENSION: '.$required_ext."\n";
+ $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.$required_ext."\n";
} else {
$ext_installed .= '- '.$required_ext." is *NOT* installed, but is recommended...\n";
}
// The required extension string was found in the array of installed extensions - yay!
} else {
- $ext_installed .= '√ '.$required_ext." is installed!\n";
+ $ext_installed .= $success_icon.' '.$required_ext." is installed!\n";
}
}
@@ -350,15 +360,15 @@ if ($ext_missing!='') {
echo "--------------------------------------------------------\n";
foreach ($loaded_exts_array as $loaded_ext) {
- echo "- ".$loaded_ext."\n";
+ echo $success_icon.' '.$loaded_ext."\n";
}
- echo "--------------------- !! ERROR !! ----------------------\n";
+ echo "\e[91m--------------------- !! ERROR !! ----------------------\n";
echo $ext_missing;
- echo "--------------------------------------------------------\n";
- echo "ABORTING THE INSTALLER \n";
- echo "Please install the extensions above and re-run this script.\n";
- echo "--------------------------------------------------------\n";
+ echo "\e[91m--------------------------------------------------------\n";
+ echo "\e[91mABORTING THE INSTALLER \n";
+ echo "\e[91mPlease install the extensions above and re-run this script.\n";
+ echo "\e[91m--------------------------------------------------------\n";
exit(1);
} else {
echo $ext_installed."\n";
@@ -367,9 +377,9 @@ if ($ext_missing!='') {
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
echo "STEP 3: Checking directory permissions: \n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
$writable_dirs_array =
@@ -395,9 +405,9 @@ $dirs_not_writable = '';
// Loop through the directories that need to be writable
foreach ($writable_dirs_array as $writable_dir) {
if (is_writable($writable_dir)) {
- $dirs_writable .= '√ '.getcwd().'/'.$writable_dir." is writable \n";
+ $dirs_writable .= $success_icon.' '.getcwd().'/'.$writable_dir." is writable \n";
} else {
- $dirs_not_writable .= '✘ PERMISSIONS ERROR: '.getcwd().'/'.$writable_dir." is NOT writable\n";
+ $dirs_not_writable .= $error_icon.' PERMISSIONS ERROR: '.getcwd().'/'.$writable_dir." is NOT writable\n";
}
}
@@ -405,44 +415,24 @@ echo $dirs_writable."\n";
// Print out a useful error message
if ($dirs_not_writable!='') {
- echo "--------------------------------------------------------\n";
- echo "The following directories/files do not seem writable: \n";
- echo "--------------------------------------------------------\n";
+ echo "\e[91m--------------------------------------------------------\n";
+ echo "\eThe following directories/files do not seem writable: \n";
+ echo "\e--------------------------------------------------------\e[39m\n";
echo $dirs_not_writable;
- echo "--------------------- !! ERROR !! ----------------------\n";
- echo "Please check the permissions on the directories above and re-run this script.\n";
- echo "------------------------- :( ---------------------------\n\n";
+ echo "\e[91m--------------------- !! ERROR !! ----------------------\n";
+ echo "\ePlease check the permissions on the directories above and re-run this script.\n";
+ echo "\e------------------------- :( ---------------------------\e[39m\n\n";
exit(1);
}
-echo "--------------------------------------------------------\n";
-echo "STEP 4: Backing up database: \n";
-echo "--------------------------------------------------------\n\n";
-$backup = exec('php artisan snipeit:backup', $backup_results, $return_code);
-echo '-- ' . implode("\n", $backup_results) . "\n\n";
-if ($return_code > 0) {
- die("Something went wrong with your backup. Aborting!\n\n");
-}
-unset($return_code);
-echo "--------------------------------------------------------\n";
-echo "STEP 5: Putting application into maintenance mode: \n";
-echo "--------------------------------------------------------\n\n";
-exec('php artisan down', $down_results, $return_code);
-echo '-- ' . implode("\n", $down_results) . "\n";
-if ($return_code > 0) {
- die("Something went wrong with downing you site. This can't be good. Please investigate the error. Aborting!n\n");
-}
-unset($return_code);
-
-
-echo "--------------------------------------------------------\n";
-echo "STEP 6: Pulling latest from Git (".$branch." branch): \n";
-echo "--------------------------------------------------------\n\n";
+echo "\e[95m--------------------------------------------------------\n";
+echo "STEP 4: Pulling latest from Git (".$branch." branch): \n";
+echo "--------------------------------------------------------\e[39m\n\n";
$git_version = shell_exec('git --version');
if ((strpos('git version', $git_version)) === false) {
@@ -466,9 +456,9 @@ if ((strpos('git version', $git_version)) === false) {
}
-echo "--------------------------------------------------------\n";
-echo "STEP 7: Cleaning up old cached files:\n";
-echo "--------------------------------------------------------\n\n";
+echo "\e[95m--------------------------------------------------------\n";
+echo "STEP 5: Cleaning up old cached files:\n";
+echo "--------------------------------------------------------\e[39m\n\n";
// Build an array of the files we generally want to delete because they
// can cause issues with funky caching
@@ -481,39 +471,28 @@ $unused_files = [
foreach ($unused_files as $unused_file) {
if (file_exists($unused_file)) {
- echo "√ Deleting ".$unused_file.". It is no longer used.\n";
+ echo $success_icon." Deleting ".$unused_file.". It is no longer used.\n";
@unlink($unused_file);
} else {
- echo "√ No ".$unused_file.", so nothing to delete.\n";
+ echo $success_icon." No ".$unused_file.", so nothing to delete.\n";
}
}
echo "\n";
-$config_clear = shell_exec('php artisan config:clear');
-$cache_clear = shell_exec('php artisan cache:clear');
-$route_clear = shell_exec('php artisan route:clear');
-$view_clear = shell_exec('php artisan view:clear');
-echo '-- '.$config_clear;
-echo '-- '.$cache_clear;
-echo '-- '.$route_clear;
-echo '-- '.$view_clear;
-echo "\n";
-echo "--------------------------------------------------------\n";
-echo "STEP 8: Updating composer dependencies:\n";
+echo "\e[95m--------------------------------------------------------\n";
+echo "STEP 6: Updating composer dependencies:\n";
echo "(This may take a moment.)\n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
echo "-- Running the app in ".$app_environment." mode.\n";
// Composer install
if (file_exists('composer.phar')) {
- echo "√ Local composer.phar detected, so we'll use that.\n\n";
+ echo $success_icon." Local composer.phar detected, so we'll use that.\n\n";
echo "-- Updating local composer.phar\n\n";
$composer_update = shell_exec('php composer.phar self-update');
echo $composer_update."\n\n";
-
-
// Use --no-dev only if we are in production mode.
// This will cause errors otherwise, if the user is in develop or local for their APP_ENV
if ($app_environment == 'production') {
@@ -521,10 +500,9 @@ if (file_exists('composer.phar')) {
} else {
$composer = shell_exec('php composer.phar install --prefer-source');
}
+
$composer_dump = shell_exec('php composer.phar dump');
-
-
} else {
echo "-- We couldn't find a local composer.phar. No worries, trying globally.\n";
@@ -541,48 +519,87 @@ if (file_exists('composer.phar')) {
$composer_dump = shell_exec('composer dump');
-
}
echo $composer_dump."\n";
echo $composer;
+$config_clear = shell_exec('php artisan config:clear');
+$cache_clear = shell_exec('php artisan cache:clear');
+$route_clear = shell_exec('php artisan route:clear');
+$view_clear = shell_exec('php artisan view:clear');
+echo $success_icon.' '.trim($config_clear)."\n";
+echo $success_icon.' '.trim($cache_clear)."\n";
+echo $success_icon.' '.trim($route_clear)."\n";
+echo $success_icon.' '.trim($view_clear)."\n";
+echo "\n";
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
+echo "STEP 7: Putting application into maintenance mode: \n";
+echo "--------------------------------------------------------\e[39m\n\n";
+exec('php artisan down', $down_results, $return_code);
+echo '-- ' . implode("\n", $down_results) . "\n";
+if ($return_code > 0) {
+ die("Something went wrong with downing your site. This can't be good. Please investigate the error. Aborting!n\n");
+}
+unset($return_code);
+
+
+echo "\e[95m--------------------------------------------------------\n";
+echo "STEP 8: Backing up database: \n";
+echo "--------------------------------------------------------\e[39m\n\n";
+
+if (!$skip_backup) {
+ $backup = exec('php artisan snipeit:backup', $backup_results, $return_code);
+
+ if ($return_code > 0) {
+ die($error_icon." Something went wrong with your backup. Aborting!\n\n");
+ } else {
+ echo '-- ' . implode("\n", $backup_results) . "\n\n";
+ }
+ unset($return_code);
+} else {
+ echo "Upgrade was run with --skip-backup, so no backup will be run.\n\n";
+}
+
+
+
+
+echo "\e[95m--------------------------------------------------------\n";
echo "STEP 9: Migrating database:\n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
$migrations = shell_exec('php artisan migrate --force');
echo $migrations."\n";
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
echo "STEP 10: Checking for OAuth keys:\n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-private.key'))) {
- echo "- No OAuth keys detected. Running passport install now.\n\n";
- $passport = shell_exec('php artisan passport:install');
+ echo $info_icon." No OAuth keys detected. Running passport install now.\n\n";
+ $passport = shell_exec('php artisan passport:install --no-interaction');
echo $passport;
} else {
- echo "√ OAuth keys detected. Skipping passport install.\n\n";
+ echo $success_icon." OAuth keys detected. Skipping passport install.\n\n";
}
-echo "--------------------------------------------------------\n";
+echo "\e[95m--------------------------------------------------------\n";
echo "STEP 11: Taking application out of maintenance mode:\n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
$up = shell_exec('php artisan up');
-echo '-- '.$up."\n";
+echo $success_icon.' '.trim($up)."\n\n";
-echo "---------------------- FINISHED! -----------------------\n";
+echo "\e[92m---------------------- FINISHED! -----------------------\n";
echo "All done! Clear your browser cookies and re-login to use \n";
echo "your upgraded Snipe-IT!\n";
-echo "--------------------------------------------------------\n\n";
+echo "--------------------------------------------------------\e[39m\n\n";
function str_begins($haystack, $needle) {
@@ -592,6 +609,3 @@ function str_begins($haystack, $needle) {
function str_ends($haystack, $needle) {
return (substr_compare($haystack, $needle, -strlen($needle)) === 0);
}
-
-
-