AnonymousUserSessionTest.php

Same filename in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php
  2. 10 core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php
  3. 11.x core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php

Namespace

Drupal\Tests\Core\Session

File

core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php

View source
<?php

namespace Drupal\Tests\Core\Session;

use Drupal\Tests\UnitTestCase;
use Drupal\Core\Session\AnonymousUserSession;
use Drupal\user\RoleInterface;

/**
 * @coversDefaultClass \Drupal\Core\Session\AnonymousUserSession
 * @group Session
 */
class AnonymousUserSessionTest extends UnitTestCase {
    
    /**
     * Tests the method getRoles exclude or include locked roles based in param.
     *
     * @covers ::getRoles
     * @todo Move roles constants to a class/interface
     */
    public function testUserGetRoles() {
        $anonymous_user = new AnonymousUserSession();
        $this->assertEquals([
            RoleInterface::ANONYMOUS_ID,
        ], $anonymous_user->getRoles());
        $this->assertEquals([], $anonymous_user->getRoles(TRUE));
    }

}

Classes

Title Deprecated Summary
AnonymousUserSessionTest @coversDefaultClass \Drupal\Core\Session\AnonymousUserSession @group Session

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