Fixes for tests

This commit is contained in:
David Bomba 2025-09-06 13:26:10 +10:00
parent 1f62b24e25
commit afa4bc461c
2 changed files with 8 additions and 15 deletions

View File

@ -434,21 +434,14 @@ class TaskRepository extends BaseRepository
public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $models, string $column, mixed $new_value): void public function bulkUpdate(\Illuminate\Database\Eloquent\Builder $models, string $column, mixed $new_value): void
{ {
nlog("xx");
nlog($models->pluck('id'));
nlog("yy");
// First, filter out tasks that have been invoiced // First, filter out tasks that have been invoiced
$models->whereNull('invoice_id'); $models->whereNull('invoice_id');
nlog($models->pluck('id'));
if(stripos($column, '_id') !== false) { if(stripos($column, '_id') !== false) {
$new_value = $this->decodePrimaryKey($new_value); $new_value = $this->decodePrimaryKey($new_value);
} }
nlog("setting column = " . $column . " to " . $new_value);
if ($column === 'project_id') { if ($column === 'project_id') {
// Handle project_id updates with client_id synchronization // Handle project_id updates with client_id synchronization
$project = Project::withTrashed() $project = Project::withTrashed()

View File

@ -102,7 +102,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::whereIn('id', [$task1->id, $task2->id]); $models = Task::whereIn('id', [$task1->id, $task2->id]);
// Bulk update project_id // Bulk update project_id
$this->taskRepository->bulkUpdate($models, 'project_id', $otherProject->id); $this->taskRepository->bulkUpdate($models, 'project_id', $otherProject->hashed_id);
// Refresh models from database // Refresh models from database
$task1->refresh(); $task1->refresh();
@ -164,7 +164,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::where('id', $task->id); $models = Task::where('id', $task->id);
// Bulk update client_id // Bulk update client_id
$this->taskRepository->bulkUpdate($models, 'client_id', $newClient->id); $this->taskRepository->bulkUpdate($models, 'client_id', $newClient->hashed_id);
// Refresh model from database // Refresh model from database
$task->refresh(); $task->refresh();
@ -197,7 +197,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::whereIn('id', [$task1->id, $task2->id]); $models = Task::whereIn('id', [$task1->id, $task2->id]);
// Bulk update assigned_user_id // Bulk update assigned_user_id
$this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->id); $this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->hashed_id);
// Refresh models from database // Refresh models from database
$task1->refresh(); $task1->refresh();
@ -238,7 +238,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::whereIn('id', [$invoicedTask->id, $regularTask->id]); $models = Task::whereIn('id', [$invoicedTask->id, $regularTask->id]);
// Bulk update assigned_user_id // Bulk update assigned_user_id
$this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->id); $this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->hashed_id);
// Refresh models from database // Refresh models from database
$invoicedTask->refresh(); $invoicedTask->refresh();
@ -269,7 +269,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::where('id', $task->id); $models = Task::where('id', $task->id);
// Bulk update project_id (should work with soft deleted project) // Bulk update project_id (should work with soft deleted project)
$this->taskRepository->bulkUpdate($models, 'project_id', $this->testProject->id); $this->taskRepository->bulkUpdate($models, 'project_id', $this->testProject->hashed_id);
// Refresh model from database // Refresh model from database
$task->refresh(); $task->refresh();
@ -324,7 +324,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$startTime = microtime(true); $startTime = microtime(true);
// Bulk update assigned_user_id // Bulk update assigned_user_id
$this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->id); $this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->hashed_id);
$endTime = microtime(true); $endTime = microtime(true);
$executionTime = $endTime - $startTime; $executionTime = $endTime - $startTime;
@ -345,7 +345,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::where('id', 99999); $models = Task::where('id', 99999);
// This should not throw an error // This should not throw an error
$this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->id); $this->taskRepository->bulkUpdate($models, 'assigned_user_id', $this->testUser->hashed_id);
// No assertions needed - just ensuring no exceptions are thrown // No assertions needed - just ensuring no exceptions are thrown
$this->assertTrue(true); $this->assertTrue(true);
@ -369,7 +369,7 @@ class TaskRepositoryBulkUpdateTest extends TestCase
$models = Task::where('id', $task->id); $models = Task::where('id', $task->id);
// Bulk update project_id (should work with soft deleted project) // Bulk update project_id (should work with soft deleted project)
$this->taskRepository->bulkUpdate($models, 'project_id', $this->testProject->id); $this->taskRepository->bulkUpdate($models, 'project_id', $this->testProject->hashed_id);
// Refresh model from database // Refresh model from database
$task->refresh(); $task->refresh();