M4032404TestCaseTest.php in 403 to 404 8
File
tests/src/Functional/M4032404TestCaseTest.php
View source
<?php
namespace Drupal\Tests\m4032404\Functional;
use Drupal\Tests\BrowserTestBase;
class M4032404TestCaseTest extends BrowserTestBase {
protected $privilegedUser;
protected static $modules = [
'm4032404',
];
public function setUp() {
parent::setUp();
$this->privilegedUser = $this
->drupalCreateUser();
$this
->drupalLogin($this->privilegedUser);
}
public function testM4032404Test404() {
$this
->drupalGet('admin');
$this
->assertResponse(404, 'Anonymous users get a 404 instead of a 403.');
$this
->drupalGet('user/1');
$this
->assertResponse(404, 'User gets a 404 instead of a 403 on non-admin paths.');
$this
->config('m4032404.settings')
->set('admin_only', TRUE)
->save();
$this
->drupalGet('user/1');
$this
->assertResponse(403, 'User gets a 403 on non-admin paths when admin-only is configured.');
}
}