diff --git a/src/Plugin/BannerAjaxLoadControllerPlugin.php b/src/Plugin/BannerAjaxLoadControllerPlugin.php new file mode 100644 index 0000000..8427246 --- /dev/null +++ b/src/Plugin/BannerAjaxLoadControllerPlugin.php @@ -0,0 +1,52 @@ +writeClose(); + } + + //phpcs:ignore MEQP2.Classes.PublicNonInterfaceMethods.PublicMethodFound + public function beforeExecute() + { + } +} diff --git a/src/etc/di.xml b/src/etc/di.xml index d133cb2..e242179 100644 --- a/src/etc/di.xml +++ b/src/etc/di.xml @@ -18,4 +18,16 @@ - \ No newline at end of file + + + + + + + + + Magento\Framework\Message\Session + + + + diff --git a/tests/Integration/AbstractSessionTest.php b/tests/Integration/AbstractSessionTest.php index 2360432..76b4284 100644 --- a/tests/Integration/AbstractSessionTest.php +++ b/tests/Integration/AbstractSessionTest.php @@ -5,9 +5,11 @@ use IntegerNet\SessionUnblocker\Plugin\SessionStoragePlugin; use IntegerNet\SessionUnblocker\MethodLog; -use IntegerNet\SessionUnblocker\Test\Util\SectionLoadActionSpy; +use IntegerNet\SessionUnblocker\Test\Util\BannerAjaxLoadActionSpy; +use IntegerNet\SessionUnblocker\Test\Util\CustomerSectionLoadActionSpy; use IntegerNet\SessionUnblocker\Test\Util\SessionSpy; -use Magento\Customer\Controller\Section\Load as LoadAction; +use Magento\Banner\Controller\Ajax\Load as BannerAjaxLoadAction; +use Magento\Customer\Controller\Section\Load as CustomerSectionLoadAction; use Magento\Framework\Session\Generic as GenericSession; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; @@ -78,8 +80,9 @@ private function setUpSpies(): void $this->objectManager->configure( [ 'preferences' => [ - LoadAction::class => SectionLoadActionSpy::class, - GenericSession::class => SessionSpy::class, + BannerAjaxLoadAction::class => BannerAjaxLoadActionSpy::class, + CustomerSectionLoadAction::class => CustomerSectionLoadActionSpy::class, + GenericSession::class => SessionSpy::class, ], SessionStoragePlugin::class => [ 'arguments' => ['doLogMethods' => true] diff --git a/tests/Integration/BannerAjaxLoadControllerTest.php b/tests/Integration/BannerAjaxLoadControllerTest.php new file mode 100644 index 0000000..bc31e1a --- /dev/null +++ b/tests/Integration/BannerAjaxLoadControllerTest.php @@ -0,0 +1,20 @@ +when_dispatched('banner/ajax/load'); + $this->then_sessions_have_been_started_and_closed_before_action(); + } + + public function testBannerAjaxLoadNoWrites() + { + $this->given_session_already_exists(); + $this->when_dispatched('banner/ajax/load'); + $this->then_sessions_have_not_been_modified_after_write(); + } +} diff --git a/tests/Util/BannerAjaxLoadActionSpy.php b/tests/Util/BannerAjaxLoadActionSpy.php new file mode 100644 index 0000000..45c0b8c --- /dev/null +++ b/tests/Util/BannerAjaxLoadActionSpy.php @@ -0,0 +1,17 @@ +logControllerAction(parent::class, __FUNCTION__); + return parent::execute(); + } + +} \ No newline at end of file diff --git a/tests/Util/SectionLoadActionSpy.php b/tests/Util/CustomerSectionLoadActionSpy.php similarity index 87% rename from tests/Util/SectionLoadActionSpy.php rename to tests/Util/CustomerSectionLoadActionSpy.php index 0f58abb..0864f01 100644 --- a/tests/Util/SectionLoadActionSpy.php +++ b/tests/Util/CustomerSectionLoadActionSpy.php @@ -6,7 +6,7 @@ use IntegerNet\SessionUnblocker\MethodLog; use Magento\Customer\Controller\Section\Load; -class SectionLoadActionSpy extends Load +class CustomerSectionLoadActionSpy extends Load { public function execute() {