You are here

public function IconBuilderTest::providerTestBuild in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php \Drupal\KernelTests\Core\Layout\IconBuilderTest::providerTestBuild()

File

core/tests/Drupal/KernelTests/Core/Layout/IconBuilderTest.php, line 35

Class

IconBuilderTest
@coversDefaultClass \Drupal\Core\Layout\Icon\SvgIconBuilder @group Layout

Namespace

Drupal\KernelTests\Core\Layout

Code

public function providerTestBuild() {
  $data = [];
  $data['empty'][] = new SvgIconBuilder();
  $data['empty'][] = [];
  $data['empty'][] = <<<'EOD'
<svg width="125" height="150" class="layout-icon"></svg>

EOD;
  $data['two_column'][] = (new SvgIconBuilder())
    ->setId('two_column')
    ->setLabel('Two Column')
    ->setWidth(250)
    ->setHeight(300)
    ->setStrokeWidth(2);
  $data['two_column'][] = [
    [
      'left',
      'right',
    ],
  ];
  $data['two_column'][] = <<<'EOD'
<svg width="250" height="300" class="layout-icon layout-icon--two-column"><title>Two Column</title>
<g><title>left</title>
<rect x="1" y="1" width="121" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--left" />
</g>
<g><title>right</title>
<rect x="128" y="1" width="121" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--right" />
</g>
</svg>

EOD;
  $data['two_column_no_stroke'][] = (new SvgIconBuilder())
    ->setWidth(250)
    ->setHeight(300)
    ->setStrokeWidth(NULL);
  $data['two_column_no_stroke'][] = [
    [
      'left',
      'right',
    ],
  ];
  $data['two_column_no_stroke'][] = <<<'EOD'
<svg width="250" height="300" class="layout-icon"><g><title>left</title>
<rect x="0" y="0" width="123" height="300" class="layout-icon__region layout-icon__region--left" />
</g>
<g><title>right</title>
<rect x="127" y="0" width="123" height="300" class="layout-icon__region layout-icon__region--right" />
</g>
</svg>

EOD;
  $data['two_column_border_collapse'][] = (new SvgIconBuilder())
    ->setWidth(250)
    ->setHeight(300)
    ->setStrokeWidth(2)
    ->setPadding(-2);
  $data['two_column_border_collapse'][] = [
    [
      'left',
      'right',
    ],
  ];
  $data['two_column_border_collapse'][] = <<<'EOD'
<svg width="250" height="300" class="layout-icon"><g><title>left</title>
<rect x="1" y="1" width="124" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--left" />
</g>
<g><title>right</title>
<rect x="125" y="1" width="124" height="298" stroke-width="2" class="layout-icon__region layout-icon__region--right" />
</g>
</svg>

EOD;
  $data['stacked'][] = (new SvgIconBuilder())
    ->setStrokeWidth(2);
  $data['stacked'][] = [
    [
      'sidebar',
      'top',
      'top',
    ],
    [
      'sidebar',
      'left',
      'right',
    ],
    [
      'sidebar',
      'middle',
      'middle',
    ],
    [
      'footer_left',
      'footer_right',
    ],
    [
      'footer_full',
    ],
  ];
  $data['stacked'][] = <<<'EOD'
<svg width="125" height="150" class="layout-icon"><g><title>sidebar</title>
<rect x="1" y="1" width="37" height="86.4" stroke-width="2" class="layout-icon__region layout-icon__region--sidebar" />
</g>
<g><title>top</title>
<rect x="44" y="1" width="80" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--top" />
</g>
<g><title>left</title>
<rect x="44" y="31.8" width="37" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--left" />
</g>
<g><title>right</title>
<rect x="87" y="31.8" width="37" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--right" />
</g>
<g><title>middle</title>
<rect x="44" y="62.6" width="80" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--middle" />
</g>
<g><title>footer_left</title>
<rect x="1" y="93.4" width="58.5" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--footer-left" />
</g>
<g><title>footer_right</title>
<rect x="65.5" y="93.4" width="58.5" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--footer-right" />
</g>
<g><title>footer_full</title>
<rect x="1" y="124.2" width="123" height="24.8" stroke-width="2" class="layout-icon__region layout-icon__region--footer-full" />
</g>
</svg>

EOD;
  return $data;
}