diff --git a/tests/Feature/RouteTest.php b/tests/Feature/RouteTest.php deleted file mode 100755 index 1f77bfb1e9..0000000000 --- a/tests/Feature/RouteTest.php +++ /dev/null @@ -1,23 +0,0 @@ -get('/'); - - $response->assertStatus(200); - } - -} diff --git a/tests/Unit/ArticleControllerTest.php b/tests/Unit/ArticleControllerTest.php index 7c02d78967..9c1e69eddb 100644 --- a/tests/Unit/ArticleControllerTest.php +++ b/tests/Unit/ArticleControllerTest.php @@ -29,8 +29,7 @@ public function setUp(): void //Create User -> Agent - //$str = Str::random(10); - $str = 'demopass'; + $str = Str::random(10); $password = Hash::make($str); $email = $faker->unique()->email(); $user = new User([ diff --git a/tests/Unit/ArtisanCommandTest.php b/tests/Unit/ArtisanCommandTest.php deleted file mode 100644 index f169ed216b..0000000000 --- a/tests/Unit/ArtisanCommandTest.php +++ /dev/null @@ -1,19 +0,0 @@ -artisan('route:list') - ->assertExitCode(0); - } -} diff --git a/tests/Unit/CategoryControllerTest.php b/tests/Unit/CategoryControllerTest.php index 808616e9aa..1e275085f6 100644 --- a/tests/Unit/CategoryControllerTest.php +++ b/tests/Unit/CategoryControllerTest.php @@ -26,8 +26,7 @@ public function setUp(): void //Create User -> Agent - //$str = Str::random(10); - $str = 'demopass'; + $str = Str::random(10); $password = Hash::make($str); $email = $faker->unique()->email(); $user = new User([ diff --git a/tests/Unit/PageControllerTest.php b/tests/Unit/PageControllerTest.php index 041e5ee8b8..aa2cb8db98 100644 --- a/tests/Unit/PageControllerTest.php +++ b/tests/Unit/PageControllerTest.php @@ -9,6 +9,7 @@ use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Tests\TestCase; +Use Illuminate\Support\Str; class PageControllerTest extends TestCase { @@ -23,8 +24,7 @@ public function setUp(): void //Create User -> Agent - //$str = Str::random(10); - $str = 'demopass'; + $str = Str::random(10); $password = Hash::make($str); $email = $faker->unique()->email(); $user = new User([ diff --git a/tests/Unit/TicketControllerTest.php b/tests/Unit/TicketControllerTest.php index 02efdf2225..9af5a5e9b5 100644 --- a/tests/Unit/TicketControllerTest.php +++ b/tests/Unit/TicketControllerTest.php @@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Lang; use Tests\TestCase; - +use Illuminate\Support\Str; class TicketControllerTest extends TestCase { /** @@ -23,8 +23,7 @@ public function test_tooltip() //Create User -> Agent - //$str = Str::random(10); - $str = 'demopass'; + $str = Str::random(10); $password = Hash::make($str); $email = $faker->unique()->email(); $user = new User([ @@ -137,4 +136,79 @@ public function test_reply() $response3->assertStatus(200); $response3->assertSee(Lang::get('lang.you_have_successfully_replied_to_your_ticket')); } + + public function test_user_change_the_status() + { + $faker = FakerFactory::create(); + + //Create User -> User + + $str = Str::random(10); + $password = Hash::make($str); + $email = $faker->unique()->email(); + $user = new User([ + 'first_name' => $faker->firstName(), + 'last_name' => $faker->lastName(), + 'email' => $email, + 'user_name' => $faker->unique()->userName(), + 'password' => $password, + 'active' => 1, + 'role' => 'user', + ]); + $user->save(); + + // Authenticate as the created user + + $this->actingAs($user); + + $ticket = new Tickets( + [ + 'ticket_number' => 'AAAA-0000-0001', + 'user_id' => $user->id, + 'priority_id' => 2, + 'sla' => 2, + 'help_topic_id' => 1, + 'status' => 1, + 'source' => 1, + ] + ); + + $ticket->save(); + $ticket->dept_id = 1; + $ticket->save(); + + $ticket_thread = new Ticket_Thread( + [ + 'ticket_id' => $ticket->id, + 'user_id' => $user->id, + 'poster' => 'client', + 'title' => 'TestCase', + 'body' => 'Testing', + ] + ); + $ticket_thread->save(); + + $mytickets = $this->get(route('ticket2')); + $mytickets->assertStatus(200); + + $response = $this->post(route('select_all'), [ + 'select_all' => [$ticket->id], + 'submit' => 'Open', + + ]); + + // Assert that the response status code indicates success + $response->assertStatus(302); // Adjust this as needed + + // Assert that the ticket's status has been updated to open + + $response->assertSessionHas('success', Lang::get('lang.tickets_have_been_opened')); + $response = $this->post(route('select_all'), [ + 'select_all' => [$ticket->id], + 'submit' => 'Close', + ]); + $response->assertStatus(302); // Adjust this as needed + $this->assertEquals(3, $ticket->fresh()->status); // Adjust this as needed + $response->assertSessionHas('success', Lang::get('lang.tickets_have_been_closed')); + } }