rename note to ticket

This commit is contained in:
Finn 2021-08-22 17:03:19 +02:00
parent 5f45d0a3c8
commit 0e2f6f944d
8 changed files with 31 additions and 31 deletions

View file

@ -3,13 +3,13 @@
namespace OCA\UPschooling\Controller; namespace OCA\UPschooling\Controller;
use OCA\UPschooling\AppInfo\Application; use OCA\UPschooling\AppInfo\Application;
use OCA\UPschooling\Service\NoteService; use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\ApiController; use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
class TicketApiController extends ApiController { class TicketApiController extends ApiController {
/** @var NoteService */ /** @var TicketService */
private $service; private $service;
/** @var string */ /** @var string */
@ -18,7 +18,7 @@ class TicketApiController extends ApiController {
use Errors; use Errors;
public function __construct(IRequest $request, public function __construct(IRequest $request,
NoteService $service, TicketService $service,
$userId) { $userId) {
parent::__construct(Application::APP_ID, $request); parent::__construct(Application::APP_ID, $request);
$this->service = $service; $this->service = $service;

View file

@ -3,13 +3,13 @@
namespace OCA\UPschooling\Controller; namespace OCA\UPschooling\Controller;
use OCA\UPschooling\AppInfo\Application; use OCA\UPschooling\AppInfo\Application;
use OCA\UPschooling\Service\NoteService; use OCA\UPschooling\Service\TicketService;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
class TicketController extends Controller { class TicketController extends Controller {
/** @var NoteService */ /** @var TicketService */
private $service; private $service;
/** @var string */ /** @var string */
@ -18,7 +18,7 @@ class TicketController extends Controller {
use Errors; use Errors;
public function __construct(IRequest $request, public function __construct(IRequest $request,
NoteService $service, TicketService $service,
$userId) { $userId) {
parent::__construct(Application::APP_ID, $request); parent::__construct(Application::APP_ID, $request);
$this->service = $service; $this->service = $service;

View file

@ -6,7 +6,7 @@ use JsonSerializable;
use OCP\AppFramework\Db\Entity; use OCP\AppFramework\Db\Entity;
class Note extends Entity implements JsonSerializable { class Ticket extends Entity implements JsonSerializable {
protected $title; protected $title;
protected $content; protected $content;
protected $userId; protected $userId;

View file

@ -8,19 +8,19 @@ use OCP\AppFramework\Db\QBMapper;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection; use OCP\IDBConnection;
class NoteMapper extends QBMapper { class TicketMapper extends QBMapper {
public function __construct(IDBConnection $db) { public function __construct(IDBConnection $db) {
parent::__construct($db, 'upschooling', Note::class); parent::__construct($db, 'upschooling', Ticket::class);
} }
/** /**
* @param int $id * @param int $id
* @param string $userId * @param string $userId
* @return Entity|Note * @return Entity|Ticket
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
* @throws DoesNotExistException * @throws DoesNotExistException
*/ */
public function find(int $id, string $userId): Note { public function find(int $id, string $userId): Ticket {
/* @var $qb IQueryBuilder */ /* @var $qb IQueryBuilder */
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();
$qb->select('*') $qb->select('*')

View file

@ -7,15 +7,15 @@ use Exception;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException; use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCA\UPschooling\Db\Note; use OCA\UPschooling\Db\Ticket;
use OCA\UPschooling\Db\NoteMapper; use OCA\UPschooling\Db\TicketMapper;
class NoteService { class TicketService {
/** @var NoteMapper */ /** @var TicketMapper */
private $mapper; private $mapper;
public function __construct(NoteMapper $mapper) { public function __construct(TicketMapper $mapper) {
$this->mapper = $mapper; $this->mapper = $mapper;
} }
@ -46,7 +46,7 @@ class NoteService {
} }
public function create($title, $content, $userId) { public function create($title, $content, $userId) {
$note = new Note(); $note = new Ticket();
$note->setTitle($title); $note->setTitle($title);
$note->setContent($content); $note->setContent($content);
$note->setUserId($userId); $note->setUserId($userId);

View file

@ -7,8 +7,8 @@ use OCP\IRequest;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use OCA\UPschooling\Db\Note; use OCA\UPschooling\Db\Ticket;
use OCA\UPschooling\Db\NoteMapper; use OCA\UPschooling\Db\TicketMapper;
use OCA\UPschooling\Controller\TicketController; use OCA\UPschooling\Controller\TicketController;
class NoteIntegrationTest extends TestCase { class NoteIntegrationTest extends TestCase {
@ -31,12 +31,12 @@ class NoteIntegrationTest extends TestCase {
}); });
$this->controller = $container->query(TicketController::class); $this->controller = $container->query(TicketController::class);
$this->mapper = $container->query(NoteMapper::class); $this->mapper = $container->query(TicketMapper::class);
} }
public function testUpdate() { public function testUpdate() {
// create a new note that should be updated // create a new note that should be updated
$note = new Note(); $note = new Ticket();
$note->setTitle('old_title'); $note->setTitle('old_title');
$note->setContent('old_content'); $note->setContent('old_content');
$note->setUserId($this->userId); $note->setUserId($this->userId);
@ -44,7 +44,7 @@ class NoteIntegrationTest extends TestCase {
$id = $this->mapper->insert($note)->getId(); $id = $this->mapper->insert($note)->getId();
// fromRow does not set the fields as updated // fromRow does not set the fields as updated
$updatedNote = Note::fromRow([ $updatedNote = Ticket::fromRow([
'id' => $id, 'id' => $id,
'user_id' => $this->userId 'user_id' => $this->userId
]); ]);

View file

@ -8,7 +8,7 @@ use OCP\AppFramework\Http;
use OCP\IRequest; use OCP\IRequest;
use OCA\UPschooling\Service\NoteNotFound; use OCA\UPschooling\Service\NoteNotFound;
use OCA\UPschooling\Service\NoteService; use OCA\UPschooling\Service\TicketService;
use OCA\UPschooling\Controller\TicketController; use OCA\UPschooling\Controller\TicketController;
class NoteControllerTest extends TestCase { class NoteControllerTest extends TestCase {
@ -19,7 +19,7 @@ class NoteControllerTest extends TestCase {
public function setUp(): void { public function setUp(): void {
$this->request = $this->getMockBuilder(IRequest::class)->getMock(); $this->request = $this->getMockBuilder(IRequest::class)->getMock();
$this->service = $this->getMockBuilder(NoteService::class) $this->service = $this->getMockBuilder(TicketService::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->controller = new TicketController($this->request, $this->service, $this->userId); $this->controller = new TicketController($this->request, $this->service, $this->userId);

View file

@ -7,9 +7,9 @@ use PHPUnit\Framework\TestCase;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCA\UPschooling\Db\Note; use OCA\UPschooling\Db\Ticket;
use OCA\UPschooling\Service\NoteService; use OCA\UPschooling\Service\TicketService;
use OCA\UPschooling\Db\NoteMapper; use OCA\UPschooling\Db\TicketMapper;
class NoteServiceTest extends TestCase { class NoteServiceTest extends TestCase {
private $service; private $service;
@ -17,15 +17,15 @@ class NoteServiceTest extends TestCase {
private $userId = 'john'; private $userId = 'john';
public function setUp(): void { public function setUp(): void {
$this->mapper = $this->getMockBuilder(NoteMapper::class) $this->mapper = $this->getMockBuilder(TicketMapper::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->service = new NoteService($this->mapper); $this->service = new TicketService($this->mapper);
} }
public function testUpdate() { public function testUpdate() {
// the existing note // the existing note
$note = Note::fromRow([ $note = Ticket::fromRow([
'id' => 3, 'id' => 3,
'title' => 'yo', 'title' => 'yo',
'content' => 'nope' 'content' => 'nope'
@ -36,7 +36,7 @@ class NoteServiceTest extends TestCase {
->will($this->returnValue($note)); ->will($this->returnValue($note));
// the note when updated // the note when updated
$updatedNote = Note::fromRow(['id' => 3]); $updatedNote = Ticket::fromRow(['id' => 3]);
$updatedNote->setTitle('title'); $updatedNote->setTitle('title');
$updatedNote->setContent('content'); $updatedNote->setContent('content');
$this->mapper->expects($this->once()) $this->mapper->expects($this->once())