AccessResultNeutralTest.php

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

Namespace

Drupal\Tests\Core\Access

File

core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php

View source
<?php

namespace Drupal\Tests\Core\Access;

use Drupal\Core\Access\AccessResultNeutral;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\Core\Access\AccessResultNeutral
 * @group Access
 */
class AccessResultNeutralTest extends UnitTestCase {
    
    /**
     * Tests the construction of an AccessResultForbidden object.
     *
     * @covers ::__construct
     * @covers ::getReason
     */
    public function testConstruction() {
        $a = new AccessResultNeutral();
        $this->assertEquals('', $a->getReason());
        $reason = $this->getRandomGenerator()
            ->string();
        $b = new AccessResultNeutral($reason);
        $this->assertEquals($reason, $b->getReason());
    }
    
    /**
     * Tests setReason()
     *
     * @covers ::setReason
     */
    public function testSetReason() {
        $a = new AccessResultNeutral();
        $reason = $this->getRandomGenerator()
            ->string();
        $return = $a->setReason($reason);
        $this->assertSame($reason, $a->getReason());
        $this->assertSame($a, $return);
    }

}

Classes

Title Deprecated Summary
AccessResultNeutralTest @coversDefaultClass \Drupal\Core\Access\AccessResultNeutral @group Access

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