diff --git a/app/code/Magento/Quote/Model/Webapi/ParamOverriderCartId.php b/app/code/Magento/Quote/Model/Webapi/ParamOverriderCartId.php index a13a2dc590def..ae6c82629c437 100644 --- a/app/code/Magento/Quote/Model/Webapi/ParamOverriderCartId.php +++ b/app/code/Magento/Quote/Model/Webapi/ParamOverriderCartId.php @@ -56,7 +56,7 @@ public function getOverriddenValue() } } } catch (NoSuchEntityException $e) { - /* do nothing and just return null */ + throw new NoSuchEntityException(__('Current customer does not have an active cart.')); } return null; } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php b/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php index bc47a04a226e1..b533463d689a8 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php @@ -67,6 +67,9 @@ public function testGetOverriddenValueIsCustomerAndCartExists() $this->assertSame($retValue, $this->model->getOverriddenValue()); } + /** + * @expectedException \Magento\Framework\Exception\NoSuchEntityException + */ public function testGetOverriddenValueIsCustomerAndCartDoesNotExist() { $customerId = 1; @@ -83,7 +86,7 @@ public function testGetOverriddenValueIsCustomerAndCartDoesNotExist() ->with($customerId) ->will($this->throwException(new NoSuchEntityException())); - $this->assertNull($this->model->getOverriddenValue()); + $this->model->getOverriddenValue(); } public function testGetOverriddenValueIsCustomerAndCartIsNull() diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request/ParamOverriderInterface.php b/lib/internal/Magento/Framework/Webapi/Rest/Request/ParamOverriderInterface.php index 21741a2c16c1d..828022353e4fa 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request/ParamOverriderInterface.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request/ParamOverriderInterface.php @@ -34,6 +34,7 @@ interface ParamOverriderInterface * Returns the overridden value to use. * * @return string|int|null + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getOverriddenValue(); }