From 0327e71f0f7fee210415ddd88454e786a3f60135 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Tue, 21 May 2024 13:26:29 -0700 Subject: [PATCH] made message the keys, cleaned up array --- tests/Unit/Helpers/HelperTest.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/Unit/Helpers/HelperTest.php b/tests/Unit/Helpers/HelperTest.php index 00d8f1f5d..3ef114b79 100644 --- a/tests/Unit/Helpers/HelperTest.php +++ b/tests/Unit/Helpers/HelperTest.php @@ -28,56 +28,52 @@ class HelperTest extends TestCase $this->settings->set(['digit_separator' => '1.234,56']); $this->assertSame(12.34, Helper::ParseCurrency('12,34')); } - public function testGetRedirectOptionMethod(){ + public function testGetRedirectOptionMethod() + { $test_data = [ - [ + 'Option 2: redirect for user assigned to ' => [ 'request' =>(object) ['assigned_user' => 22], 'id' => 1, 'checkout_to_type' => 'user', 'redirect_option' => 2, 'table' => 'Assets', 'route' => route('users.show', 22), - 'message' => 'redirect option 2 for user assigned to failed.' ], - [ + 'Option 2: redirect location assigned to ' => [ 'request' =>(object) ['assigned_location' => 10], 'id' => 2, 'checkout_to_type' => 'location', 'redirect_option' => 2, 'table' => 'Locations', 'route' => route('locations.show', 10), - 'message' => 'redirect option 2 location assigned to failed.' ], - [ + 'Option 2: redirect back to asset assigned to ' => [ 'request' =>(object) ['assigned_asset' => 101], 'id' => 3, 'checkout_to_type' => 'asset', 'redirect_option' => 2, 'table' => 'Assets', 'route' => route('hardware.show', 101), - 'message' => 'redirect option 2 back to asset assigned to failed.' ], - [ + 'Option 1: redirect back to asset ' => [ 'request' =>(object) ['assigned_asset' => null], 'id' => 999, 'checkout_to_type' => null, 'redirect_option' => 1, 'table' => 'Assets', 'route' => route('hardware.show', 999), - 'message' => 'redirect option 1 back to asset failed.' ], - [ + 'Option 0: redirect back to index ' => [ 'request' =>(object) ['assigned_asset' => null], 'id' => null, 'checkout_to_type' => null, 'redirect_option' => 0, 'table' => 'Assets', 'route' => route('hardware.index'), - 'message' => 'redirect option 0 back to index failed.' ], ]; - foreach ($test_data as $data) { + foreach ($test_data as $scenario => $data ) { Session::put('redirect_option', $data['redirect_option']); Session::put('checkout_to_type', $data['checkout_to_type']); @@ -85,7 +81,7 @@ class HelperTest extends TestCase $redirect = Helper::getRedirectOption($data['request'],$data['id'], $data['table']); $this->assertInstanceOf(RedirectResponse::class, $redirect); - $this->assertEquals($data['route'], $redirect->getTargetUrl(), $data['message']); + $this->assertEquals($data['route'], $redirect->getTargetUrl(), $scenario.'failed.'); } } }