Skip to content

A free open source IT asset/license management system

Departments: Added bulk delete

snipeedb5763c0194
diff --git a/app/Actions/Departments/DestroyDepartmentAction.php b/app/Actions/Departments/DestroyDepartmentAction.php
new file mode 100644
index 0000000000..a41f78f858
--- /dev/null
+++ b/app/Actions/Departments/DestroyDepartmentAction.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace App\Actions\Departments;
+
+use App\Exceptions\ItemStillHasUsers;
+use App\Models\Department;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Storage;
+
+class DestroyDepartmentAction
+{
+ /**
+ * @throws ItemStillHasUsers
+ */
+ public static function run(Department $department): bool
+ {
+ $department->loadCount(['users as users_count']);
+
+ if ($department->users_count > 0) {
+ throw new ItemStillHasUsers($department);
+ }
+
+ if ($department->image) {
+ try {
+ Storage::disk('public')->delete('departments/'.$department->image);
+ } catch (\Exception $e) {
+ Log::info($e->getMessage());
+ }
+ }
+
+ $department->delete();
+
+ return true;
+ }
+}
diff --git a/app/Http/Controllers/BulkCategoriesController.php b/app/Http/Controllers/BulkCategoriesController.php
index b59c487d08..943907b0ed 100644
--- a/app/Http/Controllers/BulkCategoriesController.php
+++ b/app/Http/Controllers/BulkCategoriesController.php
@@ -55,7 +55,7 @@ class BulkCategoriesController extends Controller
return redirect()->route('categories.index')->with('multi_error_messages', $errors);
} else {
- return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.bulk_success'));
+ return redirect()->route('categories.index')->with('success', trans_choice('admin/categories/message.delete.bulk_success', $success_count, ['count' => $success_count]));
}
}
}
diff --git a/app/Http/Controllers/BulkCompaniesController.php b/app/Http/Controllers/BulkCompaniesController.php
index 11b5ef78a6..77ee14bc7b 100644
--- a/app/Http/Controllers/BulkCompaniesController.php
+++ b/app/Http/Controllers/BulkCompaniesController.php
@@ -63,6 +63,6 @@ class BulkCompaniesController extends Controller
}
return redirect()->route('companies.index')
- ->with('success', trans('admin/companies/message.delete.bulk_success'));
+ ->with('success', trans_choice('admin/companies/message.delete.bulk_success', $success_count, ['count' => $success_count]));
}
}
diff --git a/app/Http/Controllers/BulkDepartmentsController.php b/app/Http/Controllers/BulkDepartmentsController.php
new file mode 100644
index 0000000000..0eb988005c
--- /dev/null
+++ b/app/Http/Controllers/BulkDepartmentsController.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Actions\Departments\DestroyDepartmentAction;
+use App\Exceptions\ItemStillHasUsers;
+use App\Models\Department;
+use Illuminate\Http\Request;
+
+class BulkDepartmentsController extends Controller
+{
+ public function destroy(Request $request)
+ {
+ $this->authorize('delete', Department::class);
+
+ $errors = [];
+ $success_count = 0;
+
+ foreach ($request->ids as $id) {
+ $department = Department::find($id);
+ if (is_null($department)) {
+ $errors[] = trans('admin/departments/message.does_not_exist');
+
+ continue;
+ }
+ try {
+ DestroyDepartmentAction::run(department: $department);
+ $success_count++;
+ } catch (ItemStillHasUsers $e) {
+ $errors[] = trans('general.bulk_delete_associations.assoc_users_no_count', ['item_name' => $department->name, 'item' => trans('general.department')]);
+ } catch (\Exception $e) {
+ report($e);
+ $errors[] = trans('general.something_went_wrong');
+ }
+ }
+
+ if (count($errors) > 0) {
+ if ($success_count > 0) {
+ return redirect()->route('departments.index')
+ ->with('success', trans_choice('admin/departments/message.delete.partial_success', $success_count, ['count' => $success_count]))
+ ->with('multi_error_messages', $errors);
+ }
+
+ return redirect()->route('departments.index')->with('multi_error_messages', $errors);
+ }
+
+ return redirect()->route('departments.index')
+ ->with('success', trans_choice('admin/departments/message.delete.bulk_success', $success_count, ['count' => $success_count]));
+ }
+}
diff --git a/app/Http/Controllers/BulkManufacturersController.php b/app/Http/Controllers/BulkManufacturersController.php
index 6d13c6999d..1690710935 100644
--- a/app/Http/Controllers/BulkManufacturersController.php
+++ b/app/Http/Controllers/BulkManufacturersController.php
@@ -51,7 +51,7 @@ class BulkManufacturersController extends Controller
return redirect()->route('manufacturers.index')->with('multi_error_messages', $errors);
} else {
- return redirect()->route('manufacturers.index')->with('success', trans('admin/manufacturers/message.delete.bulk_success'));
+ return redirect()->route('manufacturers.index')->with('success', trans_choice('admin/manufacturers/message.delete.bulk_success', $success_count, ['count' => $success_count]));
}
}
}
diff --git a/app/Http/Controllers/BulkStatuslabelsController.php b/app/Http/Controllers/BulkStatuslabelsController.php
index 52652962fa..146401eb1f 100644
--- a/app/Http/Controllers/BulkStatuslabelsController.php
+++ b/app/Http/Controllers/BulkStatuslabelsController.php
@@ -45,6 +45,6 @@ class BulkStatuslabelsController extends Controller
}
return redirect()->route('statuslabels.index')
- ->with('success', trans('admin/statuslabels/message.delete.bulk_success'));
+ ->with('success', trans_choice('admin/statuslabels/message.delete.bulk_success', $success_count, ['count' => $success_count]));
}
}
diff --git a/app/Http/Controllers/BulkSuppliersController.php b/app/Http/Controllers/BulkSuppliersController.php
index 394bf08e53..dc21cdf558 100644
--- a/app/Http/Controllers/BulkSuppliersController.php
+++ b/app/Http/Controllers/BulkSuppliersController.php
@@ -30,6 +30,7 @@ class BulkSuppliersController extends Controller
}
try {
DestroySupplierAction::run(supplier: $supplier);
+ $success_count++;
} catch (ItemStillHasAssets $e) {
$errors[] = trans('general.bulk_delete_associations.assoc_assets', ['asset_count' => (int) $supplier->assets_count, 'item' => trans('general.supplier'), 'item_name' => $supplier->name]);
} catch (ItemStillHasMaintenances $e) {
@@ -54,7 +55,7 @@ class BulkSuppliersController extends Controller
return redirect()->route('suppliers.index')->with('multi_error_messages', $errors);
} else {
- return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.bulk_success'));
+ return redirect()->route('suppliers.index')->with('success', trans_choice('admin/suppliers/message.delete.bulk_success', $success_count, ['count' => $success_count]));
}
}
}
diff --git a/app/Http/Transformers/DepartmentsTransformer.php b/app/Http/Transformers/DepartmentsTransformer.php
index defa08e600..f805d8d6ac 100644
--- a/app/Http/Transformers/DepartmentsTransformer.php
+++ b/app/Http/Transformers/DepartmentsTransformer.php
@@ -55,6 +55,9 @@ class DepartmentsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Department::class),
'delete' => (Gate::allows('delete', Department::class) && ($department->users_count == 0)),
+ 'bulk_selectable' => [
+ 'delete' => $department->users_count == 0,
+ ],
];
$array += $permissions_array;
diff --git a/app/Presenters/DepartmentPresenter.php b/app/Presenters/DepartmentPresenter.php
index 88c186550d..9ef5fea36a 100644
--- a/app/Presenters/DepartmentPresenter.php
+++ b/app/Presenters/DepartmentPresenter.php
@@ -16,6 +16,13 @@ class DepartmentPresenter extends Presenter
{
$layout = [
[
+ 'field' => 'checkbox',
+ 'checkbox' => true,
+ 'formatter' => 'checkboxEnabledFormatter',
+ 'titleTooltip' => trans('general.select_all_none'),
+ 'printIgnore' => true,
+ 'class' => 'hidden-print',
+ ], [
'field' => 'id',
'searchable' => false,
'sortable' => true,
diff --git a/resources/lang/en-US/admin/categories/message.php b/resources/lang/en-US/admin/categories/message.php
index df1fd3e8c2..a46f30dcb4 100644
--- a/resources/lang/en-US/admin/categories/message.php
+++ b/resources/lang/en-US/admin/categories/message.php
@@ -21,7 +21,7 @@ return [
'confirm' => 'Are you sure you wish to delete this category?',
'error' => 'There was an issue deleting the category. Please try again.',
'success' => 'Category was deleted successfully.',
- 'bulk_success' => 'Categories were deleted successfully.',
+ 'bulk_success' => 'Category deleted successfully.|:count categories were deleted successfully.',
'partial_success' => 'Category deleted successfully. See additional information below. | :count categories were deleted successfully. See additional information below.',
],
diff --git a/resources/lang/en-US/admin/companies/message.php b/resources/lang/en-US/admin/companies/message.php
index 0daf841063..f61171a1b5 100644
--- a/resources/lang/en-US/admin/companies/message.php
+++ b/resources/lang/en-US/admin/companies/message.php
@@ -16,7 +16,7 @@ return [
'confirm' => 'Are you sure you wish to delete this company?',
'error' => 'There was an issue deleting the company. Please try again.',
'success' => 'The Company was deleted successfully.',
- 'bulk_success' => 'Companies were deleted successfully.',
+ 'bulk_success' => 'Company deleted successfully.|:count companies were deleted successfully.',
'partial_success' => 'Company deleted successfully. See additional information below. | :count companies were deleted successfully. See additional information below.',
],
];
diff --git a/resources/lang/en-US/admin/departments/message.php b/resources/lang/en-US/admin/departments/message.php
index f3072a9ce6..bd51319117 100644
--- a/resources/lang/en-US/admin/departments/message.php
+++ b/resources/lang/en-US/admin/departments/message.php
@@ -17,6 +17,8 @@ return [
'confirm' => 'Are you sure you wish to delete this department?',
'error' => 'There was an issue deleting the department. Please try again.',
'success' => 'The department was deleted successfully.',
+ 'bulk_success' => 'Department deleted successfully.|:count departments were deleted successfully.',
+ 'partial_success' => 'Department deleted successfully. See additional information below. | :count departments were deleted successfully. See additional information below.',
],
];
diff --git a/resources/lang/en-US/admin/manufacturers/message.php b/resources/lang/en-US/admin/manufacturers/message.php
index 6cb61dcd40..13f09a11ad 100644
--- a/resources/lang/en-US/admin/manufacturers/message.php
+++ b/resources/lang/en-US/admin/manufacturers/message.php
@@ -25,7 +25,7 @@ return [
'confirm' => 'Are you sure you wish to delete this manufacturer?',
'error' => 'There was an issue deleting the manufacturer. Please try again.',
'success' => 'Manufacturer deleted successfully.',
- 'bulk_success' => 'Manufacturers deleted successfully.',
+ 'bulk_success' => 'Manufacturer deleted successfully.|:count manufacturers were deleted successfully.',
'partial_success' => 'Manufacturer deleted successfully. See additional information below. | :count manufacturers were deleted successfully. See additional information below.',
],
diff --git a/resources/lang/en-US/admin/statuslabels/message.php b/resources/lang/en-US/admin/statuslabels/message.php
index d566b662e0..e116708eeb 100644
--- a/resources/lang/en-US/admin/statuslabels/message.php
+++ b/resources/lang/en-US/admin/statuslabels/message.php
@@ -20,7 +20,7 @@ return [
'confirm' => 'Are you sure you wish to delete this Status Label?',
'error' => 'There was an issue deleting the Status Label. Please try again.',
'success' => 'The Status Label was deleted successfully.',
- 'bulk_success' => 'Status Labels were deleted successfully.',
+ 'bulk_success' => 'Status Label deleted successfully.|:count status labels were deleted successfully.',
'partial_success' => 'Status Label deleted successfully. See additional information below. | :count status labels were deleted successfully. See additional information below.',
],
diff --git a/resources/lang/en-US/admin/suppliers/message.php b/resources/lang/en-US/admin/suppliers/message.php
index d84f9615f4..4b790a0d59 100644
--- a/resources/lang/en-US/admin/suppliers/message.php
+++ b/resources/lang/en-US/admin/suppliers/message.php
@@ -20,7 +20,7 @@ return [
'error' => 'There was an issue deleting the supplier. Please try again.',
'success' => 'Supplier was deleted successfully.',
'not_found' => 'Supplier not found.',
- 'bulk_success' => 'Suppliers were deleted successfully.',
+ 'bulk_success' => 'Supplier deleted successfully.|:count suppliers were deleted successfully.',
'partial_success' => '.',
],
diff --git a/resources/views/departments/index.blade.php b/resources/views/departments/index.blade.php
index 65249a8d49..bef51ad6e9 100644
--- a/resources/views/departments/index.blade.php
+++ b/resources/views/departments/index.blade.php
@@ -9,8 +9,22 @@
{{-- Page content --}}
@section('content')
<x-container>
- <x-box>
+ <x-box name="department">
+
+ <x-slot:bulkactions>
+ <x-table.bulk-actions
+ name='department'
+ action_route="{{ route('departments.bulk.delete') }}"
+ model_name="department"
+ >
+ @can('delete', App\Models\Department::class)
+ <option>{{ trans('general.delete') }}</option>
+ @endcan
+ </x-table.bulk-actions>
+ </x-slot:bulkactions>
+
<x-table
+ name="department"
show_column_search="false"
buttons="departmentButtons"
fixed_right_number="1"
diff --git a/routes/web.php b/routes/web.php
index 06f271bde4..ab723c9085 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -8,6 +8,7 @@ use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Http\Controllers\BulkCategoriesController;
use App\Http\Controllers\BulkCompaniesController;
+use App\Http\Controllers\BulkDepartmentsController;
use App\Http\Controllers\BulkManufacturersController;
use App\Http\Controllers\BulkStatuslabelsController;
use App\Http\Controllers\BulkSuppliersController;
@@ -115,6 +116,8 @@ Route::group(['middleware' => 'auth'], function () {
* Departments
*/
Route::resource('departments', DepartmentsController::class);
+
+ Route::post('departments/bulk/delete', [BulkDepartmentsController::class, 'destroy'])->name('departments.bulk.delete');
});
/*
diff --git a/tests/Feature/Categories/Ui/BulkDeleteCategoriesTest.php b/tests/Feature/Categories/Ui/BulkDeleteCategoriesTest.php
index e67a8d3341..a4d932b2e2 100644
--- a/tests/Feature/Categories/Ui/BulkDeleteCategoriesTest.php
+++ b/tests/Feature/Categories/Ui/BulkDeleteCategoriesTest.php
@@ -49,4 +49,25 @@ class BulkDeleteCategoriesTest extends TestCase implements TestsPermissionsRequi
$this->assertSoftDeleted($category2);
$this->assertSoftDeleted($category3);
}
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ $solo = Category::factory()->create();
+
+ $this->actingAs(User::factory()->deleteCategories()->create())
+ ->post(route('categories.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/categories/message.delete.bulk_success', 1, ['count' => 1]));
+
+ $a = Category::factory()->create();
+ $b = Category::factory()->create();
+ $c = Category::factory()->create();
+
+ $this->actingAs(User::factory()->deleteCategories()->create())
+ ->post(route('categories.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/categories/message.delete.bulk_success', 3, ['count' => 3]));
+ }
}
diff --git a/tests/Feature/Companies/Ui/BulkDeleteCompaniesTest.php b/tests/Feature/Companies/Ui/BulkDeleteCompaniesTest.php
index 75fdb95e48..40c4939863 100644
--- a/tests/Feature/Companies/Ui/BulkDeleteCompaniesTest.php
+++ b/tests/Feature/Companies/Ui/BulkDeleteCompaniesTest.php
@@ -111,4 +111,26 @@ class BulkDeleteCompaniesTest extends TestCase
$this->assertSoftDeleted($deletable);
}
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ // Single-item batch → singular success message.
+ $solo = Company::factory()->create();
+
+ $this->actingAs(User::factory()->deleteCompanies()->create())
+ ->post(route('companies.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/companies/message.delete.bulk_success', 1, ['count' => 1]));
+
+ $a = Company::factory()->create();
+ $b = Company::factory()->create();
+ $c = Company::factory()->create();
+
+ $this->actingAs(User::factory()->deleteCompanies()->create())
+ ->post(route('companies.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/companies/message.delete.bulk_success', 3, ['count' => 3]));
+ }
}
diff --git a/tests/Feature/Departments/Api/BulkSelectableTest.php b/tests/Feature/Departments/Api/BulkSelectableTest.php
new file mode 100644
index 0000000000..89df4a9e13
--- /dev/null
+++ b/tests/Feature/Departments/Api/BulkSelectableTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Tests\Feature\Departments\Api;
+
+use App\Models\Department;
+use App\Models\User;
+use Tests\TestCase;
+
+/**
+ * Verifies the JS-visible flag that drives the bulk-delete checkbox on the
+ * departments index. The bootstrap-table `checkboxEnabledFormatter` reads
+ * `available_actions.bulk_selectable.delete` and disables the row's checkbox
+ * when every entry there is false. A department with any assigned user must
+ * therefore report `bulk_selectable.delete === false`; a clean department
+ * must report `true`.
+ */
+class BulkSelectableTest extends TestCase
+{
+ public function test_clean_department_is_bulk_selectable()
+ {
+ $department = Department::factory()->create();
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->getJson(route('api.departments.show', $department))
+ ->assertOk()
+ ->assertJsonPath('available_actions.bulk_selectable.delete', true);
+ }
+
+ public function test_department_with_users_is_not_bulk_selectable()
+ {
+ $department = Department::factory()->create();
+ User::factory()->create(['department_id' => $department->id]);
+
+ $this->actingAsForApi(User::factory()->superuser()->create())
+ ->getJson(route('api.departments.show', $department))
+ ->assertOk()
+ ->assertJsonPath('available_actions.bulk_selectable.delete', false);
+ }
+}
diff --git a/tests/Feature/Departments/Ui/BulkDeleteDepartmentsTest.php b/tests/Feature/Departments/Ui/BulkDeleteDepartmentsTest.php
new file mode 100644
index 0000000000..8263b09bd6
--- /dev/null
+++ b/tests/Feature/Departments/Ui/BulkDeleteDepartmentsTest.php
@@ -0,0 +1,107 @@
+<?php
+
+namespace Tests\Feature\Departments\Ui;
+
+use App\Models\Department;
+use App\Models\User;
+use Tests\TestCase;
+
+class BulkDeleteDepartmentsTest extends TestCase
+{
+ public function test_requires_permission()
+ {
+ $this->actingAs(User::factory()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [1, 2, 3],
+ ])
+ ->assertForbidden();
+ }
+
+ public function test_department_with_users_is_not_bulk_deleted()
+ {
+ $department = Department::factory()->create();
+ User::factory()->create(['department_id' => $department->id]);
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$department->id],
+ ]);
+
+ $this->assertModelExists($department);
+ $this->assertNotSoftDeleted($department);
+ }
+
+ public function test_deletable_departments_are_bulk_deleted()
+ {
+ $department1 = Department::factory()->create();
+ $department2 = Department::factory()->create();
+ $department3 = Department::factory()->create();
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$department1->id, $department2->id, $department3->id],
+ ])
+ ->assertRedirect(route('departments.index'));
+
+ $this->assertSoftDeleted($department1);
+ $this->assertSoftDeleted($department2);
+ $this->assertSoftDeleted($department3);
+ }
+
+ public function test_partial_success_deletes_the_clean_ones_and_reports_the_rest()
+ {
+ // One clean, one blocked by an assigned user. The clean one should soft-delete
+ // and the blocked one should surface in the multi-error flash bag.
+ $deletable = Department::factory()->create();
+ $blocked = Department::factory()->create();
+ User::factory()->create(['department_id' => $blocked->id]);
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$deletable->id, $blocked->id],
+ ])
+ ->assertRedirect(route('departments.index'))
+ ->assertSessionHas('success')
+ ->assertSessionHas('multi_error_messages');
+
+ $this->assertSoftDeleted($deletable);
+ $this->assertNotSoftDeleted($blocked);
+ }
+
+ public function test_nonexistent_ids_are_reported_and_do_not_break_the_batch()
+ {
+ $deletable = Department::factory()->create();
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$deletable->id, 999999],
+ ])
+ ->assertRedirect(route('departments.index'))
+ ->assertSessionHas('multi_error_messages');
+
+ $this->assertSoftDeleted($deletable);
+ }
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ // Single-item batch → singular success message.
+ $solo = Department::factory()->create();
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/departments/message.delete.bulk_success', 1, ['count' => 1]));
+
+ // Multi-item batch → plural success message with the count interpolated.
+ $a = Department::factory()->create();
+ $b = Department::factory()->create();
+ $c = Department::factory()->create();
+
+ $this->actingAs(User::factory()->deleteDepartments()->create())
+ ->post(route('departments.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/departments/message.delete.bulk_success', 3, ['count' => 3]));
+ }
+}
diff --git a/tests/Feature/Manufacturers/Ui/BulkDeleteManufacturersTest.php b/tests/Feature/Manufacturers/Ui/BulkDeleteManufacturersTest.php
index 5235f558c4..0ca23a8008 100644
--- a/tests/Feature/Manufacturers/Ui/BulkDeleteManufacturersTest.php
+++ b/tests/Feature/Manufacturers/Ui/BulkDeleteManufacturersTest.php
@@ -48,4 +48,25 @@ class BulkDeleteManufacturersTest extends TestCase implements TestsPermissionsRe
$this->assertSoftDeleted($manufacturer2);
$this->assertSoftDeleted($manufacturer3);
}
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ $solo = Manufacturer::factory()->create();
+
+ $this->actingAs(User::factory()->deleteManufacturers()->create())
+ ->post(route('manufacturers.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/manufacturers/message.delete.bulk_success', 1, ['count' => 1]));
+
+ $a = Manufacturer::factory()->create();
+ $b = Manufacturer::factory()->create();
+ $c = Manufacturer::factory()->create();
+
+ $this->actingAs(User::factory()->deleteManufacturers()->create())
+ ->post(route('manufacturers.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/manufacturers/message.delete.bulk_success', 3, ['count' => 3]));
+ }
}
diff --git a/tests/Feature/StatusLabels/Ui/BulkDeleteStatusLabelsTest.php b/tests/Feature/StatusLabels/Ui/BulkDeleteStatusLabelsTest.php
index 3e69e908f5..b879d0a216 100644
--- a/tests/Feature/StatusLabels/Ui/BulkDeleteStatusLabelsTest.php
+++ b/tests/Feature/StatusLabels/Ui/BulkDeleteStatusLabelsTest.php
@@ -82,4 +82,25 @@ class BulkDeleteStatusLabelsTest extends TestCase
$this->assertSoftDeleted($deletable);
}
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ $solo = Statuslabel::factory()->create();
+
+ $this->actingAs(User::factory()->deleteStatusLabels()->create())
+ ->post(route('statuslabels.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/statuslabels/message.delete.bulk_success', 1, ['count' => 1]));
+
+ $a = Statuslabel::factory()->create();
+ $b = Statuslabel::factory()->create();
+ $c = Statuslabel::factory()->create();
+
+ $this->actingAs(User::factory()->deleteStatusLabels()->create())
+ ->post(route('statuslabels.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/statuslabels/message.delete.bulk_success', 3, ['count' => 3]));
+ }
}
diff --git a/tests/Feature/Suppliers/Ui/BulkDeleteSuppliersTest.php b/tests/Feature/Suppliers/Ui/BulkDeleteSuppliersTest.php
index bf07145f72..07cf960cdf 100644
--- a/tests/Feature/Suppliers/Ui/BulkDeleteSuppliersTest.php
+++ b/tests/Feature/Suppliers/Ui/BulkDeleteSuppliersTest.php
@@ -49,4 +49,25 @@ class BulkDeleteSuppliersTest extends TestCase implements TestsPermissionsRequir
$this->assertSoftDeleted($supplier2);
$this->assertSoftDeleted($supplier3);
}
+
+ public function test_bulk_success_message_pluralizes_by_count()
+ {
+ $solo = Supplier::factory()->create();
+
+ $this->actingAs(User::factory()->deleteSuppliers()->create())
+ ->post(route('suppliers.bulk.delete'), [
+ 'ids' => [$solo->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/suppliers/message.delete.bulk_success', 1, ['count' => 1]));
+
+ $a = Supplier::factory()->create();
+ $b = Supplier::factory()->create();
+ $c = Supplier::factory()->create();
+
+ $this->actingAs(User::factory()->deleteSuppliers()->create())
+ ->post(route('suppliers.bulk.delete'), [
+ 'ids' => [$a->id, $b->id, $c->id],
+ ])
+ ->assertSessionHas('success', trans_choice('admin/suppliers/message.delete.bulk_success', 3, ['count' => 3]));
+ }
}