More PHP 5.4/5.3 fixes

master
Mike Koch 7 years ago
parent 016a50878d
commit 41cbdadb72
No known key found for this signature in database
GPG Key ID: 9BA5D7F8391455ED

@ -64,7 +64,7 @@ class CategoryHandler extends \BaseClass {
}
}
throw new \Exception("Newly created category {$id} lost! :O");
throw new \BaseException("Newly created category {$id} lost! :O");
}
/**
@ -145,7 +145,7 @@ class CategoryHandler extends \BaseClass {
}
}
throw new \Exception("Category {$category->id} vanished! :O");
throw new \BaseException("Category {$category->id} vanished! :O");
}
function deleteCategory($id, $userContext, $heskSettings) {
@ -154,7 +154,7 @@ class CategoryHandler extends \BaseClass {
}
if ($id === 1) {
throw new \Exception("Category 1 cannot be deleted!");
throw new \BaseException("Category 1 cannot be deleted!");
}
$this->ticketGateway->moveTicketsToDefaultCategory($id, $heskSettings);
@ -175,7 +175,7 @@ class CategoryHandler extends \BaseClass {
}
if ($category === null) {
throw new \Exception("Could not find category with ID {$id}!");
throw new \BaseException("Could not find category with ID {$id}!");
}
if ($direction === Direction::UP) {

@ -3,7 +3,6 @@
namespace BusinessLogic\Emails;
use BusinessLogic\Exceptions\ApiFriendlyException;
use BusinessLogic\Exceptions\EmailTemplateNotFoundException;
use BusinessLogic\Exceptions\InvalidEmailTemplateException;
use BusinessLogic\Statuses\DefaultStatusForAction;
@ -77,10 +76,10 @@ class EmailTemplateParser extends \BaseClass {
}
if ($fullLanguageName === null) {
throw new \Exception("Language code {$languageCode} did not return any valid HESK languages!");
throw new \BaseException("Language code {$languageCode} did not return any valid HESK languages!");
}
$subject = $this->parseSubject($subject, $ticket, $fullLanguageName, $heskSettings);
$subject = $this->parseSubject($subject, $ticket, $fullLanguageName, $heskSettings, $modsForHeskSettings);
$message = $this->parseMessage($template, $ticket, $fullLanguageName, $emailTemplate->forStaff, $heskSettings, $modsForHeskSettings, false);
$htmlMessage = $this->parseMessage($htmlTemplate, $ticket, $fullLanguageName, $emailTemplate->forStaff, $heskSettings, $modsForHeskSettings, true);
@ -117,11 +116,11 @@ class EmailTemplateParser extends \BaseClass {
* @return string
* @throws \Exception if common.inc.php isn't loaded
*/
private function parseSubject($subjectTemplate, $ticket, $language, $heskSettings) {
private function parseSubject($subjectTemplate, $ticket, $language, $heskSettings, $modsForHeskSettings) {
global $hesklang;
if (!function_exists('hesk_msgToPlain')) {
throw new \Exception("common.inc.php not loaded!");
throw new \BaseException("common.inc.php not loaded!");
}
if ($ticket === null) {
@ -131,7 +130,14 @@ class EmailTemplateParser extends \BaseClass {
// Status name and category name
$defaultStatus = $this->statusGateway->getStatusForDefaultAction(DefaultStatusForAction::NEW_TICKET, $heskSettings);
$statusName = $defaultStatus->localizedNames[$language];
$category = $this->categoryGateway->getAllCategories($heskSettings)[$ticket->categoryId];
$categories = $this->categoryGateway->getAllCategories($heskSettings, $modsForHeskSettings);
$category = null;
foreach ($categories as $innerCategory) {
if ($innerCategory->id === $ticket->categoryId) {
$category = $innerCategory;
break;
}
}
switch ($ticket->priorityId) {
case Priority::CRITICAL:
@ -173,7 +179,7 @@ class EmailTemplateParser extends \BaseClass {
global $hesklang;
if (!function_exists('hesk_msgToPlain')) {
throw new \Exception("common.inc.php not loaded!");
throw new \BaseException("common.inc.php not loaded!");
}
if ($ticket === null) {
@ -193,7 +199,17 @@ class EmailTemplateParser extends \BaseClass {
// Status name and category name
$defaultStatus = $this->statusGateway->getStatusForDefaultAction(DefaultStatusForAction::NEW_TICKET, $heskSettings);
$statusName = hesk_msgToPlain($defaultStatus->localizedNames[$language]);
$category = hesk_msgToPlain($this->categoryGateway->getAllCategories($heskSettings)[$ticket->categoryId]->name);
$categories = $this->categoryGateway->getAllCategories($heskSettings, $modsForHeskSettings);
$category = null;
foreach ($categories as $innerCategory) {
if ($innerCategory->id === $ticket->categoryId) {
$category = $innerCategory;
break;
}
}
$category = hesk_msgToPlain($category->name);
$owner = $this->userGateway->getUserById($ticket->ownerId, $heskSettings);
$ownerName = $owner === null ? $hesklang['unas'] : hesk_msgToPlain($owner->name);

@ -130,7 +130,7 @@ class TicketCreator extends \BaseClass {
$status = $this->statusGateway->getStatusForDefaultAction(DefaultStatusForAction::NEW_TICKET, $heskSettings);
if ($status === null) {
throw new \Exception("Could not find the default status for a new ticket!");
throw new \BaseException("Could not find the default status for a new ticket!");
}
$ticket->statusId = $status->id;

@ -9,6 +9,6 @@ class ValidationModel extends \BaseClass {
public $errorKeys;
function __construct() {
$this->errorKeys = [];
$this->errorKeys = array();
}
}

@ -14,7 +14,7 @@ class PublicAttachmentController extends \BaseClass {
self::verifyAttachmentsAreEnabled($hesk_settings);
/* @var $attachmentRetriever AttachmentRetriever */
$attachmentRetriever = $applicationContext->get(AttachmentRetriever::class);
$attachmentRetriever = $applicationContext->get(AttachmentRetriever::clazz());
$attachment = $attachmentRetriever->getAttachmentContentsForTrackingId($trackingId, $attachmentId, $userContext, $hesk_settings);

@ -18,7 +18,7 @@ class StaffTicketAttachmentsController extends \BaseClass {
$this->verifyAttachmentsAreEnabled($hesk_settings);
/* @var $attachmentRetriever AttachmentRetriever */
$attachmentRetriever = $applicationContext->get(AttachmentRetriever::class);
$attachmentRetriever = $applicationContext->get(AttachmentRetriever::clazz());
$contents = $attachmentRetriever->getAttachmentContentsForTicket($ticketId, $attachmentId, $userContext, $hesk_settings);
@ -37,7 +37,7 @@ class StaffTicketAttachmentsController extends \BaseClass {
$this->verifyAttachmentsAreEnabled($hesk_settings);
/* @var $attachmentHandler AttachmentHandler */
$attachmentHandler = $applicationContext->get(AttachmentHandler::class);
$attachmentHandler = $applicationContext->get(AttachmentHandler::clazz());
$createAttachmentForTicketModel = $this->createModel(JsonRetriever::getJsonData(), $ticketId);
@ -61,7 +61,7 @@ class StaffTicketAttachmentsController extends \BaseClass {
global $applicationContext, $hesk_settings, $userContext;
/* @var $attachmentHandler AttachmentHandler */
$attachmentHandler = $applicationContext->get(AttachmentHandler::class);
$attachmentHandler = $applicationContext->get(AttachmentHandler::clazz());
$attachmentHandler->deleteAttachmentFromTicket($ticketId, $attachmentId, $userContext, $hesk_settings);

@ -30,7 +30,7 @@ class CategoryController extends \BaseClass {
global $hesk_settings, $applicationContext, $userContext;
/* @var $categoryRetriever CategoryRetriever */
$categoryRetriever = $applicationContext->get(CategoryRetriever::class);
$categoryRetriever = $applicationContext->get(CategoryRetriever::clazz());
return $categoryRetriever->getAllCategories($hesk_settings, $userContext);
}
@ -43,7 +43,7 @@ class CategoryController extends \BaseClass {
$category = $this->buildCategoryFromJson($data);
/* @var $categoryHandler CategoryHandler */
$categoryHandler = $applicationContext->get(CategoryHandler::class);
$categoryHandler = $applicationContext->get(CategoryHandler::clazz());
$category = $categoryHandler->createCategory($category, $userContext, $hesk_settings);
@ -80,7 +80,7 @@ class CategoryController extends \BaseClass {
$category->id = intval($id);
/* @var $categoryHandler CategoryHandler */
$categoryHandler = $applicationContext->get(CategoryHandler::class);
$categoryHandler = $applicationContext->get(CategoryHandler::clazz());
$category = $categoryHandler->editCategory($category, $userContext, $hesk_settings);
@ -91,7 +91,7 @@ class CategoryController extends \BaseClass {
global $hesk_settings, $userContext, $applicationContext;
/* @var $categoryHandler CategoryHandler */
$categoryHandler = $applicationContext->get(CategoryHandler::class);
$categoryHandler = $applicationContext->get(CategoryHandler::clazz());
$categoryHandler->deleteCategory($id, $userContext, $hesk_settings);
@ -102,7 +102,7 @@ class CategoryController extends \BaseClass {
global $applicationContext, $hesk_settings;
/* @var $handler CategoryHandler */
$handler = $applicationContext->get(CategoryHandler::class);
$handler = $applicationContext->get(CategoryHandler::clazz());
$handler->sortCategory(intval($id), $direction, $hesk_settings);
}

@ -16,7 +16,7 @@ class CustomNavElementController extends InternalApiController {
self::staticCheckForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
output($handler->getAllCustomNavElements($hesk_settings));
}
@ -27,7 +27,7 @@ class CustomNavElementController extends InternalApiController {
self::staticCheckForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
$handler->sortCustomNavElement(intval($id), $direction, $hesk_settings);
}
@ -38,7 +38,7 @@ class CustomNavElementController extends InternalApiController {
$this->checkForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
output($handler->getCustomNavElement($id, $hesk_settings));
}
@ -49,7 +49,7 @@ class CustomNavElementController extends InternalApiController {
$this->checkForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
$data = JsonRetriever::getJsonData();
$element = $handler->createCustomNavElement($this->buildElementModel($data), $hesk_settings);
@ -63,7 +63,7 @@ class CustomNavElementController extends InternalApiController {
$this->checkForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
$data = JsonRetriever::getJsonData();
$handler->saveCustomNavElement($this->buildElementModel($data, $id), $hesk_settings);
@ -77,7 +77,7 @@ class CustomNavElementController extends InternalApiController {
$this->checkForInternalUseOnly();
/* @var $handler CustomNavElementHandler */
$handler = $applicationContext->get(CustomNavElementHandler::class);
$handler = $applicationContext->get(CustomNavElementHandler::clazz());
$handler->deleteCustomNavElement($id, $hesk_settings);

@ -10,7 +10,7 @@ class SettingsController extends \BaseClass {
global $applicationContext, $hesk_settings;
/* @var $settingsRetriever SettingsRetriever */
$settingsRetriever = $applicationContext->get(SettingsRetriever::class);
$settingsRetriever = $applicationContext->get(SettingsRetriever::clazz());
output($settingsRetriever->getAllSettings($hesk_settings));
}

@ -10,7 +10,7 @@ class StatusController extends \BaseClass {
global $applicationContext, $hesk_settings;
/* @var $statusRetriever StatusRetriever */
$statusRetriever = $applicationContext->get(StatusRetriever::class);
$statusRetriever = $applicationContext->get(StatusRetriever::clazz());
output($statusRetriever->getAllStatuses($hesk_settings));
}

@ -18,7 +18,7 @@ class CustomerTicketController extends \BaseClass {
$emailAddress = isset($_GET['email']) ? $_GET['email'] : null;
/* @var $ticketRetriever TicketRetriever */
$ticketRetriever = $applicationContext->get(TicketRetriever::class);
$ticketRetriever = $applicationContext->get(TicketRetriever::clazz());
output($ticketRetriever->getTicketByTrackingIdAndEmail($trackingId, $emailAddress, $hesk_settings));
}
@ -27,7 +27,7 @@ class CustomerTicketController extends \BaseClass {
global $applicationContext, $hesk_settings, $userContext;
/* @var $ticketCreator TicketCreator */
$ticketCreator = $applicationContext->get(TicketCreator::class);
$ticketCreator = $applicationContext->get(TicketCreator::clazz());
$jsonRequest = JsonRetriever::getJsonData();

@ -19,15 +19,15 @@ class ResendTicketEmailToCustomerController extends InternalApiController {
$this->checkForInternalUseOnly();
/* @var $ticketRetriever TicketRetriever */
$ticketRetriever = $applicationContext->get(TicketRetriever::class);
$ticketRetriever = $applicationContext->get(TicketRetriever::clazz());
$ticket = $ticketRetriever->getTicketById($ticketId, $hesk_settings, $userContext);
/* @var $modsForHeskSettingsGateway ModsForHeskSettingsGateway */
$modsForHeskSettingsGateway = $applicationContext->get(ModsForHeskSettingsGateway::class);
$modsForHeskSettingsGateway = $applicationContext->get(ModsForHeskSettingsGateway::clazz());
$modsForHeskSettings = $modsForHeskSettingsGateway->getAllSettings($hesk_settings);
/* @var $emailSender EmailSenderHelper */
$emailSender = $applicationContext->get(EmailSenderHelper::class);
$emailSender = $applicationContext->get(EmailSenderHelper::clazz());
$language = $ticket->language;

@ -15,7 +15,7 @@ class StaffTicketController extends \BaseClass {
global $applicationContext, $userContext, $hesk_settings;
/* @var $ticketRetriever TicketRetriever */
$ticketRetriever = $applicationContext->get(TicketRetriever::class);
$ticketRetriever = $applicationContext->get(TicketRetriever::clazz());
output($ticketRetriever->getTicketById($id, $hesk_settings, $userContext));
}
@ -24,7 +24,7 @@ class StaffTicketController extends \BaseClass {
global $applicationContext, $userContext, $hesk_settings;
/* @var $ticketDeleter TicketDeleter */
$ticketDeleter = $applicationContext->get(TicketDeleter::class);
$ticketDeleter = $applicationContext->get(TicketDeleter::clazz());
$ticketDeleter->deleteTicket($id, $userContext, $hesk_settings);
@ -35,7 +35,7 @@ class StaffTicketController extends \BaseClass {
global $applicationContext, $userContext, $hesk_settings;
/* @var $ticketEditor TicketEditor */
$ticketEditor = $applicationContext->get(TicketEditor::class);
$ticketEditor = $applicationContext->get(TicketEditor::clazz());
$jsonRequest = JsonRetriever::getJsonData();

@ -23,7 +23,7 @@ class FileReader extends \BaseClass {
$fileContents = file_get_contents($location);
if ($fileContents === false) {
throw new \Exception("Failed to read the file!");
throw new \BaseException("Failed to read the file!");
}
return $fileContents;

@ -17,7 +17,7 @@ class FileWriter extends \BaseClass {
$fileSize = file_put_contents($location, $contents);
if ($fileSize === false) {
throw new \Exception("Failed to save the file!");
throw new \BaseException("Failed to save the file!");
}
return $fileSize;

@ -224,7 +224,7 @@ class Link
*/
public static function before( $funcName, $params = null )
{
array_push( self::$beforeFuncs, [ $funcName, $params ]);
array_push( self::$beforeFuncs, array($funcName, $params));
}
/**
@ -236,6 +236,6 @@ class Link
*/
public static function after( $funcName, $params = null )
{
array_push( self::$afterFuncs, [ $funcName, $params ]);
array_push( self::$afterFuncs, array($funcName, $params));
}
}

@ -46,11 +46,11 @@ class AttachmentHandlerTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->attachmentGateway = $this->createMock(AttachmentGateway::class);
$this->fileWriter = $this->createMock(FileWriter::class);
$this->fileDeleter = $this->createMock(FileDeleter::class);
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->attachmentGateway = $this->createMock(AttachmentGateway::clazz());
$this->fileWriter = $this->createMock(FileWriter::clazz());
$this->fileDeleter = $this->createMock(FileDeleter::clazz());
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::clazz());
$this->heskSettings = array(
'attach_dir' => 'attachments',
'attachments' => array(
@ -78,7 +78,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->attachmentContents = null;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/CONTENTS_EMPTY/');
//-- Act
@ -91,7 +91,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->attachmentContents = '';
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/CONTENTS_EMPTY/');
//-- Act
@ -106,7 +106,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->attachmentContents = 'invalid base 64';
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/CONTENTS_NOT_BASE_64/');
//-- Act
@ -119,7 +119,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->displayName = null;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/DISPLAY_NAME_EMPTY/');
//-- Act
@ -132,7 +132,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->displayName = '';
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/DISPLAY_NAME_EMPTY/');
//-- Act
@ -145,7 +145,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->ticketId = null;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/TICKET_ID_MISSING/');
//-- Act
@ -158,7 +158,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->ticketId = 0;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/TICKET_ID_MISSING/');
//-- Act
@ -172,7 +172,7 @@ class AttachmentHandlerTest extends TestCase {
$this->createAttachmentForTicketModel->ticketId = 0;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/EXTENSION_NOT_PERMITTED/');
//-- Act
@ -186,7 +186,7 @@ class AttachmentHandlerTest extends TestCase {
$this->heskSettings['attachments']['max_size'] = 1;
//-- Assert
$this->expectException(ValidationException::class);
$this->expectException(ValidationException::clazz());
$this->expectExceptionMessageRegExp('/FILE_SIZE_TOO_LARGE/');
//-- Act
@ -261,7 +261,7 @@ class AttachmentHandlerTest extends TestCase {
->willReturn(false);
//-- Assert
$this->expectException(\Exception::class);
$this->expectException(\BaseException::clazz());
$this->expectExceptionMessage("User does not have access to ticket {$ticketId} being created / edited!");
//-- Act

@ -32,10 +32,10 @@ class AttachmentRetrieverTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->attachmentGateway = $this->createMock(AttachmentGateway::class);
$this->fileReader = $this->createMock(FileReader::class);
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
$this->attachmentGateway = $this->createMock(AttachmentGateway::clazz());
$this->fileReader = $this->createMock(FileReader::clazz());
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::clazz());
$this->heskSettings = array('attach_dir' => 'attachments');
$this->attachmentRetriever = new AttachmentRetriever($this->attachmentGateway, $this->fileReader,

@ -32,10 +32,10 @@ class CategoryHandlerTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->categoryGateway = $this->createMock(CategoryGateway::class);
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->permissionChecker = $this->createMock(PermissionChecker::class);
$this->modsForHeskSettingsGateway = $this->createMock(ModsForHeskSettingsGateway::class);
$this->categoryGateway = $this->createMock(CategoryGateway::clazz());
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->permissionChecker = $this->createMock(PermissionChecker::clazz());
$this->modsForHeskSettingsGateway = $this->createMock(ModsForHeskSettingsGateway::clazz());
$this->categoryHandler = new CategoryHandler($this->categoryGateway,
$this->ticketGateway,

@ -38,9 +38,9 @@ class EmailSenderHelperTest extends TestCase {
private $modsForHeskSettings;
protected function setUp() {
$this->emailTemplateParser = $this->createMock(EmailTemplateParser::class);
$this->basicEmailSender = $this->createMock(BasicEmailSender::class);
$this->mailgunEmailSender = $this->createMock(MailgunEmailSender::class);
$this->emailTemplateParser = $this->createMock(EmailTemplateParser::clazz());
$this->basicEmailSender = $this->createMock(BasicEmailSender::clazz());
$this->mailgunEmailSender = $this->createMock(MailgunEmailSender::clazz());
$this->heskSettings = array(
'languages' => array(
'English' => array('folder' => 'en')

@ -22,7 +22,7 @@ class BanRetrieverTests extends TestCase {
private $banRetriever;
protected function setUp() {
$this->banGateway = $this->createMock(BanGateway::class);
$this->banGateway = $this->createMock(BanGateway::clazz());
$this->banRetriever = new BanRetriever($this->banGateway);
}

@ -20,7 +20,7 @@ class UserToTicketCheckerTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->userGateway = $this->createMock(UserGateway::class);
$this->userGateway = $this->createMock(UserGateway::clazz());
$this->userToTicketChecker = new UserToTicketChecker($this->userGateway);
}

@ -28,8 +28,8 @@ class AutoassignerTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->categoryGateway = $this->createMock(CategoryGateway::class);
$this->userGateway = $this->createMock(UserGateway::class);
$this->categoryGateway = $this->createMock(CategoryGateway::clazz());
$this->userGateway = $this->createMock(UserGateway::clazz());
$this->autoassigner = new Autoassigner($this->categoryGateway, $this->userGateway);
$this->heskSettings = array(
'autoassign' => 1

@ -48,9 +48,9 @@ class NewTicketValidatorTest extends TestCase {
private $heskSettings = array();
function setUp() {
$this->banRetriever = $this->createMock(BanRetriever::class);
$this->categoryRetriever = $this->createMock(CategoryRetriever::class);
$this->ticketValidators = $this->createMock(TicketValidators::class);
$this->banRetriever = $this->createMock(BanRetriever::clazz());
$this->categoryRetriever = $this->createMock(CategoryRetriever::clazz());
$this->ticketValidators = $this->createMock(TicketValidators::clazz());
$this->newTicketValidator = new NewTicketValidator($this->categoryRetriever, $this->banRetriever, $this->ticketValidators);
$this->userContext = new UserContext();

@ -98,15 +98,15 @@ class CreateTicketTest extends TestCase {
private $modsForHeskSettings;
protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->newTicketValidator = $this->createMock(NewTicketValidator::class);
$this->trackingIdGenerator = $this->createMock(TrackingIdGenerator::class);
$this->autoassigner = $this->createMock(Autoassigner::class);
$this->statusGateway = $this->createMock(StatusGateway::class);
$this->verifiedEmailChecker = $this->createMock(VerifiedEmailChecker::class);
$this->emailSenderHelper = $this->createMock(EmailSenderHelper::class);
$this->userGateway = $this->createMock(UserGateway::class);
$this->modsForHeskSettingsGateway = $this->createMock(ModsForHeskSettingsGateway::class);
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->newTicketValidator = $this->createMock(NewTicketValidator::clazz());
$this->trackingIdGenerator = $this->createMock(TrackingIdGenerator::clazz());
$this->autoassigner = $this->createMock(Autoassigner::clazz());
$this->statusGateway = $this->createMock(StatusGateway::clazz());
$this->verifiedEmailChecker = $this->createMock(VerifiedEmailChecker::clazz());
$this->emailSenderHelper = $this->createMock(EmailSenderHelper::clazz());
$this->userGateway = $this->createMock(UserGateway::clazz());
$this->modsForHeskSettingsGateway = $this->createMock(ModsForHeskSettingsGateway::clazz());
$this->ticketCreator = new TicketCreator($this->newTicketValidator, $this->trackingIdGenerator,
$this->autoassigner, $this->statusGateway, $this->ticketGateway, $this->verifiedEmailChecker,

@ -30,9 +30,9 @@ class TicketDeleterTest extends TestCase {
private $userToTicketChecker;
protected function setUp() {
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->attachmentHandler = $this->createMock(AttachmentHandler::class);
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::clazz());
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->attachmentHandler = $this->createMock(AttachmentHandler::clazz());
$this->ticketDeleter = new TicketDeleter($this->ticketGateway, $this->userToTicketChecker, $this->attachmentHandler);
}
@ -43,7 +43,7 @@ class TicketDeleterTest extends TestCase {
$this->userToTicketChecker->method('isTicketAccessibleToUser')->willReturn(false);
//-- Assert
$this->expectException(\Exception::class);
$this->expectException(\BaseException::clazz());
$this->expectExceptionMessage("User does not have access to ticket 1");
//-- Act

@ -21,8 +21,8 @@ class TicketRetrieverTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::clazz());
$this->heskSettings = array('email_view_ticket' => 0);
$this->ticketRetriever = new TicketRetriever($this->ticketGateway, $this->userToTicketChecker);
@ -65,7 +65,7 @@ class TicketRetrieverTest extends TestCase {
$this->ticketGateway->method('getTicketByTrackingId')->with($trackingId, $this->heskSettings)->willReturn($ticket);
//-- Assert
$this->expectException(\Exception::class);
$this->expectException(\BaseException::clazz());
$this->expectExceptionMessage("Email 'email@example.com' entered in for ticket '12345' does not match!");
//-- Act

@ -18,7 +18,7 @@ class TicketValidatorsTest extends TestCase {
private $ticketValidator;
protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->ticketValidator = new TicketValidators($this->ticketGateway);
}

@ -19,7 +19,7 @@ class TrackingIdGeneratorTest extends TestCase {
private $trackingIdGenerator;
function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class);
$this->ticketGateway = $this->createMock(TicketGateway::clazz());
$this->trackingIdGenerator = new TrackingIdGenerator($this->ticketGateway);
}

@ -23,7 +23,7 @@ class VerifiedEmailCheckerTest extends TestCase {
private $heskSettings;
protected function setUp() {
$this->verifiedEmailGateway = $this->createMock(VerifiedEmailGateway::class);
$this->verifiedEmailGateway = $this->createMock(VerifiedEmailGateway::clazz());
$this->heskSettings = array();
$this->verifiedEmailChecker = new VerifiedEmailChecker($this->verifiedEmailGateway);
}

@ -183,10 +183,10 @@ Link::before('globalBefore');
Link::all(array(
// Categories
'/v1/categories/all' => action(\Controllers\Categories\CategoryController::clazz() . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::clazz(), [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::clazz() . '::sort', [RequestMethod::POST], SecurityHandler::INTERNAL),
'/v1/categories/all' => action(\Controllers\Categories\CategoryController::clazz() . '::printAllCategories', array(RequestMethod::GET), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories' => action(\Controllers\Categories\CategoryController::clazz(), array(RequestMethod::POST), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::clazz(), array(RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE), SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
'/v1-internal/categories/{i}/sort/{s}' => action(\Controllers\Categories\CategoryController::clazz() . '::sort', array(RequestMethod::POST), SecurityHandler::INTERNAL),
// Tickets
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::clazz(), RequestMethod::all()),
// Tickets - Staff
@ -230,7 +230,7 @@ Link::all(array(
* @return array The configured path
*/
function action($class, $requestMethods, $securityHandler = SecurityHandler::AUTH_TOKEN) {
return [$class, $class, $securityHandler, $requestMethods];
return array($class, $class, $securityHandler, $requestMethods);
}
class SecurityHandler {

@ -12,7 +12,7 @@ while test $# -gt 0; do
continue
fi
for file in `find $current -type f -not -path "*vendor/*" -name "*.php"` ; do
for file in `find $current -type f -not -path "*vendor/*" -not -path "api/Tests/*" -name "*.php"` ; do
RESULTS=`php -l $file`
echo $RESULTS

@ -31,7 +31,7 @@ if ($request_method == 'POST') {
if ($action == 'generate') {
$token = '';
$letter_array = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
$letter_array = array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');
// Pick 32 random characters. That will be the hash
for ($i = 0; $i < 32; $i++) {
$letter = $letter_array[rand(0, 15)];

Loading…
Cancel
Save