public function WebformViewsFieldTestBase::testMultiValueDeltaOffset in Webform Views Integration 8.5
Test the multivalue element placing single value into a cell.
File
- tests/
src/ Kernel/ field/ WebformViewsFieldTestBase.php, line 68
Class
- WebformViewsFieldTestBase
- Reasonable starting point for testing webform views field handlers.
Namespace
Drupal\Tests\webform_views\Kernel\fieldCode
public function testMultiValueDeltaOffset() {
// Delta offset within element multivalues to display in the cell.
$offset = 0;
// Convert each webform element into multivalue before creating the webform.
$webform_elements = $this->webform_elements;
foreach ($webform_elements as $k => $v) {
$webform_elements[$k]['#multiple'] = 10;
}
$this->webform = $this
->createWebform($webform_elements);
$this
->createWebformSubmissions($this->webform_submission_multivalue_data, $this->webform);
// Convert each view field handler into 'all in one' multi value before
// creating the view.
$view_handlers = $this->view_handlers;
foreach ($view_handlers['field'] as $k => $v) {
$view_handlers['field'][$k]['options']['webform_multiple_value'] = FALSE;
$view_handlers['field'][$k]['options']['webform_multiple_delta'] = $offset;
}
$this->view = $this
->initView($this->webform, $view_handlers);
$rendered_cells = $this
->renderView($this->view);
$expected = [];
foreach ($this->webform_submission_multivalue_data as $i => $submission) {
foreach ($submission as $element => $data) {
$expected[$i][$element] = $data[$offset];
}
}
$this
->assertSame($expected, $rendered_cells);
}