Fix tests, remove ls from ci config
This commit is contained in:
parent
2efa603474
commit
7300b5bd5f
@ -6,5 +6,4 @@ before_script:
|
||||
test:app:
|
||||
script:
|
||||
- cd api/Tests
|
||||
- ls
|
||||
- phpunit
|
@ -37,7 +37,7 @@ class AttachmentRetriever {
|
||||
throw new ApiFriendlyException("Ticket {$ticketId} not found!", "Ticket Not Found", 404);
|
||||
}
|
||||
|
||||
if ($this->userToTicketChecker->isTicketAccessibleToUser($userContext, $ticket, $heskSettings)) {
|
||||
if (!$this->userToTicketChecker->isTicketAccessibleToUser($userContext, $ticket, $heskSettings)) {
|
||||
throw new AccessViolationException("User does not have access to attachment {$attachmentId}!");
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ namespace BusinessLogic\Attachments;
|
||||
|
||||
use BusinessLogic\Security\UserContext;
|
||||
use BusinessLogic\Security\UserToTicketChecker;
|
||||
use BusinessLogic\Tickets\Ticket;
|
||||
use DataAccess\Attachments\AttachmentGateway;
|
||||
use DataAccess\Files\FileReader;
|
||||
use DataAccess\Tickets\TicketGateway;
|
||||
@ -55,6 +56,10 @@ class AttachmentRetrieverTest extends TestCase {
|
||||
$this->fileReader->method('readFromFile')
|
||||
->with('5', $this->heskSettings['attach_dir'])
|
||||
->willReturn($attachmentContents);
|
||||
$this->ticketGateway->method('getTicketById')
|
||||
->willReturn(new Ticket());
|
||||
$this->userToTicketChecker->method('isTicketAccessibleToUser')
|
||||
->willReturn(true);
|
||||
|
||||
//-- Act
|
||||
$actualContents = $this->attachmentRetriever->getAttachmentContentsForTicket(0, 4, new UserContext(), $this->heskSettings);
|
||||
|
@ -39,6 +39,7 @@ class TicketDeleterTest extends TestCase {
|
||||
|
||||
function testItThrowsAnExceptionWhenTheUserDoesNotHavePermissionToDeleteTheTicket() {
|
||||
//-- Arrange
|
||||
$this->ticketGateway->method('getTicketById')->willReturn(new Ticket());
|
||||
$this->userToTicketChecker->method('isTicketAccessibleToUser')->willReturn(false);
|
||||
|
||||
//-- Assert
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace BusinessLogic\Tickets;
|
||||
|
||||
|
||||
use BusinessLogic\Security\UserToTicketChecker;
|
||||
use DataAccess\Tickets\TicketGateway;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -13,14 +14,18 @@ class TicketRetrieverTest extends TestCase {
|
||||
/* @var $ticketGateway \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $ticketGateway;
|
||||
|
||||
/* @var $userToTicketChecker \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userToTicketChecker;
|
||||
|
||||
/* @var $heskSettings array */
|
||||
private $heskSettings;
|
||||
|
||||
protected function setUp() {
|
||||
$this->ticketGateway = $this->createMock(TicketGateway::class);
|
||||
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
|
||||
$this->heskSettings = array('email_view_ticket' => 0);
|
||||
|
||||
$this->ticketRetriever = new TicketRetriever($this->ticketGateway);
|
||||
$this->ticketRetriever = new TicketRetriever($this->ticketGateway, $this->userToTicketChecker);
|
||||
}
|
||||
|
||||
function testItGetsTheTicketByTrackingId() {
|
||||
|
@ -41,8 +41,8 @@ class TrackingIdGeneratorTest extends TestCase {
|
||||
function testItThrowsAnExceptionWhenItWasUnableToGenerateAValidTrackingId() {
|
||||
//-- Arrange
|
||||
$exceptionThrown = false;
|
||||
$this->ticketGateway->method('getTicketByTrackingId')
|
||||
->willReturn(new Ticket());
|
||||
$this->ticketGateway->method('doesTicketExist')
|
||||
->willReturn(true);
|
||||
|
||||
//-- Act
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user