Skip to content

Commit

Permalink
Clean up Ticket Models and factories (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohns authored Dec 12, 2024
1 parent 9ef04bd commit b8d8977
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Inensus\Ticket\Factories;
namespace Database\Factories\Inensus\Ticket\Models;

use Illuminate\Database\Eloquent\Factories\Factory;
use Inensus\Ticket\Models\TicketCategory;
Expand Down
24 changes: 0 additions & 24 deletions src/backend/database/factories/TicketBoardFactory.php

This file was deleted.

23 changes: 0 additions & 23 deletions src/backend/database/factories/TicketCardFactory.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/backend/database/seeders/TicketSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(
*/
public function run() {
// Create Ticket categories
TicketCategory::newFactory()
TicketCategory::factory()
->count(2)
->sequence(
[
Expand Down
4 changes: 0 additions & 4 deletions src/backend/packages/inensus/ticket/src/Models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class Ticket extends BaseModel {
'waiting' => 2,
];

public function card() {
return $this->belongsTo(TicketCard::class);
}

public function category(): BelongsTo {
return $this->belongsTo(TicketCategory::class, 'category_id');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@

namespace Inensus\Ticket\Models;

use Illuminate\Database\Eloquent\Factories\Factory;
use Inensus\Ticket\Factories\TicketCategoryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class TicketCategory extends BaseModel {
/**
* Create a new factory instance for the model.
*/
protected static function newFactory(): Factory {
return TicketCategoryFactory::new();
}
use HasFactory;

protected $table = 'ticket_categories';
}
8 changes: 0 additions & 8 deletions src/backend/tests/Feature/AgentAppTicketsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public function testAgentGetsTicketList() {
$this->createAgent();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$ticketCount = 1;
$this->createTicket($ticketCount, 1, $this->person->id, $this->agent->id);
$response = $this->actingAs($this->agent)->get('/api/app/agents/ticket');
Expand All @@ -29,8 +27,6 @@ public function testAgentGetsTicketById() {
$this->createAgent();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$ticketCount = 1;
$this->createTicket($ticketCount, 1, $this->person->id, $this->agent->id);

Expand All @@ -46,8 +42,6 @@ public function testAgentGetsTicketCustomerId() {
$this->createAgent();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$ticketCount = 1;
$this->createTicket($ticketCount, 1, $this->person->id, $this->agent->id);
$response = $this->actingAs($this->agent)->get(sprintf(
Expand All @@ -66,8 +60,6 @@ public function testAgentCreatesATicket() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();

$postData = [
'owner_id' => $this->person->id,
Expand Down
20 changes: 5 additions & 15 deletions src/backend/tests/Feature/CreateEnvironments.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
use Database\Factories\CompanyFactory;
use Database\Factories\ConnectionGroupFactory;
use Database\Factories\ConnectionTypeFactory;
use Database\Factories\Inensus\Ticket\Models\TicketCategoryFactory;
use Database\Factories\ManufacturerFactory;
use Database\Factories\MeterFactory;
use Database\Factories\Meter\MeterFactory;
use Database\Factories\Meter\MeterTariffFactory;
use Database\Factories\Meter\MeterTypeFactory;
use Database\Factories\MeterParameterFactory;
use Database\Factories\MeterTariffFactory;
use Database\Factories\MeterTokenFactory;
use Database\Factories\MeterTypeFactory;
use Database\Factories\MiniGridFactory;
use Database\Factories\PaymentHistoryFactory;
use Database\Factories\PersonFactory;
use Database\Factories\Person\PersonFactory;
use Database\Factories\SubConnectionTypeFactory;
use Database\Factories\SubTargetFactory;
use Database\Factories\TargetFactory;
use Database\Factories\TicketBoardFactory;
use Database\Factories\TicketCardFactory;
use Database\Factories\TicketCategoryFactory;
use Database\Factories\TicketFactory;
use Database\Factories\TicketUserFactory;
use Database\Factories\TimeOfUsageFactory;
Expand Down Expand Up @@ -747,14 +745,6 @@ protected function createTicket($ticketCount = 1, $status = 0, $customerId = nul
}
}

protected function createTicketBoard() {
$this->ticketBoard = TicketBoardFactory::new()->create();
}

protected function createTicketCard() {
$this->ticketCard = TicketCardFactory::new()->create();
}

protected function createTicketOutsourceReport($ticketOutSourceReportCount = 1) {
while ($ticketOutSourceReportCount > 0) {
}
Expand Down
14 changes: 0 additions & 14 deletions src/backend/tests/Feature/TicketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ public function testUserCreatesATicket() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();

$postData = [
'owner_id' => $this->person->id,
Expand All @@ -57,8 +55,6 @@ public function testUserGetsTicketList() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id);
$response = $this->actingAs($this->user)->get('/tickets');
$response->assertStatus(200);
Expand All @@ -70,8 +66,6 @@ public function testUserGetsTicketByTrelloId() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id);
$trelloId = $this->ticket->ticket_id;
$response = $this->actingAs($this->user)->get(sprintf('/tickets/%s', $trelloId));
Expand All @@ -85,8 +79,6 @@ public function testUserClosesATicket() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id);
$ticketId = $this->ticket->id;
$trelloId = $this->ticket->ticket_id;
Expand All @@ -102,8 +94,6 @@ public function testUserGetsAgentsTicketList() {
$this->createAgent();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id, $this->agent->id);
$response = $this->actingAs($this->user)->get(sprintf('/tickets/api/agents/%s', $this->agent->id));
$response->assertStatus(200);
Expand Down Expand Up @@ -141,8 +131,6 @@ public function testUserGetsTicketListForACustomer() {
$this->createAgent();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id);
$response = $this->actingAs($this->user)->get(sprintf('/tickets/api/tickets/user/%s', $this->person->id));
$response->assertStatus(200);
Expand All @@ -154,8 +142,6 @@ public function testUserAddsCommentToTicketByTrelloId() {
$this->createPerson();
$this->createTicketCategory();
$this->createTicketUser();
$this->createTicketBoard();
$this->createTicketCard();
$this->createTicket(1, 1, $this->person->id);
$trelloId = $this->ticket->ticket_id;
$postData = [
Expand Down

0 comments on commit b8d8977

Please sign in to comment.