NodeListBuilderTest.php

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

Namespace

Drupal\Tests\node\Kernel

File

core/modules/node/tests/src/Kernel/NodeListBuilderTest.php

View source
<?php

namespace Drupal\Tests\node\Kernel;

use Drupal\Core\Language\LanguageInterface;
use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the admin listing fallback when views is not enabled.
 *
 * @group node
 */
class NodeListBuilderTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [
        'node',
        'user',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() : void {
        parent::setUp();
        $this->installEntitySchema('node');
    }
    
    /**
     * Tests that the correct cache contexts are set.
     */
    public function testCacheContexts() {
        
        /** @var \Drupal\Core\Entity\EntityListBuilderInterface $list_builder */
        $list_builder = $this->container
            ->get('entity_type.manager')
            ->getListBuilder('node');
        $build = $list_builder->render();
        $this->container
            ->get('renderer')
            ->renderRoot($build);
        $this->assertEqualsCanonicalizing([
            'languages:' . LanguageInterface::TYPE_INTERFACE,
            'theme',
            'url.query_args.pagers:0',
            'user.node_grants:view',
            'user.permissions',
        ], $build['#cache']['contexts']);
    }

}

Classes

Title Deprecated Summary
NodeListBuilderTest Tests the admin listing fallback when views is not enabled.

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