Skip to content

Commit 5084541

Browse files
authored
Merge pull request #3046 from magento-architects/MAGETWO-94207-REST-400
[architects] MAGETWO-94207: Cart GET for customer in REST returns 400 when cart not created
2 parents 8d260f3 + 391c067 commit 5084541

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

app/code/Magento/Quote/Model/Webapi/ParamOverriderCartId.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getOverriddenValue()
5656
}
5757
}
5858
} catch (NoSuchEntityException $e) {
59-
/* do nothing and just return null */
59+
throw new NoSuchEntityException(__('Current customer does not have an active cart.'));
6060
}
6161
return null;
6262
}

app/code/Magento/Quote/Test/Unit/Model/Webapi/ParamOverriderCartIdTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public function testGetOverriddenValueIsCustomerAndCartExists()
6767
$this->assertSame($retValue, $this->model->getOverriddenValue());
6868
}
6969

70+
/**
71+
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
72+
*/
7073
public function testGetOverriddenValueIsCustomerAndCartDoesNotExist()
7174
{
7275
$customerId = 1;
@@ -83,7 +86,7 @@ public function testGetOverriddenValueIsCustomerAndCartDoesNotExist()
8386
->with($customerId)
8487
->will($this->throwException(new NoSuchEntityException()));
8588

86-
$this->assertNull($this->model->getOverriddenValue());
89+
$this->model->getOverriddenValue();
8790
}
8891

8992
public function testGetOverriddenValueIsCustomerAndCartIsNull()

lib/internal/Magento/Framework/Webapi/Rest/Request/ParamOverriderInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface ParamOverriderInterface
3434
* Returns the overridden value to use.
3535
*
3636
* @return string|int|null
37+
* @throws \Magento\Framework\Exception\NoSuchEntityException
3738
*/
3839
public function getOverriddenValue();
3940
}

0 commit comments

Comments
 (0)