rename note to ticket
This commit is contained in:
parent
5f45d0a3c8
commit
0e2f6f944d
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
|
@ -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('*')
|
|
@ -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);
|
|
@ -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
|
||||
]);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue