WebformSubmissionLogNodeTest.php in Webform 8.5
File
modules/webform_submission_log/tests/src/Functional/WebformSubmissionLogNodeTest.php
View source
<?php
namespace Drupal\Tests\webform_submission_log\Functional;
use Drupal\Tests\webform_node\Functional\WebformNodeBrowserTestBase;
use Drupal\Tests\webform_submission_log\Traits\WebformSubmissionLogTrait;
use Drupal\webform\Entity\WebformSubmission;
class WebformSubmissionLogNodeTest extends WebformNodeBrowserTestBase {
use WebformSubmissionLogTrait;
public static $modules = [
'block',
'webform',
'webform_node',
'webform_submission_log',
];
protected static $testWebforms = [
'test_submission_log',
];
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());
$this
->drupalLogin($this->rootUser);
$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(),
]));
$this
->drupalGet("node/{$nid}/webform/submission/{$sid}/log");
$this
->assertResponse(200);
}
}