A free open source IT asset/license management system
Improve messaging
Marcus Mooree91229e3f999
diff --git a/app/Console/Commands/RegenerateAcceptances.php b/app/Console/Commands/RegenerateAcceptances.phpindex aa31d46903..82aec940b6 100644--- a/app/Console/Commands/RegenerateAcceptances.php+++ b/app/Console/Commands/RegenerateAcceptances.php@@ -315,6 +315,13 @@ class RegenerateAcceptances extends Command* Prints what the run re-requested, or under a dry run what it would have, followed* by the pairs it passed over and why.*+ * The declined line runs below the table it qualifies, and only on a run that is+ * re-asking decliners: it names the flag that would stop that, because including+ * them is decision 5's default and the one judgment on the report an operator might+ * want to reverse. Under `--exclude-declined` it is left out rather than reworded —+ * every declined pair is excluded under that flag, so the count would be identical+ * to the one heading the excluded table and would read as a second population.+ ** The closing tally is held back when a confirmation prompt is about to follow. The* wizard's preview is a real dry run, so it would otherwise sign off with "Nothing* was created." — and then ask whether to create anything, which reads as though the@@ -338,12 +345,14 @@ class RegenerateAcceptances extends Command$this->line(' '.$type.': '.$count);}- $this->info('Previously declined: '.$result->previouslyDeclined.'.');-if ($result->reportRows !== []) {$this->table(['User ID', 'User', 'Item', 'Item Type', 'Item ID', 'Units currently held', 'Units to re-request'], $result->reportRows);}+ if (! $result->excludeDeclined && $result->previouslyDeclined > 0) {+ $this->warn('Includes '.$result->previouslyDeclined.' previously declined that are being asked again.');+ }+$this->newLine();$this->info('Already covered by a pending request: '.$result->alreadyCovered.'.');diff --git a/tests/Feature/Console/RegenerateAcceptancesTest.php b/tests/Feature/Console/RegenerateAcceptancesTest.phpindex 4289659645..e55c8d0a28 100644--- a/tests/Feature/Console/RegenerateAcceptancesTest.php+++ b/tests/Feature/Console/RegenerateAcceptancesTest.php@@ -835,7 +835,7 @@ class RegenerateAcceptancesTest extends TestCase$this->artisan('snipeit:regenerate-acceptances', ['--no-interaction' => true])->expectsOutput('To re-request: 1.')- ->expectsOutput('Previously declined: 1.')+ ->expectsOutput('Includes 1 previously declined that are being asked again.')->assertExitCode(0);}@@ -850,7 +850,7 @@ class RegenerateAcceptancesTest extends TestCase$this->artisan('snipeit:regenerate-acceptances', ['--no-interaction' => true, '--exclude-declined' => true])->expectsOutput('To re-request: 0.')- ->expectsOutput('Previously declined: 1.')+ ->doesntExpectOutputToContain('being asked again')->expectsOutput('Previously declined and excluded: 1.')->expectsTable(['User ID', 'User', 'Item', 'Item Type', 'Item ID', 'Units currently held'],@@ -871,7 +871,26 @@ class RegenerateAcceptancesTest extends TestCase$this->artisan('snipeit:regenerate-acceptances', ['--no-interaction' => true, '--exclude-declined' => true])->expectsOutput('To re-request: 1.')- ->expectsOutput('Previously declined: 0.')+ ->expectsOutput('Previously declined and excluded: 0.')+ ->assertExitCode(0);+ }++ /**+ * A run with nobody to report says nothing, rather than reporting a population of+ * none. The sentence exists to flag a judgment the operator may want to reverse, and+ * there is no judgment to reverse when no holder ever declined.+ */+ public function test_no_declined_line_is_printed_when_nobody_declined(): void+ {+ $holder = User::factory()->create();+ $this->assetIn($this->acceptanceCategory('asset'), [+ 'assigned_to' => $holder->id,+ 'assigned_type' => User::class,+ ]);++ $this->artisan('snipeit:regenerate-acceptances', ['--no-interaction' => true])+ ->expectsOutput('To re-request: 1.')+ ->doesntExpectOutputToContain('previously declined')->assertExitCode(0);}@@ -1372,7 +1391,7 @@ class RegenerateAcceptancesTest extends TestCase->expectsOutput(' Accessory: 2')->expectsOutput(' Consumable: 1')->expectsOutput(' Component: 1')- ->expectsOutput('Previously declined: 1.')+ ->expectsOutput('Includes 1 previously declined that are being asked again.')->expectsOutput('Already covered by a pending request: 1.')->expectsOutput('Created: 8.')->assertExitCode(0);