YamlFormHandlerRemotePostTest.php in YAML Form 8
File
src/Tests/YamlFormHandlerRemotePostTest.php
View source
<?php
namespace Drupal\yamlform\Tests;
use Drupal\yamlform\Entity\YamlForm;
class YamlFormHandlerRemotePostTest extends YamlFormTestBase {
public function testRemotePostHandler() {
$yamlform_handler_remote = YamlForm::load('test_handler_remote_post');
$this
->drupalLogin($this->adminFormUser);
$sid = $this
->postSubmission($yamlform_handler_remote);
$this
->assertPattern('#<label>Remote operation</label>\\s+insert#ms');
$this
->assertRaw('custom_insert: true');
$this
->assertRaw('custom_all: true');
$this
->assertRaw("custom_title: 'Test: Handler: Remote post: Submission #{$sid}'");
$this
->assertRaw('first_name: John');
$this
->assertRaw('last_name: Smith');
$this
->assertRaw('email: from@example.com');
$this
->assertRaw("subject: '{subject}'");
$this
->assertRaw("message: '{message}'");
$this
->assertNoRaw("sid: '{$sid}'");
$this
->drupalPostForm("admin/structure/yamlform/manage/test_handler_remote_post/submission/{$sid}/edit", [], t('Save'));
$this
->assertRaw('custom_update: true');
$this
->assertRaw('custom_all: true');
$this
->assertRaw("custom_title: 'Test: Handler: Remote post: Submission #{$sid}'");
$this
->assertRaw('first_name: John');
$this
->assertPattern('#<label>Remote operation</label>\\s+update#ms');
$this
->drupalPostForm("admin/structure/yamlform/manage/test_handler_remote_post/submission/{$sid}/delete", [], t('Delete'));
$this
->assertRaw('custom_delete: true');
$this
->assertRaw('custom_all: true');
$this
->assertRaw("custom_title: 'Test: Handler: Remote post: Submission #{$sid}'");
$this
->assertRaw('first_name: John');
$this
->assertPattern('#<label>Remote operation</label>\\s+delete#ms');
$handler = $yamlform_handler_remote
->getHandler('remote_post');
$configuration = $handler
->getConfiguration();
$configuration['settings']['excluded_data'] = [
'subject' => 'subject',
'message' => 'message',
];
$handler
->setConfiguration($configuration);
$yamlform_handler_remote
->save();
$sid = $this
->postSubmission($yamlform_handler_remote);
$this
->assertRaw('first_name: John');
$this
->assertRaw('last_name: Smith');
$this
->assertRaw('email: from@example.com');
$this
->assertNoRaw("subject: '{subject}'");
$this
->assertNoRaw("message: '{message}'");
$this
->assertRaw("sid: '{$sid}'");
}
}