chore: code refactor via rector

This commit is contained in:
idevakk
2025-11-14 02:01:01 -08:00
parent 90ab79b3a2
commit ae795880ed
148 changed files with 1520 additions and 1486 deletions

View File

@@ -2,6 +2,7 @@
namespace Tests\Unit\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Ticket;
use App\Models\TicketResponse;
use App\Models\User;
@@ -10,6 +11,8 @@ use Tests\TestCase;
class TicketResponseTest extends TestCase
{
public $user;
public $ticket;
protected function setUp(): void
{
parent::setUp();
@@ -19,7 +22,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_can_create_a_ticket_response_with_factory()
public function it_can_create_a_ticket_response_with_factory(): void
{
$response = TicketResponse::factory()->create();
@@ -28,7 +31,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_has_correct_fillable_attributes()
public function it_has_correct_fillable_attributes(): void
{
$responseData = [
'ticket_id' => $this->ticket->id,
@@ -37,7 +40,7 @@ class TicketResponseTest extends TestCase
'ip_address' => '192.168.1.1',
];
$response = TicketResponse::create($responseData);
$response = TicketResponse::query()->create($responseData);
foreach ($responseData as $key => $value) {
$this->assertEquals($value, $response->$key);
@@ -45,7 +48,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_belongs_to_a_ticket()
public function it_belongs_to_a_ticket(): void
{
$response = TicketResponse::factory()->create(['ticket_id' => $this->ticket->id]);
@@ -54,7 +57,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_belongs_to_a_user()
public function it_belongs_to_a_user(): void
{
$response = TicketResponse::factory()->create(['user_id' => $this->user->id]);
@@ -63,7 +66,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_casts_datetime_fields_correctly()
public function it_casts_datetime_fields_correctly(): void
{
$response = TicketResponse::factory()->create([
'created_at' => '2024-01-01 12:00:00',
@@ -75,7 +78,7 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_orders_responses_by_creation_date()
public function it_orders_responses_by_creation_date(): void
{
$oldResponse = TicketResponse::factory()->create([
'ticket_id' => $this->ticket->id,
@@ -86,8 +89,7 @@ class TicketResponseTest extends TestCase
'created_at' => now(),
]);
$responses = TicketResponse::where('ticket_id', $this->ticket->id)
->orderBy('created_at', 'asc')
$responses = TicketResponse::query()->where('ticket_id', $this->ticket->id)->oldest()
->get();
$this->assertEquals($oldResponse->id, $responses->first()->id);
@@ -95,33 +97,33 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_can_query_responses_by_ticket()
public function it_can_query_responses_by_ticket(): void
{
$response1 = TicketResponse::factory()->create([
TicketResponse::factory()->create([
'ticket_id' => $this->ticket->id,
]);
$response2 = TicketResponse::factory()->create([
TicketResponse::factory()->create([
'ticket_id' => $this->ticket->id,
]);
$ticketResponses = TicketResponse::where('ticket_id', $this->ticket->id)->get();
$ticketResponses = TicketResponse::query()->where('ticket_id', $this->ticket->id)->get();
$this->assertCount(2, $ticketResponses);
}
/** @test */
public function it_handles_long_responses()
public function it_handles_long_responses(): void
{
$longResponse = str_repeat('This is a very long response. ', 50);
$response = TicketResponse::factory()->create(['response' => $longResponse]);
$this->assertEquals($longResponse, $response->response);
$this->assertGreaterThan(500, strlen($response->response));
$this->assertGreaterThan(500, strlen((string) $response->response));
}
/** @test */
public function it_uses_correct_table_name()
public function it_uses_correct_table_name(): void
{
$response = new TicketResponse;
@@ -129,10 +131,10 @@ class TicketResponseTest extends TestCase
}
/** @test */
public function it_extends_model_class()
public function it_extends_model_class(): void
{
$response = new TicketResponse;
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Model::class, $response);
$this->assertInstanceOf(Model::class, $response);
}
}