@@ -297,4 +297,46 @@ public function testSetMyCouponSuccess()
297297
298298 $ this ->assertEquals ($ quoteWithCoupon ->getCouponCode (), $ couponCode );
299299 }
300+
301+ /**
302+ * @magentoApiDataFixture Magento/Sales/_files/quote.php
303+ * @magentoApiDataFixture Magento/Checkout/_files/discount_10percent.php
304+ */
305+ public function testSetCouponWihSpaces ()
306+ {
307+ /** @var \Magento\Quote\Model\Quote $quote */
308+ $ quote = $ this ->objectManager ->create (\Magento \Quote \Model \Quote::class);
309+ $ quote ->load ('test01 ' , 'reserved_order_id ' );
310+ $ cartId = $ quote ->getId ();
311+ /** @var \Magento\SalesRule\Model\Rule $salesRule */
312+ $ salesRule = $ this ->objectManager ->create (\Magento \SalesRule \Model \Rule::class);
313+ $ salesRuleId = $ this ->objectManager ->get (\Magento \Framework \Registry::class)
314+ ->registry ('Magento/Checkout/_file/discount_10percent ' );
315+ $ salesRule ->load ($ salesRuleId );
316+ $ couponCode = $ salesRule ->getPrimaryCoupon ()->getCode () ;
317+ $ serviceInfo = [
318+ 'rest ' => [
319+ 'resourcePath ' => self ::RESOURCE_PATH . $ cartId . '/coupons/ '
320+ . rawurlencode (' ' ) . $ couponCode . rawurlencode (' ' ),
321+ 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_PUT ,
322+ ],
323+ 'soap ' => [
324+ 'service ' => self ::SERVICE_NAME ,
325+ 'serviceVersion ' => self ::SERVICE_VERSION ,
326+ 'operation ' => self ::SERVICE_NAME . 'Set ' ,
327+ ],
328+ ];
329+
330+ $ requestData = [
331+ "cartId " => $ cartId ,
332+ "couponCode " => $ couponCode ,
333+ ];
334+
335+ $ this ->assertTrue ($ this ->_webApiCall ($ serviceInfo , $ requestData ));
336+
337+ $ quoteWithCoupon = $ this ->objectManager ->create (\Magento \Quote \Model \Quote::class);
338+ $ quoteWithCoupon ->load ('test01 ' , 'reserved_order_id ' );
339+
340+ $ this ->assertEquals ($ quoteWithCoupon ->getCouponCode (), $ couponCode );
341+ }
300342}
0 commit comments