CartBlockTest.php in Commerce Core 8.2
File
modules/cart/tests/src/Functional/CartBlockTest.php
View source
<?php
namespace Drupal\Tests\commerce_cart\Functional;
class CartBlockTest extends CartBrowserTestBase {
protected function setUp() : void {
parent::setUp();
$this
->placeBlock('commerce_cart');
}
public function testCartBlock() {
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextContains('0 items');
$this->cartManager
->addEntity($this->cart, $this->variation);
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextContains('1 item');
$this
->assertSession()
->pageTextContains($this->variation
->getOrderItemTitle());
$this
->assertSession()
->pageTextContains('1 x');
$this->cartManager
->addEntity($this->cart, $this->variation, 2);
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextContains('3 items');
$this
->assertSession()
->pageTextContains('3 x');
$this->cart
->getState()
->applyTransitionById('place');
$this->cart
->save();
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextNotContains('3 items');
}
}