Fix tests, remove ls from ci config

remotes/remote_mirror_8/master
Mike Koch 7 years ago
parent 2efa603474
commit 7300b5bd5f

@ -6,5 +6,4 @@ before_script:
test:app: test:app:
script: script:
- cd api/Tests - cd api/Tests
- ls
- phpunit - phpunit

@ -37,7 +37,7 @@ class AttachmentRetriever {
throw new ApiFriendlyException("Ticket {$ticketId} not found!", "Ticket Not Found", 404); 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}!"); 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\UserContext;
use BusinessLogic\Security\UserToTicketChecker; use BusinessLogic\Security\UserToTicketChecker;
use BusinessLogic\Tickets\Ticket;
use DataAccess\Attachments\AttachmentGateway; use DataAccess\Attachments\AttachmentGateway;
use DataAccess\Files\FileReader; use DataAccess\Files\FileReader;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
@ -55,6 +56,10 @@ class AttachmentRetrieverTest extends TestCase {
$this->fileReader->method('readFromFile') $this->fileReader->method('readFromFile')
->with('5', $this->heskSettings['attach_dir']) ->with('5', $this->heskSettings['attach_dir'])
->willReturn($attachmentContents); ->willReturn($attachmentContents);
$this->ticketGateway->method('getTicketById')
->willReturn(new Ticket());
$this->userToTicketChecker->method('isTicketAccessibleToUser')
->willReturn(true);
//-- Act //-- Act
$actualContents = $this->attachmentRetriever->getAttachmentContentsForTicket(0, 4, new UserContext(), $this->heskSettings); $actualContents = $this->attachmentRetriever->getAttachmentContentsForTicket(0, 4, new UserContext(), $this->heskSettings);

@ -39,6 +39,7 @@ class TicketDeleterTest extends TestCase {
function testItThrowsAnExceptionWhenTheUserDoesNotHavePermissionToDeleteTheTicket() { function testItThrowsAnExceptionWhenTheUserDoesNotHavePermissionToDeleteTheTicket() {
//-- Arrange //-- Arrange
$this->ticketGateway->method('getTicketById')->willReturn(new Ticket());
$this->userToTicketChecker->method('isTicketAccessibleToUser')->willReturn(false); $this->userToTicketChecker->method('isTicketAccessibleToUser')->willReturn(false);
//-- Assert //-- Assert

@ -3,6 +3,7 @@
namespace BusinessLogic\Tickets; namespace BusinessLogic\Tickets;
use BusinessLogic\Security\UserToTicketChecker;
use DataAccess\Tickets\TicketGateway; use DataAccess\Tickets\TicketGateway;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -13,14 +14,18 @@ class TicketRetrieverTest extends TestCase {
/* @var $ticketGateway \PHPUnit_Framework_MockObject_MockObject */ /* @var $ticketGateway \PHPUnit_Framework_MockObject_MockObject */
private $ticketGateway; private $ticketGateway;
/* @var $userToTicketChecker \PHPUnit_Framework_MockObject_MockObject */
private $userToTicketChecker;
/* @var $heskSettings array */ /* @var $heskSettings array */
private $heskSettings; private $heskSettings;
protected function setUp() { protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class); $this->ticketGateway = $this->createMock(TicketGateway::class);
$this->userToTicketChecker = $this->createMock(UserToTicketChecker::class);
$this->heskSettings = array('email_view_ticket' => 0); $this->heskSettings = array('email_view_ticket' => 0);
$this->ticketRetriever = new TicketRetriever($this->ticketGateway); $this->ticketRetriever = new TicketRetriever($this->ticketGateway, $this->userToTicketChecker);
} }
function testItGetsTheTicketByTrackingId() { function testItGetsTheTicketByTrackingId() {

@ -41,8 +41,8 @@ class TrackingIdGeneratorTest extends TestCase {
function testItThrowsAnExceptionWhenItWasUnableToGenerateAValidTrackingId() { function testItThrowsAnExceptionWhenItWasUnableToGenerateAValidTrackingId() {
//-- Arrange //-- Arrange
$exceptionThrown = false; $exceptionThrown = false;
$this->ticketGateway->method('getTicketByTrackingId') $this->ticketGateway->method('doesTicketExist')
->willReturn(new Ticket()); ->willReturn(true);
//-- Act //-- Act
try { try {

Loading…
Cancel
Save