File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
app/code/Magento/Persistent/Test/Unit/Observer Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 2828 */
2929class EmulateQuoteObserverTest extends TestCase
3030{
31+ public const EVENT_NAME = 'controller_action_predispatch ' ;
32+ public const OBSERVER_INSTANCE = 'Magento\Persistent\Observer\EmulateQuoteObserver ' ;
33+
3134 /**
3235 * @var EmulateQuoteObserver
3336 */
@@ -272,4 +275,25 @@ public function testExecuteWhenShoppingCartIsPersistentAndQuoteExist()
272275 $ this ->checkoutSessionMock ->expects ($ this ->once ())->method ('setCustomerData ' )->with ($ this ->customerMock );
273276 $ this ->model ->execute ($ this ->observerMock );
274277 }
278+
279+ /**
280+ * Test observer is disabled as it may cause performance degradation for quotes with lots of sales rules
281+ *
282+ * @return void
283+ */
284+ public function testDisabled ()
285+ {
286+ $ eventsXml = simplexml_load_file (__DIR__ . '/../../../etc/frontend/events.xml ' );
287+ $ status = 'false ' ;
288+ foreach ($ eventsXml ->event as $ event ) {
289+ if ($ event ->attributes ()['name ' ] == self ::EVENT_NAME ) {
290+ foreach ($ event ->observer as $ observer ) {
291+ if ((string )$ observer ->attributes ()['instance ' ] == self ::OBSERVER_INSTANCE ) {
292+ $ status = $ observer ->attributes ()['disabled ' ];
293+ }
294+ }
295+ }
296+ }
297+ $ this ->assertTrue ($ status == 'true ' );
298+ }
275299}
You can’t perform that action at this time.
0 commit comments