public function CartSettingsTest::testCartBreadcrumb in Ubercart 8.4
Tests the shopping cart page breadcrumb.
File
- uc_cart/
tests/ src/ Functional/ CartSettingsTest.php, line 205
Class
- CartSettingsTest
- Tests the cart settings page.
Namespace
Drupal\Tests\uc_cart\FunctionalCode
public function testCartBreadcrumb() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/store/config/cart');
// Check that custom cart breadcrumb text field exists.
$assert
->fieldExists('uc_cart_breadcrumb_text');
// Check that custom cart breadcrumb URL.
$assert
->fieldExists('uc_cart_breadcrumb_url');
$settings = [
'uc_cart_breadcrumb_text' => $this
->randomMachineName(8),
'uc_cart_breadcrumb_url' => $this
->randomMachineName(8),
];
$this
->submitForm($settings, 'Save configuration');
$this
->drupalGet('node/' . $this->product
->id());
$this
->submitForm([], 'Add to cart');
// Test that the breadcrumb link text is set correctly.
$assert
->linkExists($settings['uc_cart_breadcrumb_text'], 0);
$links = $this
->xpath('//a[@href="' . Url::fromUri('internal:/' . $settings['uc_cart_breadcrumb_url'], [
'absolute' => TRUE,
])
->toString() . '"]');
$this
->assertTrue(isset($links[0]), 'The breadcrumb link is set correctly.');
}