public function WebformSubmissionLogNodeTest::testSubmissionLog in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_submission_log/tests/src/Functional/WebformSubmissionLogNodeTest.php \Drupal\Tests\webform_submission_log\Functional\WebformSubmissionLogNodeTest::testSubmissionLog()
Tests webform submission log.
File
- modules/
webform_submission_log/ tests/ src/ Functional/ WebformSubmissionLogNodeTest.php, line 35
Class
- WebformSubmissionLogNodeTest
- Tests for webform node submission log.
Namespace
Drupal\Tests\webform_submission_log\FunctionalCode
public function testSubmissionLog() {
global $base_path;
$node = $this
->createWebformNode('test_submission_log');
$nid = $node
->id();
$sid = $this
->postNodeSubmission($node);
$submission = WebformSubmission::load($sid);
$log = $this
->getLastSubmissionLog();
$this
->assertEqual($log->lid, 1);
$this
->assertEqual($log->sid, 1);
$this
->assertEqual($log->uid, 0);
$this
->assertEqual($log->handler_id, '');
$this
->assertEqual($log->operation, 'submission created');
$this
->assertEqual($log->message, '@title created.');
$this
->assertEqual($log->variables, [
'@title' => $submission
->label(),
]);
$this
->assertEqual($log->webform_id, 'test_submission_log');
$this
->assertEqual($log->entity_type, 'node');
$this
->assertEqual($log->entity_id, $node
->id());
// Login.
$this
->drupalLogin($this->rootUser);
// Check webform node results log table has record.
$this
->drupalGet("node/{$nid}/webform/results/log");
$this
->assertResponse(200);
$this
->assertNoRaw('No log messages available.');
$this
->assertRaw('<a href="' . $base_path . 'node/' . $nid . '/webform/submission/' . $sid . '/log">' . $sid . '</a>');
$this
->assertRaw(t('@title created.', [
'@title' => $submission
->label(),
]));
// Check webform node submission log tab.
$this
->drupalGet("node/{$nid}/webform/submission/{$sid}/log");
$this
->assertResponse(200);
}