YamlFormTest.php in YAML Form 8
File
src/Tests/YamlFormTest.php
View source
<?php
namespace Drupal\yamlform\Tests;
class YamlFormTest extends YamlFormTestBase {
public function testYamlForm() {
list($yamlform) = $this
->createYamlFormWithSubmissions();
$elements = $yamlform
->getElementsInitialized();
$this
->assert(is_array($elements));
$columns = $yamlform
->getElementsFlattenedAndHasValue();
$this
->assertEqual(array_keys($columns), [
'first_name',
'last_name',
'sex',
'dob',
'node',
'colors',
'likert',
'address',
]);
$yamlform
->set('elements', "not\nvalid\nyaml")
->save();
$this
->assertFalse($yamlform
->getElementsInitialized());
$this
->assertEqual($yamlform
->getElementsFlattenedAndHasValue(), []);
$this
->assertEqual($this->submissionStorage
->getTotal($yamlform), 3);
$yamlform
->delete();
$this
->assertEqual($this->submissionStorage
->getTotal($yamlform), 0);
$this
->assertEqual(\Drupal::state()
->get('yamlform.yamlform.' . $yamlform
->id()), NULL);
}
}