YamlFormHandlerTest.php in YAML Form 8
File
src/Tests/YamlFormHandlerTest.php
View source
<?php
namespace Drupal\yamlform\Tests;
use Drupal\yamlform\Entity\YamlForm;
use Drupal\yamlform\Entity\YamlFormSubmission;
class YamlFormHandlerTest extends YamlFormTestBase {
public function testYamlFormHandler() {
$this
->drupalLogin($this->adminFormUser);
$yamlform_handler_test = YamlForm::load('test_handler_test');
$this
->drupalGet('yamlform/test_handler_test');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->postSubmission($yamlform_handler_test, [
'element' => 'a value',
]);
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:validateForm');
$this
->assertRaw('The element must be empty. You entered <em class="placeholder">a value</em>.');
$this
->assertNoRaw('One two one two this is just a test');
$sid = $this
->postSubmission($yamlform_handler_test);
$yamlform_submission = YamlFormSubmission::load($sid);
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:validateForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:submitForm');
$this
->assertRaw('One two one two this is just a test');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:confirmForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preSave');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postSave insert');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postLoad');
$this
->drupalPostForm('/admin/structure/yamlform/manage/test_handler_test/submission/' . $sid . '/edit', [], t('Save'));
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postSave update');
$this
->drupalPostForm('/admin/structure/yamlform/manage/test_handler_test/submission/' . $sid . '/delete', [], t('Delete'));
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postLoad');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preDelete');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postDelete');
$this
->assertRaw('Submission #' . $yamlform_submission
->serial() . ' has been deleted.');
$this
->drupalPostForm('admin/structure/yamlform/manage/test_handler_test/handlers/test/edit', [
'settings[message]' => '{message}',
], t('Save'));
$this
->postSubmission($yamlform_handler_test);
$this
->assertRaw('{message}');
$this
->drupalPostForm('admin/structure/yamlform/manage/test_handler_test/handlers/test/edit', [
'status' => FALSE,
], t('Save'));
$this
->drupalGet('yamlform/test_handler_test');
$this
->assertNoRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertNoRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertNoRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertNoRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->drupalPostForm('admin/structure/yamlform/manage/test_handler_test/handlers/test/edit', [
'status' => TRUE,
], t('Save'));
$yamlform_handler_test
->setSettings([
'results_disabled' => TRUE,
]);
$yamlform_handler_test
->save();
$this
->drupalLogout();
$this
->drupalGet('yamlform/test_handler_test');
$this
->assertNoFieldByName('op', 'Submit');
$this
->assertNoRaw('This form is not saving or handling any submissions. All submitted data will be lost.');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->drupalLogin($this->adminFormUser);
$this
->drupalGet('yamlform/test_handler_test');
$this
->assertFieldByName('op', 'Submit');
$this
->assertRaw('This form is currently not saving any submitted data.');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$yamlform_handler_test
->setSetting('results_disabled', TRUE);
$yamlform_handler_test
->save();
$this
->postSubmission($yamlform_handler_test);
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postCreate');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterElements');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:alterForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:validateForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:submitForm');
$this
->assertRaw('One two one two this is just a test');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:confirmForm');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:preSave');
$this
->assertRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postSave insert');
$this
->assertNoRaw('Invoked: Drupal\\yamlform_test\\Plugin\\YamlFormHandler\\TestYamlFormHandler:postLoad');
}
}