diff --git a/api/BusinessLogic/Tickets/TicketCreator.php b/api/BusinessLogic/Tickets/TicketCreator.php index 7d6c5687..ed0797d2 100644 --- a/api/BusinessLogic/Tickets/TicketCreator.php +++ b/api/BusinessLogic/Tickets/TicketCreator.php @@ -47,9 +47,10 @@ class TicketCreator { * @param $ticketRequest CreateTicketByCustomerModel * @param $heskSettings array HESK settings * @param $modsForHeskSettings array Mods for HESK settings + * @param $userContext * @return Ticket The newly created ticket * @throws ValidationException When a required field in $ticket_request is missing - * + * @throws \Exception When the default status for new tickets is not found */ function createTicketByCustomer($ticketRequest, $heskSettings, $modsForHeskSettings, $userContext) { $validationModel = $this->newTicketValidator->validateNewTicketForCustomer($ticketRequest, $heskSettings, $userContext); diff --git a/api/BusinessLogic/Tickets/VerifiedEmailChecker.php b/api/BusinessLogic/Tickets/VerifiedEmailChecker.php new file mode 100644 index 00000000..fccb32fc --- /dev/null +++ b/api/BusinessLogic/Tickets/VerifiedEmailChecker.php @@ -0,0 +1,27 @@ +verifiedEmailGateway = $verifiedEmailGateway; + } + + function isEmailVerified($emailAddress, $heskSettings) { + return $this->verifiedEmailGateway->isEmailVerified($emailAddress, $heskSettings); + } +} \ No newline at end of file diff --git a/api/DataAccess/Tickets/VerifiedEmailGateway.php b/api/DataAccess/Tickets/VerifiedEmailGateway.php new file mode 100644 index 00000000..4fa0667b --- /dev/null +++ b/api/DataAccess/Tickets/VerifiedEmailGateway.php @@ -0,0 +1,16 @@ +init(); + + $rs = hesk_dbQuery("SELECT 1 FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "verified_emails` WHERE `Email` = '" . hesk_dbEscape($emailAddress) . "'"); + + return hesk_dbNumRows($rs) > 0; + } +} \ No newline at end of file diff --git a/api/Tests/BusinessLogic/Tickets/VerifiedEmailCheckerTest.php b/api/Tests/BusinessLogic/Tickets/VerifiedEmailCheckerTest.php new file mode 100644 index 00000000..2cf838c5 --- /dev/null +++ b/api/Tests/BusinessLogic/Tickets/VerifiedEmailCheckerTest.php @@ -0,0 +1,56 @@ +verifiedEmailGateway = $this->createMock(VerifiedEmailGateway::class); + $this->heskSettings = array(); + $this->verifiedEmailChecker = new VerifiedEmailChecker($this->verifiedEmailGateway); + } + + function testItGetsTheValidationStateFromTheGatewayWhenItItTrue() { + //-- Arrange + $this->verifiedEmailGateway->method('isEmailVerified') + ->with('some email', $this->heskSettings) + ->willReturn(true); + + //-- Act + $actual = $this->verifiedEmailChecker->isEmailVerified('some email', $this->heskSettings); + + //-- Assert + self::assertThat($actual, self::isTrue()); + } + + function testItGetsTheValidationStateFromTheGatewayWhenItItFalse() { + //-- Arrange + $this->verifiedEmailGateway->method('isEmailVerified') + ->with('some email', $this->heskSettings) + ->willReturn(false); + + //-- Act + $actual = $this->verifiedEmailChecker->isEmailVerified('some email', $this->heskSettings); + + //-- Assert + self::assertThat($actual, self::isFalse()); + } +}