From 6f990dd1de5d8a9f4ba4ac582da626805eca3d02 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 24 Sep 2025 15:27:16 -0700 Subject: [PATCH 1/4] adds an option to disable Auto assigned an actionlogs in factories --- .../factories/CheckoutAcceptanceFactory.php | 20 ++++++++++-- .../Email/AssetAcceptanceReminderTest.php | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php index bb56ab2b4a..5e0016763d 100644 --- a/database/factories/CheckoutAcceptanceFactory.php +++ b/database/factories/CheckoutAcceptanceFactory.php @@ -23,23 +23,39 @@ class CheckoutAcceptanceFactory extends Factory 'assigned_to_id' => User::factory(), ]; } + protected static bool $skipAutoAssign = false; + + public function withoutAutoAssign(): static + { + // turn off for this create() call + static::$skipAutoAssign = true; + + // ensure it turns back on AFTER creating + return $this->afterCreating(function () { + static::$skipAutoAssign = false; + }); + } public function configure(): static { return $this->afterCreating(function (CheckoutAcceptance $acceptance) { + if (static::$skipAutoAssign) { + return; // short-circuit + } if ($acceptance->checkoutable instanceof Asset) { $this->createdAssociatedActionLogEntry($acceptance); } if ($acceptance->checkoutable instanceof Asset && $acceptance->assignedTo instanceof User) { $acceptance->checkoutable->update([ - 'assigned_to' => $acceptance->assigned_to_id, - 'assigned_type' => get_class($acceptance->assignedTo), + 'assigned_to' => $acceptance->assigned_to_id, + 'assigned_type'=> get_class($acceptance->assignedTo), ]); } }); } + public function forAccessory() { return $this->state([ diff --git a/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php index deb3e07d2c..11afdaba4b 100644 --- a/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php +++ b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php @@ -86,7 +86,38 @@ class AssetAcceptanceReminderTest extends TestCase public function testReminderIsSentToUser() { +<<<<<<< Updated upstream $checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create(); +======= + $checkedOutBy = User::factory()->canViewReports()->create(); + + $checkoutTypes = [ + Asset::class => CheckoutAssetMail::class, + Accessory::class => CheckoutAccessoryMail::class, + LicenseSeat::class => CheckoutLicenseMail::class, + Consumable::class => CheckoutConsumableMail::class, + //for the future its setup for components, but we dont send reminders for components at the moment. +// Component::class => CheckoutComponentMail::class, + ]; + + $assignee = User::factory()->create(['email' => 'test@example.com']); + foreach ($checkoutTypes as $modelClass => $mailable) { + + $item = $modelClass::factory()->create(); + $acceptance = CheckoutAcceptance::factory()->withoutAutoAssign()->pending()->create([ + 'checkoutable_id' => $item->id, + 'checkoutable_type' => $modelClass, + 'assigned_to_id' => $assignee->id, + ]); + + if ($modelClass === LicenseSeat::class) { + $logType = License::class; + $logId = $item->license->id; + } else { + $logType = $modelClass; + $logId = $item->id; + } +>>>>>>> Stashed changes $this->actingAs(User::factory()->canViewReports()->create()) ->post($this->routeFor($checkoutAcceptance)) From 533d82d4d8f0cf8611c8beb7267687075ec33295 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 24 Sep 2025 15:34:02 -0700 Subject: [PATCH 2/4] remove unnecessary changes --- .../factories/CheckoutAcceptanceFactory.php | 2 +- .../Email/AssetAcceptanceReminderTest.php | 31 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php index 5e0016763d..b53885807f 100644 --- a/database/factories/CheckoutAcceptanceFactory.php +++ b/database/factories/CheckoutAcceptanceFactory.php @@ -25,7 +25,7 @@ class CheckoutAcceptanceFactory extends Factory } protected static bool $skipAutoAssign = false; - public function withoutAutoAssign(): static + public function withoutActionLog(): static { // turn off for this create() call static::$skipAutoAssign = true; diff --git a/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php index 11afdaba4b..deb3e07d2c 100644 --- a/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php +++ b/tests/Feature/Notifications/Email/AssetAcceptanceReminderTest.php @@ -86,38 +86,7 @@ class AssetAcceptanceReminderTest extends TestCase public function testReminderIsSentToUser() { -<<<<<<< Updated upstream $checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create(); -======= - $checkedOutBy = User::factory()->canViewReports()->create(); - - $checkoutTypes = [ - Asset::class => CheckoutAssetMail::class, - Accessory::class => CheckoutAccessoryMail::class, - LicenseSeat::class => CheckoutLicenseMail::class, - Consumable::class => CheckoutConsumableMail::class, - //for the future its setup for components, but we dont send reminders for components at the moment. -// Component::class => CheckoutComponentMail::class, - ]; - - $assignee = User::factory()->create(['email' => 'test@example.com']); - foreach ($checkoutTypes as $modelClass => $mailable) { - - $item = $modelClass::factory()->create(); - $acceptance = CheckoutAcceptance::factory()->withoutAutoAssign()->pending()->create([ - 'checkoutable_id' => $item->id, - 'checkoutable_type' => $modelClass, - 'assigned_to_id' => $assignee->id, - ]); - - if ($modelClass === LicenseSeat::class) { - $logType = License::class; - $logId = $item->license->id; - } else { - $logType = $modelClass; - $logId = $item->id; - } ->>>>>>> Stashed changes $this->actingAs(User::factory()->canViewReports()->create()) ->post($this->routeFor($checkoutAcceptance)) From 82bdd43168e548396d95038d081f330e4060d3d6 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Wed, 24 Sep 2025 15:38:30 -0700 Subject: [PATCH 3/4] renamed variable --- database/factories/CheckoutAcceptanceFactory.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/database/factories/CheckoutAcceptanceFactory.php b/database/factories/CheckoutAcceptanceFactory.php index b53885807f..1cd139176e 100644 --- a/database/factories/CheckoutAcceptanceFactory.php +++ b/database/factories/CheckoutAcceptanceFactory.php @@ -23,23 +23,23 @@ class CheckoutAcceptanceFactory extends Factory 'assigned_to_id' => User::factory(), ]; } - protected static bool $skipAutoAssign = false; + protected static bool $skipActionLog = false; public function withoutActionLog(): static { // turn off for this create() call - static::$skipAutoAssign = true; + static::$skipActionLog = true; // ensure it turns back on AFTER creating return $this->afterCreating(function () { - static::$skipAutoAssign = false; + static::$skipActionLog = false; }); } public function configure(): static { return $this->afterCreating(function (CheckoutAcceptance $acceptance) { - if (static::$skipAutoAssign) { + if (static::$skipActionLog) { return; // short-circuit } if ($acceptance->checkoutable instanceof Asset) { From 8af3cf4056a549263ac284b21defbbc754b8e79b Mon Sep 17 00:00:00 2001 From: William Kirstaedter Date: Mon, 29 Sep 2025 11:39:23 +0200 Subject: [PATCH 4/4] with --no-interactive, make composer non-interactive aswell --- upgrade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/upgrade.php b/upgrade.php index b98162ed96..eaf88bf931 100644 --- a/upgrade.php +++ b/upgrade.php @@ -62,6 +62,7 @@ if ($argc > 1){ break; case '--no-interactive': $no_interactive = true; + putenv("COMPOSER_NO_INTERACTION=1"); //put composer in non-interactive mode aswell break; default: // for legacy support from before we started using --branch $branch = $argv[$arg]; @@ -443,7 +444,8 @@ if ((strpos('git version', $git_version)) === false) { echo $git_fetch; echo '-- '.$git_stash; echo '-- '.$git_checkout; - echo '-- '.$git_pull."\n"; + echo '-- '.$git_pull; + echo "\n"; } else { echo "Git is NOT installed. You can still use this upgrade script to run common \n"; echo "migration commands, but you will have to manually download the updated files. \n\n";