Redirect404LogSuppressorTest.php in Redirect 8
File
modules/redirect_404/tests/src/Functional/Redirect404LogSuppressorTest.php
View source
<?php
namespace Drupal\Tests\redirect_404\Functional;
use Drupal\Core\Database\Database;
class Redirect404LogSuppressorTest extends Redirect404TestBase {
public static $modules = [
'dblog',
];
protected $adminUser;
protected $webUser;
public function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer redirect settings',
'administer redirects',
]);
$this->webUser = $this
->drupalCreateUser([]);
}
public function testSuppress404Events() {
$this
->drupalGet('page-not-found');
$this
->assertResponse(404);
$this
->drupalLogin($this->webUser);
$this
->drupalGet('admin/reports/dblog');
$this
->assertResponse(403);
$this
->assertEqual(Database::getConnection()
->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")
->fetchField(), 1);
$this
->assertEqual(Database::getConnection()
->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")
->fetchField(), 1);
$this
->drupalLogin($this->adminUser);
$edit = [
'suppress_404' => TRUE,
];
$this
->drupalPostForm('admin/config/search/redirect/settings', $edit, 'Save configuration');
$this
->drupalGet('page-not-found');
$this
->assertResponse(404);
$this
->drupalLogin($this->webUser);
$this
->drupalGet('admin/reports/dblog');
$this
->assertResponse(403);
$this
->drupalLogin($this->adminUser);
$this
->assertEqual(Database::getConnection()
->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")
->fetchField(), 1);
$this
->assertEqual(Database::getConnection()
->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")
->fetchField(), 2);
}
}