Added_testcase
This commit is contained in:

committed by
KNaveenraj-ladybird

parent
f2cc9758b0
commit
0bd6f0b257
@@ -34,3 +34,4 @@
|
|||||||
<env name="DB_INSTALL" value="1"/>
|
<env name="DB_INSTALL" value="1"/>
|
||||||
</php>
|
</php>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
|
||||||
|
2
public/lb-faveo/css/bootstrap5.min.css
vendored
2
public/lb-faveo/css/bootstrap5.min.css
vendored
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@ namespace Tests\Unit;
|
|||||||
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
use App\Model\helpdesk\Ticket\Ticket_Thread;
|
||||||
use App\Model\helpdesk\Ticket\Tickets;
|
use App\Model\helpdesk\Ticket\Tickets;
|
||||||
use App\User;
|
use App\User;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Facades\Lang;
|
use Illuminate\Support\Facades\Lang;
|
||||||
@@ -14,6 +15,7 @@ class TicketControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic unit test example.
|
* A basic unit test example.
|
||||||
*
|
*
|
||||||
@@ -25,26 +27,27 @@ class TicketControllerTest extends TestCase
|
|||||||
$password = Hash::make($str);
|
$password = Hash::make($str);
|
||||||
$user = new User([
|
$user = new User([
|
||||||
'first_name' => 'a',
|
'first_name' => 'a',
|
||||||
'last_name' => 'noor',
|
'last_name' => 'noor',
|
||||||
'email' => 'naveen12@gmail.com',
|
'email' => 'naveen12@gmail.com',
|
||||||
'user_name' => 'noor',
|
'user_name' => 'noor',
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'active' => 1,
|
'active' => 1,
|
||||||
'role' => 'user',
|
'role' => 'user',
|
||||||
]);
|
]);
|
||||||
$user->save();
|
$user->save();
|
||||||
// Authenticate as the created user
|
// Authenticate as the created user
|
||||||
|
|
||||||
$this->actingAs($user);
|
$this->actingAs($user);
|
||||||
|
|
||||||
$ticket = new Tickets(
|
$ticket = new Tickets(
|
||||||
[
|
[
|
||||||
'ticket_number' => 'AAAA-0000-0001',
|
'ticket_number' => 'AAAA-0000-0001',
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'priority_id' => 2,
|
'priority_id' => 2,
|
||||||
'sla' => 2,
|
'sla' => 2,
|
||||||
'help_topic_id' => 1,
|
'help_topic_id' => 1,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'source' => 1,
|
'source' => 1
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$ticket->save();
|
$ticket->save();
|
||||||
@@ -54,20 +57,22 @@ class TicketControllerTest extends TestCase
|
|||||||
$ticket_thread = new Ticket_Thread(
|
$ticket_thread = new Ticket_Thread(
|
||||||
[
|
[
|
||||||
'ticket_id' => $ticket->id,
|
'ticket_id' => $ticket->id,
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'poster' => 'client',
|
'poster' => 'client',
|
||||||
'title' => 'TestCase',
|
'title' => 'TestCase',
|
||||||
'body' => 'Testing',
|
'body' => 'Testing',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$ticket_thread->save();
|
$ticket_thread->save();
|
||||||
|
|
||||||
|
|
||||||
$mytickets = $this->get(route('ticket2'));
|
$mytickets = $this->get(route('ticket2'));
|
||||||
$mytickets->assertStatus(200);
|
$mytickets->assertStatus(200);
|
||||||
|
|
||||||
$response = $this->post(route('select_all'), [
|
$response = $this->post(route('select_all'), [
|
||||||
'select_all' => [$ticket->id],
|
'select_all' => [$ticket->id],
|
||||||
'submit' => 'Open',
|
'submit' => 'Open',
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Assert that the response status code indicates success
|
// Assert that the response status code indicates success
|
||||||
@@ -78,10 +83,11 @@ class TicketControllerTest extends TestCase
|
|||||||
$response->assertSessionHas('success', Lang::get('lang.tickets_have_been_opened'));
|
$response->assertSessionHas('success', Lang::get('lang.tickets_have_been_opened'));
|
||||||
$response = $this->post(route('select_all'), [
|
$response = $this->post(route('select_all'), [
|
||||||
'select_all' => [$ticket->id],
|
'select_all' => [$ticket->id],
|
||||||
'submit' => 'Close',
|
'submit' => 'Close',
|
||||||
]);
|
]);
|
||||||
$response->assertStatus(302); // Adjust this as needed
|
$response->assertStatus(302); // Adjust this as needed
|
||||||
$this->assertEquals(3, $ticket->fresh()->status); // Adjust this as needed
|
$this->assertEquals(3, $ticket->fresh()->status); // Adjust this as needed
|
||||||
$response->assertSessionHas('success', Lang::get('lang.tickets_have_been_closed'));
|
$response->assertSessionHas('success', Lang::get('lang.tickets_have_been_closed'));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user