Skip to content

Commit

Permalink
test_case_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KNaveenraj-ladybird committed Oct 26, 2023
1 parent c24911a commit f8450a8
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 51 deletions.
23 changes: 0 additions & 23 deletions tests/Feature/RouteTest.php

This file was deleted.

3 changes: 1 addition & 2 deletions tests/Unit/ArticleControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
19 changes: 0 additions & 19 deletions tests/Unit/ArtisanCommandTest.php

This file was deleted.

3 changes: 1 addition & 2 deletions tests/Unit/CategoryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/PageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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([
Expand Down
80 changes: 77 additions & 3 deletions tests/Unit/TicketControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand All @@ -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([
Expand Down Expand Up @@ -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'));
}
}

0 comments on commit f8450a8

Please sign in to comment.