BreadcrumbTest.php

Same filename in this branch
  1. 9 core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
Same filename in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
  2. 8.9.x core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php
  3. 10 core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
  4. 10 core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php
  5. 11.x core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
  6. 11.x core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php

Namespace

Drupal\Tests\Core\Breadcrumb

File

core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbTest.php

View source
<?php

namespace Drupal\Tests\Core\Breadcrumb;

use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\Core\Breadcrumb\Breadcrumb
 * @group Breadcrumb
 */
class BreadcrumbTest extends UnitTestCase {
    
    /**
     * @covers ::setLinks
     */
    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>')),
        ]);
    }

}

Classes

Title Deprecated Summary
BreadcrumbTest @coversDefaultClass \Drupal\Core\Breadcrumb\Breadcrumb @group Breadcrumb

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