From 0e2f6f944d8114e32f372a15f85e2bd84ff47dfb Mon Sep 17 00:00:00 2001 From: Finn Date: Sun, 22 Aug 2021 17:03:19 +0200 Subject: [PATCH] rename note to ticket --- lib/Controller/TicketApiController.php | 6 +++--- lib/Controller/TicketController.php | 6 +++--- lib/Db/{Note.php => Ticket.php} | 2 +- lib/Db/{NoteMapper.php => TicketMapper.php} | 8 ++++---- lib/Service/{NoteService.php => TicketService.php} | 12 ++++++------ tests/Integration/NoteIntegrationTest.php | 10 +++++----- tests/Unit/Controller/NoteControllerTest.php | 4 ++-- tests/Unit/Service/NoteServiceTest.php | 14 +++++++------- 8 files changed, 31 insertions(+), 31 deletions(-) rename lib/Db/{Note.php => Ticket.php} (83%) rename lib/Db/{NoteMapper.php => TicketMapper.php} (85%) rename lib/Service/{NoteService.php => TicketService.php} (89%) diff --git a/lib/Controller/TicketApiController.php b/lib/Controller/TicketApiController.php index 48c24bb..d2a9d6f 100644 --- a/lib/Controller/TicketApiController.php +++ b/lib/Controller/TicketApiController.php @@ -3,13 +3,13 @@ namespace OCA\UPschooling\Controller; use OCA\UPschooling\AppInfo\Application; -use OCA\UPschooling\Service\NoteService; +use OCA\UPschooling\Service\TicketService; use OCP\AppFramework\ApiController; use OCP\AppFramework\Http\DataResponse; use OCP\IRequest; class TicketApiController extends ApiController { - /** @var NoteService */ + /** @var TicketService */ private $service; /** @var string */ @@ -18,7 +18,7 @@ class TicketApiController extends ApiController { use Errors; public function __construct(IRequest $request, - NoteService $service, + TicketService $service, $userId) { parent::__construct(Application::APP_ID, $request); $this->service = $service; diff --git a/lib/Controller/TicketController.php b/lib/Controller/TicketController.php index b7a9066..2b3b55f 100644 --- a/lib/Controller/TicketController.php +++ b/lib/Controller/TicketController.php @@ -3,13 +3,13 @@ namespace OCA\UPschooling\Controller; use OCA\UPschooling\AppInfo\Application; -use OCA\UPschooling\Service\NoteService; +use OCA\UPschooling\Service\TicketService; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\IRequest; class TicketController extends Controller { - /** @var NoteService */ + /** @var TicketService */ private $service; /** @var string */ @@ -18,7 +18,7 @@ class TicketController extends Controller { use Errors; public function __construct(IRequest $request, - NoteService $service, + TicketService $service, $userId) { parent::__construct(Application::APP_ID, $request); $this->service = $service; diff --git a/lib/Db/Note.php b/lib/Db/Ticket.php similarity index 83% rename from lib/Db/Note.php rename to lib/Db/Ticket.php index 36e81a9..26f173d 100644 --- a/lib/Db/Note.php +++ b/lib/Db/Ticket.php @@ -6,7 +6,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; -class Note extends Entity implements JsonSerializable { +class Ticket extends Entity implements JsonSerializable { protected $title; protected $content; protected $userId; diff --git a/lib/Db/NoteMapper.php b/lib/Db/TicketMapper.php similarity index 85% rename from lib/Db/NoteMapper.php rename to lib/Db/TicketMapper.php index bd3ae2a..1f985b2 100644 --- a/lib/Db/NoteMapper.php +++ b/lib/Db/TicketMapper.php @@ -8,19 +8,19 @@ use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -class NoteMapper extends QBMapper { +class TicketMapper extends QBMapper { public function __construct(IDBConnection $db) { - parent::__construct($db, 'upschooling', Note::class); + parent::__construct($db, 'upschooling', Ticket::class); } /** * @param int $id * @param string $userId - * @return Entity|Note + * @return Entity|Ticket * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws DoesNotExistException */ - public function find(int $id, string $userId): Note { + public function find(int $id, string $userId): Ticket { /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $qb->select('*') diff --git a/lib/Service/NoteService.php b/lib/Service/TicketService.php similarity index 89% rename from lib/Service/NoteService.php rename to lib/Service/TicketService.php index 8f6e167..b2966f3 100644 --- a/lib/Service/NoteService.php +++ b/lib/Service/TicketService.php @@ -7,15 +7,15 @@ use Exception; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; -use OCA\UPschooling\Db\Note; -use OCA\UPschooling\Db\NoteMapper; +use OCA\UPschooling\Db\Ticket; +use OCA\UPschooling\Db\TicketMapper; -class NoteService { +class TicketService { - /** @var NoteMapper */ + /** @var TicketMapper */ private $mapper; - public function __construct(NoteMapper $mapper) { + public function __construct(TicketMapper $mapper) { $this->mapper = $mapper; } @@ -46,7 +46,7 @@ class NoteService { } public function create($title, $content, $userId) { - $note = new Note(); + $note = new Ticket(); $note->setTitle($title); $note->setContent($content); $note->setUserId($userId); diff --git a/tests/Integration/NoteIntegrationTest.php b/tests/Integration/NoteIntegrationTest.php index 69a6f8b..1a73d07 100644 --- a/tests/Integration/NoteIntegrationTest.php +++ b/tests/Integration/NoteIntegrationTest.php @@ -7,8 +7,8 @@ use OCP\IRequest; use PHPUnit\Framework\TestCase; -use OCA\UPschooling\Db\Note; -use OCA\UPschooling\Db\NoteMapper; +use OCA\UPschooling\Db\Ticket; +use OCA\UPschooling\Db\TicketMapper; use OCA\UPschooling\Controller\TicketController; class NoteIntegrationTest extends TestCase { @@ -31,12 +31,12 @@ class NoteIntegrationTest extends TestCase { }); $this->controller = $container->query(TicketController::class); - $this->mapper = $container->query(NoteMapper::class); + $this->mapper = $container->query(TicketMapper::class); } public function testUpdate() { // create a new note that should be updated - $note = new Note(); + $note = new Ticket(); $note->setTitle('old_title'); $note->setContent('old_content'); $note->setUserId($this->userId); @@ -44,7 +44,7 @@ class NoteIntegrationTest extends TestCase { $id = $this->mapper->insert($note)->getId(); // fromRow does not set the fields as updated - $updatedNote = Note::fromRow([ + $updatedNote = Ticket::fromRow([ 'id' => $id, 'user_id' => $this->userId ]); diff --git a/tests/Unit/Controller/NoteControllerTest.php b/tests/Unit/Controller/NoteControllerTest.php index aa0603a..bf4950a 100644 --- a/tests/Unit/Controller/NoteControllerTest.php +++ b/tests/Unit/Controller/NoteControllerTest.php @@ -8,7 +8,7 @@ use OCP\AppFramework\Http; use OCP\IRequest; use OCA\UPschooling\Service\NoteNotFound; -use OCA\UPschooling\Service\NoteService; +use OCA\UPschooling\Service\TicketService; use OCA\UPschooling\Controller\TicketController; class NoteControllerTest extends TestCase { @@ -19,7 +19,7 @@ class NoteControllerTest extends TestCase { public function setUp(): void { $this->request = $this->getMockBuilder(IRequest::class)->getMock(); - $this->service = $this->getMockBuilder(NoteService::class) + $this->service = $this->getMockBuilder(TicketService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = new TicketController($this->request, $this->service, $this->userId); diff --git a/tests/Unit/Service/NoteServiceTest.php b/tests/Unit/Service/NoteServiceTest.php index 416a079..51af8c5 100644 --- a/tests/Unit/Service/NoteServiceTest.php +++ b/tests/Unit/Service/NoteServiceTest.php @@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase; use OCP\AppFramework\Db\DoesNotExistException; -use OCA\UPschooling\Db\Note; -use OCA\UPschooling\Service\NoteService; -use OCA\UPschooling\Db\NoteMapper; +use OCA\UPschooling\Db\Ticket; +use OCA\UPschooling\Service\TicketService; +use OCA\UPschooling\Db\TicketMapper; class NoteServiceTest extends TestCase { private $service; @@ -17,15 +17,15 @@ class NoteServiceTest extends TestCase { private $userId = 'john'; public function setUp(): void { - $this->mapper = $this->getMockBuilder(NoteMapper::class) + $this->mapper = $this->getMockBuilder(TicketMapper::class) ->disableOriginalConstructor() ->getMock(); - $this->service = new NoteService($this->mapper); + $this->service = new TicketService($this->mapper); } public function testUpdate() { // the existing note - $note = Note::fromRow([ + $note = Ticket::fromRow([ 'id' => 3, 'title' => 'yo', 'content' => 'nope' @@ -36,7 +36,7 @@ class NoteServiceTest extends TestCase { ->will($this->returnValue($note)); // the note when updated - $updatedNote = Note::fromRow(['id' => 3]); + $updatedNote = Ticket::fromRow(['id' => 3]); $updatedNote->setTitle('title'); $updatedNote->setContent('content'); $this->mapper->expects($this->once())