18a19,112 > diff --git a/src/Tests/LayoutFluidTest.php b/src/Tests/LayoutFluidTest.php > new file mode 100644 > index 0000000..67d2be3 > --- /dev/null > +++ b/src/Tests/LayoutFluidTest.php > @@ -0,0 +1,88 @@ > + + > +/** > + * @file > + * Definition of Drupal\ds\Tests\LayoutFluidTest. > + */ > + > +namespace Drupal\ds\Tests; > + > +/** > + * Tests DS layout plugins > + * > + * @group ds > + */ > +class LayoutFluidTest extends FastTestBase { > + > + /** > + * Test fluid Display Suite layouts. > + */ > + function testFluidLayout() { > + // Assert our 2 tests layouts are found. > + $this->drupalGet('admin/structure/types/manage/article/display'); > + $this->assertRaw('Test Fluid two column', 'Test Fluid two column layout found'); > + > + $layout = array( > + 'layout' => 'dstest_2col_fluid', > + ); > + > + $assert = array( > + 'regions' => array( > + 'left' => '' . t('Left') . '', > + 'right' => '' . t('Right') . '', > + ), > + ); > + > + $fields = array( > + 'fields[node_author][region]' => 'left', > + 'fields[node_links][region]' => 'left', > + 'fields[body][region]' => 'left', > + ); > + > + $this->dsSelectLayout($layout, $assert); > + $this->dsConfigureUI($fields); > + > + // Create a node. > + $settings = array('type' => 'article'); > + $node = $this->drupalCreateNode($settings); > + > + $this->drupalGet('node/' . $node->id()); > + $this->assertRaw('group-left', 'Template found (region left)'); > + $this->assertNoRaw('group-right', 'Empty region right hidden'); > + $this->assertRaw('group-one-column', 'Group one column class set'); > + $this->assertRaw('dstest-2col-fluid.css', 'Css file included'); > + > + // Add fields to the right column > + $fields = array( > + 'fields[node_author][region]' => 'left', > + 'fields[node_links][region]' => 'left', > + 'fields[body][region]' => 'right', > + ); > + > + $this->dsSelectLayout($layout, $assert); > + $this->dsConfigureUI($fields); > + > + $this->drupalGet('node/' . $node->id()); > + $this->assertRaw('group-left', 'Template found (region left)'); > + $this->assertRaw('group-right', 'Template found (region right)'); > + $this->assertNoRaw('group-one-column', 'Group one column class not set'); > + > + // Move all fields to the right column > + $fields = array( > + 'fields[node_author][region]' => 'right', > + 'fields[node_links][region]' => 'right', > + 'fields[heavy_field][region]' => 'right', > + 'fields[body][region]' => 'right', > + ); > + > + $this->dsSelectLayout($layout, $assert); > + $this->dsConfigureUI($fields); > + > + $this->drupalGet('node/' . $node->id()); > + $this->assertNoRaw('group-left', 'Empty region left hidden'); > + $this->assertRaw('group-right', 'Template found (region right)'); > + $this->assertRaw('group-one-column', 'Group one column class set'); > + > + } > + > +} 61a156,239 > diff --git a/tests/modules/ds_test/css/dstest-2col-fluid.css b/tests/modules/ds_test/css/dstest-2col-fluid.css > new file mode 100644 > index 0000000..28b230c > --- /dev/null > +++ b/tests/modules/ds_test/css/dstest-2col-fluid.css > @@ -0,0 +1,10 @@ > + > +.group-left { > + float: left; > + width: 50%; > +} > + > +.group-right { > + float: left; > + width: 50%; > +} > diff --git a/tests/modules/ds_test/ds_test.layouts.yml b/tests/modules/ds_test/ds_test.layouts.yml > index e501a24..f043cca 100644 > --- a/tests/modules/ds_test/ds_test.layouts.yml > +++ b/tests/modules/ds_test/ds_test.layouts.yml > @@ -19,3 +19,15 @@ dstest_2col: > label: Left > right: > label: Right > +dstest_2col_fluid: > + label: Test Fluid two column > + category: Display Suite > + class: '\Drupal\ds\Plugin\DsLayout' > + type: partial > + template: templates/dstest-2col-fluid > + css: css/dstest-2col-fluid.css > + regions: > + left: > + label: Left > + right: > + label: Right > \ No newline at end of file > diff --git a/tests/modules/ds_test/templates/dstest-2col-fluid.html.twig b/tests/modules/ds_test/templates/dstest-2col-fluid.html.twig > new file mode 100644 > index 0000000..4b64910 > --- /dev/null > +++ b/tests/modules/ds_test/templates/dstest-2col-fluid.html.twig > @@ -0,0 +1,41 @@ > +{# > +/** > + * @file > + * Display Suite fluid 2 column template. > + * > + * Available variables: > + * - outer_wrapper: outer wrapper element > + * - left_wrapper: wrapper element around left region > + * - right_wrapper: wrapper element around right region > + * - attributes: layout attributes > + * - left_attributes: attributes for left region > + * - right_attributes: attributes for right region > + * - left: content of left region > + * - right: content of right region > + */ > +#} > + > +{% set left = left|render %} > +{% set right = right|render %} > + > +{% if (left and not right) or (right and not left) %} > + {% set layout_class = 'group-one-column' %} > +{% endif %} > + > +<{{ outer_wrapper }}{{ attributes.addClass(layout_class, 'ds-2col-fluid', 'clearfix') }}> > + > + {{ title_suffix.contextual_links }} > + > + {% if left %} > + <{{ left_wrapper }}{{ left_attributes.addClass('group-left') }}> > + {{ left }} > + > + {% endif %} > + > + {% if right %} > + <{{ right_wrapper }}{{ right_attributes.addClass('group-right') }}> > + {{ right }} > + > + {% endif %} > + > +