public function CartHandlerTest::testUpdateCartLine in Mailchimp E-Commerce 8
@covers ::updateCartLine
File
- tests/
src/ Unit/ CartHandlerTest.php, line 139
Class
- CartHandlerTest
- Tests cart handler methods.
Namespace
Drupal\Tests\mailchimp_ecommerce\UnitCode
public function testUpdateCartLine() {
$this->helper
->method('getStoreId')
->willReturn('my_store');
$this->mcEcommerce
->expects($this
->at(0))
->method('updateCartLine');
$this->handler
->updateCartLine('my_cart', 1, []);
// Test add case.
$exception = new \Exception('', 404);
$this->mcEcommerce
->expects($this
->at(0))
->method('updateCartLine')
->will($this
->throwException($exception));
$this->mcEcommerce
->expects($this
->once())
->method('addCartLine');
$this->handler
->updateCartLine('my_cart', 1, []);
// Test error handling.
$exception = new \Exception('Error!', 500);
$this->mcEcommerce
->expects($this
->at(0))
->method('updateCartLine')
->will($this
->throwException($exception));
$this->handler
->updateCartLine('my_cart', 1, []);
$this
->assertContains('Error!', $this->errors);
}