You are here

public function DbLogTest::testTemporaryUser in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/dblog/src/Tests/DbLogTest.php \Drupal\dblog\Tests\DbLogTest::testTemporaryUser()

Tests that the details page displays correctly for a temporary user.

File

core/modules/dblog/src/Tests/DbLogTest.php, line 706
Contains \Drupal\dblog\Tests\DbLogTest.

Class

DbLogTest
Generate events and verify dblog entries; verify user access to log reports based on permissions.

Namespace

Drupal\dblog\Tests

Code

public function testTemporaryUser() {

  // Create a temporary user.
  $tempuser = $this
    ->drupalCreateUser();
  $tempuser_uid = $tempuser
    ->id();

  // Log in as the admin user.
  $this
    ->drupalLogin($this->adminUser);

  // Generate a single watchdog entry.
  $this
    ->generateLogEntries(1, array(
    'user' => $tempuser,
    'uid' => $tempuser_uid,
  ));
  $wid = db_query('SELECT MAX(wid) FROM {watchdog}')
    ->fetchField();

  // Check if the full message displays on the details page.
  $this
    ->drupalGet('admin/reports/dblog/event/' . $wid);
  $this
    ->assertText('Dblog test log message');

  // Delete the user.
  user_delete($tempuser
    ->id());
  $this
    ->drupalGet('user/' . $tempuser_uid);
  $this
    ->assertResponse(404);

  // Check if the full message displays on the details page.
  $this
    ->drupalGet('admin/reports/dblog/event/' . $wid);
  $this
    ->assertText('Dblog test log message');
}