Some changes

remotes/upstream/api-rewrite
Mike Koch 7 years ago
parent 672d089b20
commit 2201f188bd

@ -72,4 +72,9 @@ class CreateTicketByCustomerModel {
* @var string * @var string
*/ */
public $language; public $language;
/**
* @var $sendEmailToCustomer bool
*/
public $sendEmailToCustomer;
} }

@ -3,6 +3,10 @@
namespace BusinessLogic\Tickets\TicketCreatorTests; namespace BusinessLogic\Tickets\TicketCreatorTests;
use BusinessLogic\Emails\Addressees;
use BusinessLogic\Emails\EmailSenderHelper;
use BusinessLogic\Emails\EmailTemplate;
use BusinessLogic\Emails\EmailTemplateRetriever;
use BusinessLogic\Security\UserContext; use BusinessLogic\Security\UserContext;
use BusinessLogic\Statuses\DefaultStatusForAction; use BusinessLogic\Statuses\DefaultStatusForAction;
use BusinessLogic\Statuses\Status; use BusinessLogic\Statuses\Status;
@ -81,6 +85,11 @@ class CreateTicketTest extends TestCase {
*/ */
private $verifiedEmailChecker; private $verifiedEmailChecker;
/**
* @var $emailSenderHelper \PHPUnit_Framework_MockObject_MockObject
*/
private $emailSenderHelper;
protected function setUp() { protected function setUp() {
$this->ticketGateway = $this->createMock(TicketGateway::class); $this->ticketGateway = $this->createMock(TicketGateway::class);
$this->newTicketValidator = $this->createMock(NewTicketValidator::class); $this->newTicketValidator = $this->createMock(NewTicketValidator::class);
@ -88,9 +97,10 @@ class CreateTicketTest extends TestCase {
$this->autoassigner = $this->createMock(Autoassigner::class); $this->autoassigner = $this->createMock(Autoassigner::class);
$this->statusGateway = $this->createMock(StatusGateway::class); $this->statusGateway = $this->createMock(StatusGateway::class);
$this->verifiedEmailChecker = $this->createMock(VerifiedEmailChecker::class); $this->verifiedEmailChecker = $this->createMock(VerifiedEmailChecker::class);
$this->emailSenderHelper = $this->createMock(EmailSenderHelper::class);
$this->ticketCreator = new TicketCreator($this->newTicketValidator, $this->trackingIdGenerator, $this->ticketCreator = new TicketCreator($this->newTicketValidator, $this->trackingIdGenerator,
$this->autoassigner, $this->statusGateway, $this->ticketGateway, $this->verifiedEmailChecker); $this->autoassigner, $this->statusGateway, $this->ticketGateway, $this->verifiedEmailChecker, $this->emailSenderHelper);
$this->ticketRequest = new CreateTicketByCustomerModel(); $this->ticketRequest = new CreateTicketByCustomerModel();
$this->ticketRequest->name = 'Name'; $this->ticketRequest->name = 'Name';
@ -248,6 +258,16 @@ class CreateTicketTest extends TestCase {
} }
function testItSendsAnEmailToTheCustomerWhenTheTicketIsCreated() { function testItSendsAnEmailToTheCustomerWhenTheTicketIsCreated() {
//-- //-- Arrange
$this->ticketRequest->sendEmailToCustomer = true;
$expectedAddressees = new Addressees();
$expectedAddressees->to = $this->ticketRequest->email;
//-- Assert
$this->emailSenderHelper->expects($this->once())->method('sendEmailForTicket')
->with(EmailTemplateRetriever::NEW_TICKET, 'en', $this->anything(), $this->heskSettings, $this->modsForHeskSettings);
//-- Act
$this->ticketCreator->createTicketByCustomer($this->ticketRequest, $this->heskSettings, $this->modsForHeskSettings, $this->userContext);
} }
} }

Loading…
Cancel
Save