public function CartBlockTest::testCartBlock in Commerce Core 8.2
Tests the count text (display, plurality), and the cart dropdown.
File
- modules/
cart/ tests/ src/ Functional/ CartBlockTest.php, line 23
Class
- CartBlockTest
- Tests the cart block.
Namespace
Drupal\Tests\commerce_cart\FunctionalCode
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');
// If the order is no longer a draft, the block should not render.
$this->cart
->getState()
->applyTransitionById('place');
$this->cart
->save();
$this
->drupalGet('<front>');
$this
->assertSession()
->pageTextNotContains('3 items');
}