@@ -133,6 +133,66 @@ public function testProcessShippingAddress()
133133 $ this ->assertEquals ($ this ->address , $ this ->address ->process ($ this ->orderMock ));
134134 }
135135
136+ /**
137+ * Test processing of the shipping address when shipping address id was not changed.
138+ * setShippingAddressId and saveAttribute methods must not be executed.
139+ */
140+ public function testProcessShippingAddressNotChanged ()
141+ {
142+ $ this ->orderMock ->expects ($ this ->exactly (2 ))
143+ ->method ('getAddresses ' )
144+ ->willReturn ([$ this ->addressMock ]);
145+ $ this ->addressMock ->expects ($ this ->once ())
146+ ->method ('save ' )->willReturnSelf ();
147+ $ this ->orderMock ->expects ($ this ->once ())
148+ ->method ('getBillingAddress ' )
149+ ->willReturn (null );
150+ $ this ->orderMock ->expects ($ this ->once ())
151+ ->method ('getShippingAddress ' )
152+ ->willReturn ($ this ->addressMock );
153+ $ this ->addressMock ->expects ($ this ->once ())
154+ ->method ('getId ' )->willReturn (1 );
155+ $ this ->orderMock ->expects ($ this ->once ())
156+ ->method ('getShippingAddressId ' )
157+ ->willReturn (1 );
158+ $ this ->orderMock ->expects ($ this ->never ())
159+ ->method ('setShippingAddressId ' )->willReturnSelf ();
160+ $ this ->attributeMock ->expects ($ this ->never ())
161+ ->method ('saveAttribute ' )
162+ ->with ($ this ->orderMock , ['shipping_address_id ' ])->willReturnSelf ();
163+ $ this ->assertEquals ($ this ->address , $ this ->address ->process ($ this ->orderMock ));
164+ }
165+
166+ /**
167+ * Test processing of the billing address when billing address id was not changed.
168+ * setBillingAddressId and saveAttribute methods must not be executed.
169+ */
170+ public function testProcessBillingAddressNotChanged ()
171+ {
172+ $ this ->orderMock ->expects ($ this ->exactly (2 ))
173+ ->method ('getAddresses ' )
174+ ->willReturn ([$ this ->addressMock ]);
175+ $ this ->addressMock ->expects ($ this ->once ())
176+ ->method ('save ' )->willReturnSelf ();
177+ $ this ->orderMock ->expects ($ this ->once ())
178+ ->method ('getBillingAddress ' )
179+ ->willReturn ($ this ->addressMock );
180+ $ this ->orderMock ->expects ($ this ->once ())
181+ ->method ('getShippingAddress ' )
182+ ->willReturn (null );
183+ $ this ->addressMock ->expects ($ this ->once ())
184+ ->method ('getId ' )->willReturn (1 );
185+ $ this ->orderMock ->expects ($ this ->once ())
186+ ->method ('getBillingAddressId ' )
187+ ->willReturn (1 );
188+ $ this ->orderMock ->expects ($ this ->never ())
189+ ->method ('setBillingAddressId ' )->willReturnSelf ();
190+ $ this ->attributeMock ->expects ($ this ->never ())
191+ ->method ('saveAttribute ' )
192+ ->with ($ this ->orderMock , ['billing_address_id ' ])->willReturnSelf ();
193+ $ this ->assertEquals ($ this ->address , $ this ->address ->process ($ this ->orderMock ));
194+ }
195+
136196 /**
137197 * Test method removeEmptyAddresses
138198 */
0 commit comments