MenuStorageTest.php

Same filename in other branches
  1. 8.9.x core/modules/system/tests/src/Kernel/Menu/MenuStorageTest.php
  2. 10 core/modules/system/tests/src/Kernel/Menu/MenuStorageTest.php
  3. 11.x core/modules/system/tests/src/Kernel/Menu/MenuStorageTest.php

Namespace

Drupal\Tests\system\Kernel\Menu

File

core/modules/system/tests/src/Kernel/Menu/MenuStorageTest.php

View source
<?php

namespace Drupal\Tests\system\Kernel\Menu;

use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException;
use Drupal\KernelTests\KernelTestBase;
use Drupal\system\Entity\Menu;
use Drupal\system\MenuStorage;

/**
 * Tests MenuStorage.
 *
 * @group Menu
 *
 * @see \Drupal\system\MenuStorage
 */
class MenuStorageTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'system',
    ];
    
    /**
     * Tests MenuStorage::MAX_ID_LENGTH is enforced.
     */
    public function testMaxIdLengthException() {
        $id = $this->randomMachineName(MenuStorage::MAX_ID_LENGTH + 1);
        $this->expectException(ConfigEntityIdLengthException::class);
        $this->expectExceptionMessage(sprintf('Configuration entity ID %s exceeds maximum allowed length of %s characters.', $id, MenuStorage::MAX_ID_LENGTH));
        Menu::create([
            'id' => $id,
        ])->save();
    }

}

Classes

Title Deprecated Summary
MenuStorageTest Tests MenuStorage.

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