YamlFormUiElementPropertiesTest.php in YAML Form 8
File
modules/yamlform_ui/src/Tests/YamlFormUiElementPropertiesTest.php
View source
<?php
namespace Drupal\yamlform_ui\Tests;
use Drupal\yamlform\Tests\YamlFormTestBase;
use Drupal\yamlform\Entity\YamlForm;
class YamlFormUiElementPropertiesTest extends YamlFormTestBase {
public static $modules = [
'system',
'filter',
'user',
'yamlform',
'yamlform_test',
'yamlform_examples',
'yamlform_ui',
];
public function setUp() {
parent::setUp();
$this
->createFilters();
}
public function testElementProperties() {
$this
->drupalLogin($this->adminFormUser);
$yamlform_ids = [
'example_layout_basic',
'test_element',
'test_element_access',
'test_element_extras',
'test_form_states_triggers',
];
foreach ($yamlform_ids as $yamlform_id) {
$yamlform_elements = YamlForm::load($yamlform_id);
$original_elements = $yamlform_elements
->getElementsDecodedAndFlattened();
foreach ($original_elements as $key => $original_element) {
$this
->drupalPostForm('admin/structure/yamlform/manage/' . $yamlform_elements
->id() . '/element/' . $key . '/edit', [], t('Save'));
\Drupal::entityTypeManager()
->getStorage('yamlform_submission')
->resetCache();
$yamlform_elements = YamlForm::load($yamlform_id);
$updated_element = $yamlform_elements
->getElementsDecodedAndFlattened()[$key];
$this
->assertEqual($original_element, $updated_element, "'{$key}'' properties is equal.");
}
}
}
}