function BreadcrumbTest::testSetLinks

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php \Drupal\Tests\Core\Breadcrumb\BreadcrumbTest::testSetLinks()
  2. 10 core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php \Drupal\Tests\Core\Breadcrumb\BreadcrumbTest::testSetLinks()
  3. 11.x core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php \Drupal\Tests\Core\Breadcrumb\BreadcrumbTest::testSetLinks()

@covers ::setLinks

File

core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php, line 19

Class

BreadcrumbTest
@coversDefaultClass \Drupal\Core\Breadcrumb\Breadcrumb @group Breadcrumb

Namespace

Drupal\Tests\Core\Breadcrumb

Code

public function testSetLinks() {
    $breadcrumb = new Breadcrumb();
    $breadcrumb->setLinks([
        new Link('Home', Url::fromRoute('<front>')),
    ]);
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage('Once breadcrumb links are set, only additional breadcrumb links can be added.');
    $breadcrumb->setLinks([
        new Link('None', Url::fromRoute('<none>')),
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.