@@ -46,7 +46,7 @@ class DepersonalizePluginTest extends TestCase
46
46
protected function setUp (): void
47
47
{
48
48
$ this ->layoutMock = $ this ->getMockForAbstractClass (LayoutInterface::class);
49
- $ this ->checkoutSessionMock = $ this ->createPartialMock (CheckoutSession::class, ['clearStorage ' ]);
49
+ $ this ->checkoutSessionMock = $ this ->createPartialMock (CheckoutSession::class, ['clearStorage ' , ' setQuoteId ' , ' getQuoteId ' ]);
50
50
$ this ->depersonalizeCheckerMock = $ this ->createMock (DepersonalizeChecker::class);
51
51
52
52
$ this ->plugin = (new ObjectManagerHelper ($ this ))->getObject (
@@ -70,6 +70,10 @@ public function testAfterGenerateElements(): void
70
70
->expects ($ this ->once ())
71
71
->method ('clearStorage ' )
72
72
->willReturnSelf ();
73
+ $ this ->checkoutSessionMock
74
+ ->expects ($ this ->once ())
75
+ ->method ('setQuoteId ' )
76
+ ->willReturn (1 );
73
77
74
78
$ this ->assertEmpty ($ this ->plugin ->afterGenerateElements ($ this ->layoutMock ));
75
79
}
@@ -86,7 +90,43 @@ public function testAfterGenerateElementsNoDepersonalize(): void
86
90
->expects ($ this ->never ())
87
91
->method ('clearStorage ' )
88
92
->willReturnSelf ();
93
+ $ this ->checkoutSessionMock
94
+ ->expects ($ this ->never ())
95
+ ->method ('setQuoteId ' )
96
+ ->willReturn (1 );
89
97
90
98
$ this ->assertEmpty ($ this ->plugin ->afterGenerateElements ($ this ->layoutMock ));
91
99
}
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
+ }
92
132
}
0 commit comments