Apply fixes from StyleCI
This commit is contained in:
@@ -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,7 +27,7 @@ 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([
|
||||
@@ -39,12 +40,12 @@ class TicketControllerTest extends TestCase
|
||||
'primary_dpt' => 1,
|
||||
'active' => 1,
|
||||
'role' => 'agent',
|
||||
'agent_tzone'=> 81,
|
||||
'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);
|
||||
@@ -63,41 +64,38 @@ class TicketControllerTest extends TestCase
|
||||
// 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,
|
||||
'user_id' => $user->id,
|
||||
'priority_id' => 2,
|
||||
'sla' => 2,
|
||||
'help_topic_id' => 1,
|
||||
'status' => 1,
|
||||
'source'=>1,
|
||||
'source' => 1,
|
||||
]
|
||||
);
|
||||
|
||||
$ticket->save();
|
||||
$ticket->dept_id =1;
|
||||
$ticket->dept_id = 1;
|
||||
$ticket->save();
|
||||
|
||||
|
||||
//Create Ticket_thread for Testing
|
||||
|
||||
$ticket_thread = new Ticket_Thread(
|
||||
[
|
||||
'ticket_id' => $ticket->id,
|
||||
'user_id' => $user->id,
|
||||
'poster' =>'client',
|
||||
'poster' => 'client',
|
||||
'title' => 'TestCase2',
|
||||
'body' =>'Testing2',
|
||||
'body' => 'Testing2',
|
||||
]
|
||||
);
|
||||
|
||||
$ticket_thread->save();
|
||||
|
||||
|
||||
// Make a GET request to the getTooltip
|
||||
$response = $this->get(route('ticket.tooltip', ['ticket_id' => $ticket->id]));
|
||||
|
||||
@@ -118,16 +116,14 @@ class TicketControllerTest extends TestCase
|
||||
$numThreads = $threads->count();
|
||||
|
||||
foreach ($threads as $thread) {
|
||||
$expectedTooltip .= '<b>' . $thread->user->user_name . ' (' . $thread->poster . ')</b></br>'
|
||||
. $thread->purify() . '<br><hr>';
|
||||
$expectedTooltip .= '<b>'.$thread->user->user_name.' ('.$thread->poster.')</b></br>'
|
||||
.$thread->purify().'<br><hr>';
|
||||
}
|
||||
|
||||
$expectedTooltip .= 'This ticket has ' . $numThreads . ' threads.';
|
||||
$expectedTooltip .= 'This ticket has '.$numThreads.' threads.';
|
||||
|
||||
// Assert that the response content contains the expected tooltip content
|
||||
$result->assertSee($expectedTooltip,$escaped=false);
|
||||
|
||||
|
||||
$result->assertSee($expectedTooltip, $escaped = false);
|
||||
}
|
||||
|
||||
//Testing Reply Alert and Last Activity filed
|
||||
@@ -151,20 +147,18 @@ class TicketControllerTest extends TestCase
|
||||
|
||||
$url = route('ticket.thread', ['id' => $tickets->id]);
|
||||
|
||||
|
||||
$response2 = $this->get($url);
|
||||
|
||||
// Assert that the response status is 200 (OK).
|
||||
$response2->assertStatus(200);
|
||||
|
||||
|
||||
// Create fake data for the reply
|
||||
|
||||
$replyData = [
|
||||
'ticket_ID'=>$tickets->id,
|
||||
'ticket_ID' => $tickets->id,
|
||||
'reply_content' => $faker->paragraph,
|
||||
'created_at'=>date_default_timezone_set('UTC'),
|
||||
'updated_at'=>date_default_timezone_set('UTC'),
|
||||
'created_at' => date_default_timezone_set('UTC'),
|
||||
'updated_at' => date_default_timezone_set('UTC'),
|
||||
];
|
||||
|
||||
// Make a POST request to the route with the reply data
|
||||
@@ -181,14 +175,13 @@ class TicketControllerTest extends TestCase
|
||||
|
||||
$result_date = $response4->getDate();
|
||||
|
||||
$userTimeZone = new DateTimeZone("Asia/Kolkata");
|
||||
$userTimeZone = new DateTimeZone('Asia/Kolkata');
|
||||
|
||||
// Convert the DateTime object to the user's time zone
|
||||
|
||||
$result_date = $result_date->setTimezone($userTimeZone);
|
||||
|
||||
$result_date = $result_date->format("d/m/Y H:i:s");
|
||||
|
||||
$result_date = $result_date->format('d/m/Y H:i:s');
|
||||
|
||||
//Converting Updated_at to User Timezone
|
||||
|
||||
@@ -200,8 +193,6 @@ class TicketControllerTest extends TestCase
|
||||
|
||||
// Asserting if the last_activity is updated correctly
|
||||
|
||||
$this->assertEquals($expected_date,$result_date);
|
||||
|
||||
$this->assertEquals($expected_date, $result_date);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user