From f3786b170cd9dd846e235d7b9c5f3d0c3fbe6a0d Mon Sep 17 00:00:00 2001 From: Anton Fedurtsya Date: Wed, 4 Oct 2023 22:33:42 +0300 Subject: [PATCH] Move input/output related classes to separate domain Signed-off-by: Anton Fedurtsya --- services.yaml | 1 + src/Service/InvoiceService.php | 2 +- src/Service/RequestDataConverter.php | 2 +- .../Controller/Admin/InvoiceController.php | 2 +- src/Transition/Core/services.yaml | 10 ---------- .../Core => Transput}/RequestInterface.php | 2 +- .../Core => Transput}/RequestProxy.php | 2 +- .../Core => Transput}/UtilsInterface.php | 2 +- src/{Transition/Core => Transput}/UtilsProxy.php | 3 ++- src/Transput/services.yaml | 15 +++++++++++++++ .../Controller/Admin/InvoiceControllerTest.php | 4 ++-- .../Transition/Core/RequestProxyTest.php | 4 ++-- .../Transition/Core/UtilsProxyTest.php | 8 ++++---- tests/Unit/Service/InvoiceServiceTest.php | 2 +- tests/Unit/Service/RequestDataConverterTest.php | 2 +- 15 files changed, 34 insertions(+), 27 deletions(-) rename src/{Transition/Core => Transput}/RequestInterface.php (87%) rename src/{Transition/Core => Transput}/RequestProxy.php (93%) rename src/{Transition/Core => Transput}/UtilsInterface.php (85%) rename src/{Transition/Core => Transput}/UtilsProxy.php (85%) create mode 100644 src/Transput/services.yaml diff --git a/services.yaml b/services.yaml index 4256550..295ea21 100644 --- a/services.yaml +++ b/services.yaml @@ -4,6 +4,7 @@ imports: - { resource: src/Service/services.yaml } - { resource: src/Settings/services.yaml } - { resource: src/Transition/Core/services.yaml } + - { resource: src/Transput/services.yaml } services: _defaults: diff --git a/src/Service/InvoiceService.php b/src/Service/InvoiceService.php index e249a96..438bf77 100644 --- a/src/Service/InvoiceService.php +++ b/src/Service/InvoiceService.php @@ -9,7 +9,7 @@ namespace FreshAdvance\Invoice\Service; -use FreshAdvance\Invoice\Transition\Core\UtilsInterface; +use FreshAdvance\Invoice\Transput\UtilsInterface; class InvoiceService implements InvoiceServiceInterface { diff --git a/src/Service/RequestDataConverter.php b/src/Service/RequestDataConverter.php index df63ea9..35a30b1 100644 --- a/src/Service/RequestDataConverter.php +++ b/src/Service/RequestDataConverter.php @@ -11,7 +11,7 @@ use FreshAdvance\Invoice\DataType\InvoiceConfiguration; use FreshAdvance\Invoice\DataType\InvoiceConfigurationInterface; -use FreshAdvance\Invoice\Transition\Core\RequestInterface; +use FreshAdvance\Invoice\Transput\RequestInterface; class RequestDataConverter implements RequestDataConverterInterface { diff --git a/src/Transition/Controller/Admin/InvoiceController.php b/src/Transition/Controller/Admin/InvoiceController.php index 372d65d..28d44d9 100644 --- a/src/Transition/Controller/Admin/InvoiceController.php +++ b/src/Transition/Controller/Admin/InvoiceController.php @@ -15,7 +15,7 @@ use FreshAdvance\Invoice\Service\InvoiceServiceInterface; use FreshAdvance\Invoice\Service\RequestDataConverterInterface; use FreshAdvance\Invoice\Traits\ServiceContainer; -use FreshAdvance\Invoice\Transition\Core\RequestInterface; +use FreshAdvance\Invoice\Transput\RequestInterface; use OxidEsales\Eshop\Application\Controller\Admin\AdminController; class InvoiceController extends AdminController diff --git a/src/Transition/Core/services.yaml b/src/Transition/Core/services.yaml index 3f82526..edfbf3f 100644 --- a/src/Transition/Core/services.yaml +++ b/src/Transition/Core/services.yaml @@ -3,18 +3,8 @@ services: public: false autowire: true bind: - OxidEsales\Eshop\Core\Utils: '@=service("FreshAdvance\\Invoice\\Core\\Registry").getUtils()' - OxidEsales\Eshop\Core\Request: '@=service("FreshAdvance\\Invoice\\Core\\Registry").getRequest()' OxidEsales\Eshop\Core\Language: '@=service("FreshAdvance\\Invoice\\Core\\Registry").getLang()' FreshAdvance\Invoice\Transition\Core\LanguageInterface: class: FreshAdvance\Invoice\Transition\Core\LanguageProxy public: true - - FreshAdvance\Invoice\Transition\Core\UtilsInterface: - class: FreshAdvance\Invoice\Transition\Core\UtilsProxy - public: true - - FreshAdvance\Invoice\Transition\Core\RequestInterface: - class: FreshAdvance\Invoice\Transition\Core\RequestProxy - public: true diff --git a/src/Transition/Core/RequestInterface.php b/src/Transput/RequestInterface.php similarity index 87% rename from src/Transition/Core/RequestInterface.php rename to src/Transput/RequestInterface.php index 3f9c249..d6242ca 100644 --- a/src/Transition/Core/RequestInterface.php +++ b/src/Transput/RequestInterface.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace FreshAdvance\Invoice\Transition\Core; +namespace FreshAdvance\Invoice\Transput; interface RequestInterface { diff --git a/src/Transition/Core/RequestProxy.php b/src/Transput/RequestProxy.php similarity index 93% rename from src/Transition/Core/RequestProxy.php rename to src/Transput/RequestProxy.php index c35d713..1094460 100644 --- a/src/Transition/Core/RequestProxy.php +++ b/src/Transput/RequestProxy.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace FreshAdvance\Invoice\Transition\Core; +namespace FreshAdvance\Invoice\Transput; use OxidEsales\Eshop\Core\Request; diff --git a/src/Transition/Core/UtilsInterface.php b/src/Transput/UtilsInterface.php similarity index 85% rename from src/Transition/Core/UtilsInterface.php rename to src/Transput/UtilsInterface.php index 3f5409e..9443f0d 100644 --- a/src/Transition/Core/UtilsInterface.php +++ b/src/Transput/UtilsInterface.php @@ -7,7 +7,7 @@ declare(strict_types=1); -namespace FreshAdvance\Invoice\Transition\Core; +namespace FreshAdvance\Invoice\Transput; interface UtilsInterface { diff --git a/src/Transition/Core/UtilsProxy.php b/src/Transput/UtilsProxy.php similarity index 85% rename from src/Transition/Core/UtilsProxy.php rename to src/Transput/UtilsProxy.php index 362d5d3..9a6e38a 100644 --- a/src/Transition/Core/UtilsProxy.php +++ b/src/Transput/UtilsProxy.php @@ -7,8 +7,9 @@ declare(strict_types=1); -namespace FreshAdvance\Invoice\Transition\Core; +namespace FreshAdvance\Invoice\Transput; +use FreshAdvance\Invoice\Transput\UtilsInterface; use OxidEsales\Eshop\Core\Utils; class UtilsProxy implements UtilsInterface diff --git a/src/Transput/services.yaml b/src/Transput/services.yaml new file mode 100644 index 0000000..38dd151 --- /dev/null +++ b/src/Transput/services.yaml @@ -0,0 +1,15 @@ +services: + _defaults: + public: false + autowire: true + bind: + OxidEsales\Eshop\Core\Request: '@=service("FreshAdvance\\Invoice\\Core\\Registry").getRequest()' + OxidEsales\Eshop\Core\Utils: '@=service("FreshAdvance\\Invoice\\Core\\Registry").getUtils()' + + FreshAdvance\Invoice\Transput\RequestInterface: + class: FreshAdvance\Invoice\Transput\RequestProxy + public: true + + FreshAdvance\Invoice\Transput\UtilsInterface: + class: FreshAdvance\Invoice\Transput\UtilsProxy + public: true diff --git a/tests/Integration/Transition/Controller/Admin/InvoiceControllerTest.php b/tests/Integration/Transition/Controller/Admin/InvoiceControllerTest.php index e6772e3..173b368 100644 --- a/tests/Integration/Transition/Controller/Admin/InvoiceControllerTest.php +++ b/tests/Integration/Transition/Controller/Admin/InvoiceControllerTest.php @@ -15,8 +15,8 @@ use FreshAdvance\Invoice\Service\Invoice; use FreshAdvance\Invoice\Service\InvoiceServiceInterface; use FreshAdvance\Invoice\Transition\Controller\Admin\InvoiceController; -use FreshAdvance\Invoice\Transition\Core\RequestInterface; -use FreshAdvance\Invoice\Transition\Core\RequestProxy; +use FreshAdvance\Invoice\Transput\RequestInterface; +use FreshAdvance\Invoice\Transput\RequestProxy; use PHPUnit\Framework\TestCase; /** diff --git a/tests/Integration/Transition/Core/RequestProxyTest.php b/tests/Integration/Transition/Core/RequestProxyTest.php index 706c9fe..06b122b 100644 --- a/tests/Integration/Transition/Core/RequestProxyTest.php +++ b/tests/Integration/Transition/Core/RequestProxyTest.php @@ -9,12 +9,12 @@ namespace Transition\Core; -use FreshAdvance\Invoice\Transition\Core\RequestProxy; +use FreshAdvance\Invoice\Transput\RequestProxy; use OxidEsales\Eshop\Core\Request; use PHPUnit\Framework\TestCase; /** - * @covers \FreshAdvance\Invoice\Transition\Core\RequestProxy + * @covers \FreshAdvance\Invoice\Transput\RequestProxy */ class RequestProxyTest extends TestCase { diff --git a/tests/Integration/Transition/Core/UtilsProxyTest.php b/tests/Integration/Transition/Core/UtilsProxyTest.php index a2ccbd3..5662629 100644 --- a/tests/Integration/Transition/Core/UtilsProxyTest.php +++ b/tests/Integration/Transition/Core/UtilsProxyTest.php @@ -9,12 +9,12 @@ namespace Transition\Core; -use FreshAdvance\Invoice\Transition\Core\UtilsProxy; +use FreshAdvance\Invoice\Transput\UtilsProxy; use OxidEsales\Eshop\Core\Utils; use PHPUnit\Framework\TestCase; /** - * @covers \FreshAdvance\Invoice\Transition\Core\UtilsProxy + * @covers \FreshAdvance\Invoice\Transput\UtilsProxy */ class UtilsProxyTest extends TestCase { @@ -25,7 +25,7 @@ public function testSetHeaderProxied(): void $utilsMock = $this->createPartialMock(Utils::class, ['setHeader']); $utilsMock->expects($this->once())->method('setHeader')->with($testValue); - $sut = new UtilsProxy($utilsMock); + $sut = new \FreshAdvance\Invoice\Transput\UtilsProxy($utilsMock); $sut->setHeader($testValue); } @@ -36,7 +36,7 @@ public function testShowMessageAndExitProxied(): void $utilsMock = $this->createPartialMock(Utils::class, ['showMessageAndExit']); $utilsMock->expects($this->once())->method('showMessageAndExit')->with($testValue); - $sut = new UtilsProxy($utilsMock); + $sut = new \FreshAdvance\Invoice\Transput\UtilsProxy($utilsMock); $sut->showMessageAndExit($testValue); } } diff --git a/tests/Unit/Service/InvoiceServiceTest.php b/tests/Unit/Service/InvoiceServiceTest.php index 35f64eb..7286d95 100644 --- a/tests/Unit/Service/InvoiceServiceTest.php +++ b/tests/Unit/Service/InvoiceServiceTest.php @@ -10,7 +10,7 @@ namespace FreshAdvance\Invoice\Tests\Unit\Service; use FreshAdvance\Invoice\Service\InvoiceService; -use FreshAdvance\Invoice\Transition\Core\UtilsProxy; +use FreshAdvance\Invoice\Transput\UtilsProxy; use org\bovigo\vfs\vfsStream; use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/Service/RequestDataConverterTest.php b/tests/Unit/Service/RequestDataConverterTest.php index a025165..b962b15 100644 --- a/tests/Unit/Service/RequestDataConverterTest.php +++ b/tests/Unit/Service/RequestDataConverterTest.php @@ -10,7 +10,7 @@ namespace FreshAdvance\Invoice\Tests\Unit\Service; use FreshAdvance\Invoice\Service\RequestDataConverter; -use FreshAdvance\Invoice\Transition\Core\RequestInterface; +use FreshAdvance\Invoice\Transput\RequestInterface; use OxidEsales\Eshop\Core\Request; use PHPUnit\Framework\TestCase;