@@ -46,7 +46,7 @@ class DepersonalizePluginTest extends TestCase
4646 protected function setUp (): void
4747 {
4848 $ this ->layoutMock = $ this ->getMockForAbstractClass (LayoutInterface::class);
49- $ this ->checkoutSessionMock = $ this ->createPartialMock (CheckoutSession::class, ['clearStorage ' ]);
49+ $ this ->checkoutSessionMock = $ this ->createPartialMock (CheckoutSession::class, ['clearStorage ' , ' setQuoteId ' , ' getQuoteId ' ]);
5050 $ this ->depersonalizeCheckerMock = $ this ->createMock (DepersonalizeChecker::class);
5151
5252 $ this ->plugin = (new ObjectManagerHelper ($ this ))->getObject (
@@ -70,6 +70,10 @@ public function testAfterGenerateElements(): void
7070 ->expects ($ this ->once ())
7171 ->method ('clearStorage ' )
7272 ->willReturnSelf ();
73+ $ this ->checkoutSessionMock
74+ ->expects ($ this ->once ())
75+ ->method ('setQuoteId ' )
76+ ->willReturn (1 );
7377
7478 $ this ->assertEmpty ($ this ->plugin ->afterGenerateElements ($ this ->layoutMock ));
7579 }
@@ -86,7 +90,43 @@ public function testAfterGenerateElementsNoDepersonalize(): void
8690 ->expects ($ this ->never ())
8791 ->method ('clearStorage ' )
8892 ->willReturnSelf ();
93+ $ this ->checkoutSessionMock
94+ ->expects ($ this ->never ())
95+ ->method ('setQuoteId ' )
96+ ->willReturn (1 );
8997
9098 $ this ->assertEmpty ($ this ->plugin ->afterGenerateElements ($ this ->layoutMock ));
9199 }
100+
101+ /**
102+ * Test beforeGenerateElements method when depersonalization is needed.
103+ *
104+ * @return void
105+ */
106+ public function testBeforeGenerateXml (): void
107+ {
108+ $ this ->depersonalizeCheckerMock ->expects ($ this ->once ())->method ('checkIfDepersonalize ' )->willReturn (true );
109+ $ this ->checkoutSessionMock
110+ ->expects ($ this ->once ())
111+ ->method ('getQuoteId ' )
112+ ->willReturn (1 );
113+
114+ $ this ->assertEmpty ($ this ->plugin ->beforeGenerateXml ($ this ->layoutMock ));
115+ }
116+
117+ /**
118+ * Test afterGenerateElements method when depersonalization is needed.
119+ *
120+ * @return void
121+ */
122+ public function testBeforeGenerateXmlNoDepersonalize (): void
123+ {
124+ $ this ->depersonalizeCheckerMock ->expects ($ this ->once ())->method ('checkIfDepersonalize ' )->willReturn (false );
125+ $ this ->checkoutSessionMock
126+ ->expects ($ this ->never ())
127+ ->method ('getQuoteId ' )
128+ ->willReturn (1 );
129+
130+ $ this ->assertEmpty ($ this ->plugin ->beforeGenerateXml ($ this ->layoutMock ));
131+ }
92132}
0 commit comments