You are here

public function AuditLogDatabaseTest::testUserAuditLog in Audit Log 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/AuditLogDatabaseTest.php \Drupal\Tests\audit_log\Kernel\AuditLogDatabaseTest::testUserAuditLog()

Verifies that user events are written to the database.

File

tests/src/Kernel/AuditLogDatabaseTest.php, line 33

Class

AuditLogDatabaseTest
Tests the audit log database logger.

Namespace

Drupal\Tests\audit_log\Kernel

Code

public function testUserAuditLog() {
  $count = db_query('SELECT COUNT(id) FROM {audit_log}')
    ->fetchField();
  $this
    ->assertEquals(0, $count);
  $user = User::create([
    'name' => 'test name',
  ]);
  $user
    ->save();
  $count = db_query('SELECT COUNT(id) FROM {audit_log}')
    ->fetchField();
  $this
    ->assertEquals(1, $count);
  $user
    ->save();
  $count = db_query('SELECT COUNT(id) FROM {audit_log}')
    ->fetchField();
  $this
    ->assertEquals(2, $count);
}