First steps in supporting email validation
This commit is contained in:
parent
08d7347f00
commit
c1638aeb98
@ -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);
|
||||
|
27
api/BusinessLogic/Tickets/VerifiedEmailChecker.php
Normal file
27
api/BusinessLogic/Tickets/VerifiedEmailChecker.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: cokoch
|
||||
* Date: 2/20/2017
|
||||
* Time: 12:40 PM
|
||||
*/
|
||||
|
||||
namespace BusinessLogic\Tickets;
|
||||
|
||||
|
||||
use DataAccess\Tickets\VerifiedEmailGateway;
|
||||
|
||||
class VerifiedEmailChecker {
|
||||
/**
|
||||
* @var $verifiedEmailGateway VerifiedEmailGateway
|
||||
*/
|
||||
private $verifiedEmailGateway;
|
||||
|
||||
function __construct($verifiedEmailGateway) {
|
||||
$this->verifiedEmailGateway = $verifiedEmailGateway;
|
||||
}
|
||||
|
||||
function isEmailVerified($emailAddress, $heskSettings) {
|
||||
return $this->verifiedEmailGateway->isEmailVerified($emailAddress, $heskSettings);
|
||||
}
|
||||
}
|
16
api/DataAccess/Tickets/VerifiedEmailGateway.php
Normal file
16
api/DataAccess/Tickets/VerifiedEmailGateway.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace DataAccess\Tickets;
|
||||
|
||||
|
||||
use DataAccess\CommonDao;
|
||||
|
||||
class VerifiedEmailGateway extends CommonDao {
|
||||
function isEmailVerified($emailAddress, $heskSettings) {
|
||||
$this->init();
|
||||
|
||||
$rs = hesk_dbQuery("SELECT 1 FROM `" . hesk_dbEscape($heskSettings['db_pfix']) . "verified_emails` WHERE `Email` = '" . hesk_dbEscape($emailAddress) . "'");
|
||||
|
||||
return hesk_dbNumRows($rs) > 0;
|
||||
}
|
||||
}
|
56
api/Tests/BusinessLogic/Tickets/VerifiedEmailCheckerTest.php
Normal file
56
api/Tests/BusinessLogic/Tickets/VerifiedEmailCheckerTest.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace BusinessLogic\Tickets;
|
||||
|
||||
|
||||
use DataAccess\Tickets\VerifiedEmailGateway;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class VerifiedEmailCheckerTest extends TestCase {
|
||||
/**
|
||||
* @var $verifiedEmailGateway \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $verifiedEmailGateway;
|
||||
|
||||
/**
|
||||
* @var $verifiedEmailChecker VerifiedEmailChecker
|
||||
*/
|
||||
private $verifiedEmailChecker;
|
||||
|
||||
/**
|
||||
* @var $heskSettings array
|
||||
*/
|
||||
private $heskSettings;
|
||||
|
||||
protected function setUp() {
|
||||
$this->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());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user