diff --git a/tests/Unit/TicketControllerTest.php b/tests/Unit/TicketControllerTest.php
index b908b4209..349cf1a46 100644
--- a/tests/Unit/TicketControllerTest.php
+++ b/tests/Unit/TicketControllerTest.php
@@ -6,12 +6,13 @@ use App\Model\helpdesk\Ticket\Ticket_Thread;
use App\Model\helpdesk\Ticket\Tickets;
use App\User;
use DateTimeZone;
+use Faker\Factory as FakerFactory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Lang;
use Illuminate\Support\Str;
use Tests\TestCase;
use UTC;
-use Faker\Factory as FakerFactory;
+
class TicketControllerTest extends TestCase
{
/**
@@ -26,25 +27,25 @@ class TicketControllerTest extends TestCase
//Create User -> Agent
//$str = Str::random(10);
- $str ="demopass";
+ $str = 'demopass';
$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,
+ 'first_name' => $faker->firstName(),
+ 'last_name' => $faker->lastName(),
+ 'email' => $email,
+ 'user_name' => $faker->unique()->userName(),
+ 'password' => $password,
'assign_group' => 1,
- 'primary_dpt' => 1,
- 'active' => 1,
- 'role' => 'agent',
- 'agent_tzone'=> 81,
+ 'primary_dpt' => 1,
+ 'active' => 1,
+ 'role' => 'agent',
+ 'agent_tzone' => 81,
]);
$user->save();
// Check if data is inserted
- $this->assertDatabaseHas('users',['email'=>$email]);
+ $this->assertDatabaseHas('users', ['email'=>$email]);
// Authenticate as the created user
$this->actingAs($user);
@@ -52,86 +53,81 @@ class TicketControllerTest extends TestCase
$this->assertAuthenticated();
// Define the dashboard route name
- $dashboardRouteName = 'dashboard';
+ $dashboardRouteName = 'dashboard';
- // Generate the dashboard route URL
- $dashboardUrl = route($dashboardRouteName);
+ // Generate the dashboard route URL
+ $dashboardUrl = route($dashboardRouteName);
- // Simulate a GET request to the dashboard route
- $dashboardResponse = $this->get($dashboardUrl);
-
- // Assert that the response status code is 200 (OK)
- $dashboardResponse->assertStatus(200);
+ // Simulate a GET request to the dashboard route
+ $dashboardResponse = $this->get($dashboardUrl);
+ // Assert that the response status code is 200 (OK)
+ $dashboardResponse->assertStatus(200);
// Create a ticket for testing.
$ticket = new Tickets(
[
'ticket_number' => 'TEST-0000-000'.$faker->randomDigit(),
- 'user_id'=>$user->id,
- 'priority_id' => 2,
- 'sla' => 2,
+ 'user_id' => $user->id,
+ 'priority_id' => 2,
+ 'sla' => 2,
'help_topic_id' => 1,
- 'status' => 1,
- 'source'=>1,
+ 'status' => 1,
+ 'source' => 1,
]
);
$ticket->save();
- $ticket->dept_id =1;
+ $ticket->dept_id = 1;
$ticket->save();
-
- //Create Ticket_thread for Testing
+ //Create Ticket_thread for Testing
$ticket_thread = new Ticket_Thread(
[
'ticket_id' => $ticket->id,
- 'user_id' => $user->id,
- 'poster' =>'client',
- 'title' => 'TestCase2',
- 'body' =>'Testing2',
+ 'user_id' => $user->id,
+ 'poster' => 'client',
+ 'title' => 'TestCase2',
+ 'body' => 'Testing2',
]
);
$ticket_thread->save();
+ // Make a GET request to the getTooltip
+ $response = $this->get(route('ticket.tooltip', ['ticket_id' => $ticket->id]));
- // Make a GET request to the getTooltip
- $response = $this->get(route('ticket.tooltip', ['ticket_id' => $ticket->id]));
+ // Assert that the response status is 200 (OK).
+ $response->assertStatus(200);
- // Assert that the response status is 200 (OK).
- $response->assertStatus(200);
+ //Accessing Tooltip url
- //Accessing Tooltip url
+ $url = 'http://127.0.0.1:8000/ticket/tooltip?ticketid='.$ticket->id;
- $url = 'http://127.0.0.1:8000/ticket/tooltip?ticketid='.$ticket->id;
-
- $result = $this->get(url($url));
+ $result = $this->get(url($url));
// Define the expected tooltip content
- $expectedTooltip = '';
+ $expectedTooltip = '';
- $threads = $ticket->thread()->select('user_id', 'poster', 'body')->get();
- $numThreads = $threads->count();
+ $threads = $ticket->thread()->select('user_id', 'poster', 'body')->get();
+ $numThreads = $threads->count();
- foreach ($threads as $thread) {
- $expectedTooltip .= '' . $thread->user->user_name . ' (' . $thread->poster . ')'
- . $thread->purify() . '