You are here

public function LogCRUDTest::testCreateLog in Log entity 8

Create Log entity.

File

src/Tests/LogCRUDTest.php, line 33

Class

LogCRUDTest
Tests the Log CRUD.

Namespace

Drupal\log\Tests

Code

public function testCreateLog() {
  $edit = [
    'name[0][value]' => $this
      ->randomMachineName(),
  ];
  $this
    ->drupalPostForm('log/add/default', $edit, t('Save'));
  $result = \Drupal::entityQuery('log')
    ->condition('name', $edit['name[0][value]'])
    ->range(0, 1)
    ->execute();
  $log_id = reset($result);
  $log = Log::load($log_id);
  $this
    ->assertNotNull($log, 'Log has been created.');
  $this
    ->assertRaw(t('Created the %label Log.', [
    '%label' => $edit['name[0][value]'],
  ]));
  $this
    ->assertText($edit['name[0][value]']);
  $this
    ->assertText($this->loggedInUser
    ->getDisplayName());
}