use DI getter shorthand
This commit is contained in:
parent
1558e0275e
commit
9de541eb6c
@ -36,9 +36,9 @@ class AdminOrder extends AdminSendController
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->item = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Order::class);
|
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.Order::class);
|
||||||
d3DicHandler::getInstance()->set(OrderRecipients::class.'.args.order', $this->item);
|
d3GetOxidDIC()->set(OrderRecipients::class.'.args.order', $this->item);
|
||||||
$this->itemRecipients = d3DicHandler::getInstance()->get(OrderRecipients::class);
|
$this->itemRecipients = d3GetOxidDIC()->get(OrderRecipients::class);
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ class AdminOrder extends AdminSendController
|
|||||||
*/
|
*/
|
||||||
protected function sendMessage(): string
|
protected function sendMessage(): string
|
||||||
{
|
{
|
||||||
d3DicHandler::getInstance()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
|
d3GetOxidDIC()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
|
||||||
/** @var Sms $sms */
|
/** @var Sms $sms */
|
||||||
$sms = d3DicHandler::getInstance()->get(Sms::class);
|
$sms = d3GetOxidDIC()->get(Sms::class);
|
||||||
return $sms->sendOrderMessage($this->item) ?
|
return $sms->sendOrderMessage($this->item) ?
|
||||||
(string) $this->getSuccessSentMessage($sms) :
|
(string) $this->getSuccessSentMessage($sms) :
|
||||||
$this->getUnsuccessfullySentMessage($sms);
|
$this->getUnsuccessfullySentMessage($sms);
|
||||||
|
@ -63,10 +63,10 @@ abstract class AdminSendController extends AdminController
|
|||||||
return $this->itemRecipients->getSmsRecipient();
|
return $this->itemRecipients->getSmsRecipient();
|
||||||
} catch (noRecipientFoundException $e) {
|
} catch (noRecipientFoundException $e) {
|
||||||
/** @var Language $lang */
|
/** @var Language $lang */
|
||||||
$lang = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Language::class);
|
$lang = d3GetOxidDIC()->get('d3ox.linkmobility.'.Language::class);
|
||||||
$message = $lang->translateString($e->getMessage());
|
$message = $lang->translateString($e->getMessage());
|
||||||
/** @var UtilsView $utilsView */
|
/** @var UtilsView $utilsView */
|
||||||
$utilsView = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.UtilsView::class);
|
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||||
$utilsView->addErrorToDisplay($message);
|
$utilsView->addErrorToDisplay($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ abstract class AdminSendController extends AdminController
|
|||||||
public function send(): void
|
public function send(): void
|
||||||
{
|
{
|
||||||
/** @var UtilsView $utilsView */
|
/** @var UtilsView $utilsView */
|
||||||
$utilsView = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.UtilsView::class);
|
$utilsView = d3GetOxidDIC()->get('d3ox.linkmobility.'.UtilsView::class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$utilsView->addErrorToDisplay($this->sendMessage());
|
$utilsView->addErrorToDisplay($this->sendMessage());
|
||||||
@ -95,16 +95,16 @@ abstract class AdminSendController extends AdminController
|
|||||||
protected function getMessageBody(): string
|
protected function getMessageBody(): string
|
||||||
{
|
{
|
||||||
/** @var Request $request */
|
/** @var Request $request */
|
||||||
$request = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.Request::class);
|
$request = d3GetOxidDIC()->get('d3ox.linkmobility.'.Request::class);
|
||||||
$messageBody = $request->getRequestEscapedParameter('messagebody');
|
$messageBody = $request->getRequestEscapedParameter('messagebody');
|
||||||
|
|
||||||
if (false === is_string($messageBody) || strlen(trim($messageBody)) <= 1) {
|
if (false === is_string($messageBody) || strlen(trim($messageBody)) <= 1) {
|
||||||
d3DicHandler::getInstance()->setParameter(
|
d3GetOxidDIC()->setParameter(
|
||||||
'd3ox.linkmobility.'.InvalidArgumentException::class.'.args.message',
|
'd3ox.linkmobility.'.InvalidArgumentException::class.'.args.message',
|
||||||
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH')
|
Registry::getLang()->translateString('D3LM_EXC_MESSAGE_NO_LENGTH')
|
||||||
);
|
);
|
||||||
/** @var InvalidArgumentException $exc */
|
/** @var InvalidArgumentException $exc */
|
||||||
$exc = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.InvalidArgumentException::class);
|
$exc = d3GetOxidDIC()->get('d3ox.linkmobility.'.InvalidArgumentException::class);
|
||||||
throw $exc;
|
throw $exc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ abstract class AdminSendController extends AdminController
|
|||||||
protected function getSuccessSentMessage(Sms $sms): successfullySentException
|
protected function getSuccessSentMessage(Sms $sms): successfullySentException
|
||||||
{
|
{
|
||||||
$smsCount = $sms->getResponse() ? $sms->getResponse()->getSmsCount() : 0;
|
$smsCount = $sms->getResponse() ? $sms->getResponse()->getSmsCount() : 0;
|
||||||
d3DicHandler::getInstance()->setParameter(successfullySentException::class.'.args.smscount', $smsCount);
|
d3GetOxidDIC()->setParameter(successfullySentException::class.'.args.smscount', $smsCount);
|
||||||
/** @var successfullySentException $exc */
|
/** @var successfullySentException $exc */
|
||||||
$exc = d3DicHandler::getInstance()->get(successfullySentException::class);
|
$exc = d3GetOxidDIC()->get(successfullySentException::class);
|
||||||
return $exc;
|
return $exc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ class AdminUser extends AdminSendController
|
|||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->item = d3DicHandler::getInstance()->get('d3ox.linkmobility.'.User::class);
|
$this->item = d3GetOxidDIC()->get('d3ox.linkmobility.'.User::class);
|
||||||
d3DicHandler::getInstance()->set(UserRecipients::class.".args.user", $this->item);
|
d3GetOxidDIC()->set(UserRecipients::class.".args.user", $this->item);
|
||||||
$this->itemRecipients = d3DicHandler::getInstance()->get(UserRecipients::class);
|
$this->itemRecipients = d3GetOxidDIC()->get(UserRecipients::class);
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ class AdminUser extends AdminSendController
|
|||||||
*/
|
*/
|
||||||
protected function sendMessage(): string
|
protected function sendMessage(): string
|
||||||
{
|
{
|
||||||
d3DicHandler::getInstance()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
|
d3GetOxidDIC()->setParameter(Sms::class.'.args.message', $this->getMessageBody());
|
||||||
/** @var Sms $sms */
|
/** @var Sms $sms */
|
||||||
$sms = d3DicHandler::getInstance()->get(Sms::class);
|
$sms = d3GetOxidDIC()->get(Sms::class);
|
||||||
return $sms->sendUserAccountMessage($this->item) ?
|
return $sms->sendUserAccountMessage($this->item) ?
|
||||||
(string) $this->getSuccessSentMessage($sms) :
|
(string) $this->getSuccessSentMessage($sms) :
|
||||||
$this->getUnsuccessfullySentMessage($sms);
|
$this->getUnsuccessfullySentMessage($sms);
|
||||||
|
@ -47,7 +47,7 @@ class AdminOrderTest extends AdminSend
|
|||||||
->onlyMethods(['load'])
|
->onlyMethods(['load'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$itemMock->method('load')->willReturn(true);
|
$itemMock->method('load')->willReturn(true);
|
||||||
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.Order::class, $itemMock);
|
d3GetOxidDIC()->set('d3ox.linkmobility.'.Order::class, $itemMock);
|
||||||
|
|
||||||
$sut = parent::canConstruct();
|
$sut = parent::canConstruct();
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class AdminOrderTest extends AdminSend
|
|||||||
->onlyMethods(['sendOrderMessage'])
|
->onlyMethods(['sendOrderMessage'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$smsMock->expects($this->once())->method('sendOrderMessage')->willReturn($canSendItemMessage);
|
$smsMock->expects($this->once())->method('sendOrderMessage')->willReturn($canSendItemMessage);
|
||||||
d3DicHandler::getInstance()->set(Sms::class, $smsMock);
|
d3GetOxidDIC()->set(Sms::class, $smsMock);
|
||||||
|
|
||||||
/** @var AdminOrder|MockObject $sut */
|
/** @var AdminOrder|MockObject $sut */
|
||||||
$sut = $this->getMockBuilder(AdminOrder::class)
|
$sut = $this->getMockBuilder(AdminOrder::class)
|
||||||
|
@ -148,7 +148,7 @@ class AdminSend extends LMUnitTestCase
|
|||||||
->onlyMethods(['addErrorToDisplay'])
|
->onlyMethods(['addErrorToDisplay'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
|
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
|
||||||
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
|
d3GetOxidDIC()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
|
||||||
|
|
||||||
/** @var OrderRecipients|MockObject $itemRecipientsMock */
|
/** @var OrderRecipients|MockObject $itemRecipientsMock */
|
||||||
$itemRecipientsMock = $this->getMockBuilder($this->itemRecipientClass)
|
$itemRecipientsMock = $this->getMockBuilder($this->itemRecipientClass)
|
||||||
@ -158,8 +158,8 @@ class AdminSend extends LMUnitTestCase
|
|||||||
$itemRecipientsMock->method('getSmsRecipient')->willThrowException(
|
$itemRecipientsMock->method('getSmsRecipient')->willThrowException(
|
||||||
oxNew(noRecipientFoundException::class)
|
oxNew(noRecipientFoundException::class)
|
||||||
);
|
);
|
||||||
d3DicHandler::getInstance()->set(OrderRecipients::class, $itemRecipientsMock);
|
d3GetOxidDIC()->set(OrderRecipients::class, $itemRecipientsMock);
|
||||||
d3DicHandler::getInstance()->set(UserRecipients::class, $itemRecipientsMock);
|
d3GetOxidDIC()->set(UserRecipients::class, $itemRecipientsMock);
|
||||||
|
|
||||||
/** @var AdminOrder|AdminUser|MockObject $sut */
|
/** @var AdminOrder|AdminUser|MockObject $sut */
|
||||||
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
||||||
@ -201,7 +201,7 @@ class AdminSend extends LMUnitTestCase
|
|||||||
->onlyMethods(['addErrorToDisplay'])
|
->onlyMethods(['addErrorToDisplay'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
|
$utilsViewMock->expects($this->once())->method('addErrorToDisplay');
|
||||||
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
|
d3GetOxidDIC()->set('d3ox.linkmobility.'.UtilsView::class, $utilsViewMock);
|
||||||
|
|
||||||
/** @var AdminOrder|AdminUser|MockObject $sut */
|
/** @var AdminOrder|AdminUser|MockObject $sut */
|
||||||
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
||||||
@ -249,7 +249,7 @@ class AdminSend extends LMUnitTestCase
|
|||||||
->onlyMethods(['getRequestEscapedParameter'])
|
->onlyMethods(['getRequestEscapedParameter'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$requestMock->method('getRequestEscapedParameter')->willReturn($message);
|
$requestMock->method('getRequestEscapedParameter')->willReturn($message);
|
||||||
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.Request::class, $requestMock);
|
d3GetOxidDIC()->set('d3ox.linkmobility.'.Request::class, $requestMock);
|
||||||
|
|
||||||
/** @var AdminOrder|AdminUser|MockObject $sut */
|
/** @var AdminOrder|AdminUser|MockObject $sut */
|
||||||
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
$sut = $this->getMockBuilder($this->subjectUnderTestClass)
|
||||||
@ -309,7 +309,7 @@ class AdminSend extends LMUnitTestCase
|
|||||||
$successfullySendExceptionMock = $this->getMockBuilder(successfullySentException::class)
|
$successfullySendExceptionMock = $this->getMockBuilder(successfullySentException::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
d3DicHandler::getInstance()->set(successfullySentException::class, $successfullySendExceptionMock);
|
d3GetOxidDIC()->set(successfullySentException::class, $successfullySendExceptionMock);
|
||||||
|
|
||||||
/** @var Response|MockObject $resonseMock */
|
/** @var Response|MockObject $resonseMock */
|
||||||
$resonseMock = $this->getMockBuilder(Response::class)
|
$resonseMock = $this->getMockBuilder(Response::class)
|
||||||
|
@ -46,7 +46,7 @@ class AdminUserTest extends AdminSend
|
|||||||
->onlyMethods(['load'])
|
->onlyMethods(['load'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$itemMock->method('load')->willReturn(true);
|
$itemMock->method('load')->willReturn(true);
|
||||||
d3DicHandler::getInstance()->set('d3ox.linkmobility.'.User::class, $itemMock);
|
d3GetOxidDIC()->set('d3ox.linkmobility.'.User::class, $itemMock);
|
||||||
|
|
||||||
$sut = parent::canConstruct();
|
$sut = parent::canConstruct();
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ class AdminUserTest extends AdminSend
|
|||||||
->onlyMethods(['sendUserAccountMessage'])
|
->onlyMethods(['sendUserAccountMessage'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$smsMock->expects($this->once())->method('sendUserAccountMessage')->willReturn($canSendItemMessage);
|
$smsMock->expects($this->once())->method('sendUserAccountMessage')->willReturn($canSendItemMessage);
|
||||||
d3DicHandler::getInstance()->set(Sms::class, $smsMock);
|
d3GetOxidDIC()->set(Sms::class, $smsMock);
|
||||||
|
|
||||||
/** @var AdminUser|MockObject $sut */
|
/** @var AdminUser|MockObject $sut */
|
||||||
$sut = $this->getMockBuilder(AdminUser::class)
|
$sut = $this->getMockBuilder(AdminUser::class)
|
||||||
|
Loading…
Reference in New Issue
Block a user