View source
<?php
namespace Drupal\yamlform\Tests;
use Drupal\yamlform\Entity\YamlForm;
class YamlFormElementTableTest extends YamlFormTestBase {
protected static $modules = [
'system',
'user',
'yamlform',
'yamlform_test',
];
public function test() {
$yamlform = YamlForm::load('test_element_table');
$edit = [
'yamlform_tableselect_sort_custom[one][weight]' => '4',
'yamlform_tableselect_sort_custom[two][weight]' => '3',
'yamlform_tableselect_sort_custom[three][weight]' => '2',
'yamlform_tableselect_sort_custom[four][weight]' => '1',
'yamlform_tableselect_sort_custom[five][weight]' => '0',
'yamlform_tableselect_sort_custom[one][checkbox]' => TRUE,
'yamlform_tableselect_sort_custom[two][checkbox]' => TRUE,
'yamlform_tableselect_sort_custom[three][checkbox]' => TRUE,
'yamlform_tableselect_sort_custom[four][checkbox]' => TRUE,
'yamlform_tableselect_sort_custom[five][checkbox]' => TRUE,
];
$this
->drupalPostForm('yamlform/test_element_table', $edit, t('Submit'));
$this
->assertRaw("yamlform_tableselect_sort_custom:\n - five\n - four\n - three\n - two\n - one");
$edit = [
'yamlform_table_sort_custom[one][weight]' => '4',
'yamlform_table_sort_custom[two][weight]' => '3',
'yamlform_table_sort_custom[three][weight]' => '2',
'yamlform_table_sort_custom[four][weight]' => '1',
'yamlform_table_sort_custom[five][weight]' => '0',
];
$this
->drupalPostForm('yamlform/test_element_table', $edit, t('Submit'));
$this
->assertRaw("yamlform_table_sort_custom:\n - five\n - four\n - three\n - two\n - one");
$this
->drupalLogin($this->adminFormUser);
$excluded_columns = $this
->getExportColumns($yamlform);
unset($excluded_columns['yamlform_tableselect_sort_custom']);
$this
->getExport($yamlform, [
'options_format' => 'separate',
'excluded_columns' => $excluded_columns,
]);
$this
->assertRaw('"yamlform_tableselect_sort (custom): one","yamlform_tableselect_sort (custom): two","yamlform_tableselect_sort (custom): three","yamlform_tableselect_sort (custom): four","yamlform_tableselect_sort (custom): five"');
$this
->assertRaw('5,4,3,2,1');
}
}