X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FCore%2FLayout%2FLayoutPluginManagerTest.php;h=139200cabeabfdb6243164171282cc30c9ebcf4e;hp=2d898591482370a889896207206c8ab755514b3b;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hpb=9424afc6c1f518c301bf87a23c047d1873435d05 diff --git a/web/core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php b/web/core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php index 2d8985914..139200cab 100644 --- a/web/core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php +++ b/web/core/tests/Drupal/Tests/Core/Layout/LayoutPluginManagerTest.php @@ -12,6 +12,7 @@ use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Layout\LayoutDefault; use Drupal\Core\Layout\LayoutDefinition; use Drupal\Core\Layout\LayoutPluginManager; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; use Prophecy\Argument; @@ -114,8 +115,12 @@ class LayoutPluginManagerTest extends UnitTestCase { $theme_a_path = vfsStream::url('root/themes/theme_a'); $layout_definition = $this->layoutPluginManager->getDefinition('theme_a_provided_layout'); $this->assertSame('theme_a_provided_layout', $layout_definition->id()); - $this->assertSame('2 column layout', $layout_definition->getLabel()); - $this->assertSame('Columns: 2', $layout_definition->getCategory()); + $this->assertSame('2 column layout', (string) $layout_definition->getLabel()); + $this->assertSame('Columns: 2', (string) $layout_definition->getCategory()); + $this->assertSame('A theme provided layout', (string) $layout_definition->getDescription()); + $this->assertTrue($layout_definition->getLabel() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getCategory() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getDescription() instanceof TranslatableMarkup); $this->assertSame('twocol', $layout_definition->getTemplate()); $this->assertSame("$theme_a_path/templates", $layout_definition->getPath()); $this->assertSame('theme_a/twocol', $layout_definition->getLibrary()); @@ -126,19 +131,26 @@ class LayoutPluginManagerTest extends UnitTestCase { $this->assertSame(LayoutDefault::class, $layout_definition->getClass()); $expected_regions = [ 'left' => [ - 'label' => 'Left region', + 'label' => new TranslatableMarkup('Left region', [], ['context' => 'layout_region']), ], 'right' => [ - 'label' => 'Right region', + 'label' => new TranslatableMarkup('Right region', [], ['context' => 'layout_region']), ], ]; - $this->assertSame($expected_regions, $layout_definition->getRegions()); + $regions = $layout_definition->getRegions(); + $this->assertEquals($expected_regions, $regions); + $this->assertTrue($regions['left']['label'] instanceof TranslatableMarkup); + $this->assertTrue($regions['right']['label'] instanceof TranslatableMarkup); $module_a_path = vfsStream::url('root/modules/module_a'); $layout_definition = $this->layoutPluginManager->getDefinition('module_a_provided_layout'); $this->assertSame('module_a_provided_layout', $layout_definition->id()); - $this->assertSame('1 column layout', $layout_definition->getLabel()); - $this->assertSame('Columns: 1', $layout_definition->getCategory()); + $this->assertSame('1 column layout', (string) $layout_definition->getLabel()); + $this->assertSame('Columns: 1', (string) $layout_definition->getCategory()); + $this->assertSame('A module provided layout', (string) $layout_definition->getDescription()); + $this->assertTrue($layout_definition->getLabel() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getCategory() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getDescription() instanceof TranslatableMarkup); $this->assertSame(NULL, $layout_definition->getTemplate()); $this->assertSame("$module_a_path/layouts", $layout_definition->getPath()); $this->assertSame('module_a/onecol', $layout_definition->getLibrary()); @@ -149,19 +161,26 @@ class LayoutPluginManagerTest extends UnitTestCase { $this->assertSame(LayoutDefault::class, $layout_definition->getClass()); $expected_regions = [ 'top' => [ - 'label' => 'Top region', + 'label' => new TranslatableMarkup('Top region', [], ['context' => 'layout_region']), ], 'bottom' => [ - 'label' => 'Bottom region', + 'label' => new TranslatableMarkup('Bottom region', [], ['context' => 'layout_region']), ], ]; - $this->assertSame($expected_regions, $layout_definition->getRegions()); + $regions = $layout_definition->getRegions(); + $this->assertEquals($expected_regions, $regions); + $this->assertTrue($regions['top']['label'] instanceof TranslatableMarkup); + $this->assertTrue($regions['bottom']['label'] instanceof TranslatableMarkup); $core_path = '/core/lib/Drupal/Core'; $layout_definition = $this->layoutPluginManager->getDefinition('plugin_provided_layout'); $this->assertSame('plugin_provided_layout', $layout_definition->id()); $this->assertEquals('Layout plugin', $layout_definition->getLabel()); $this->assertEquals('Columns: 1', $layout_definition->getCategory()); + $this->assertEquals('Test layout', $layout_definition->getDescription()); + $this->assertTrue($layout_definition->getLabel() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getCategory() instanceof TranslatableMarkup); + $this->assertTrue($layout_definition->getDescription() instanceof TranslatableMarkup); $this->assertSame('plugin-provided-layout', $layout_definition->getTemplate()); $this->assertSame($core_path, $layout_definition->getPath()); $this->assertSame(NULL, $layout_definition->getLibrary()); @@ -172,10 +191,12 @@ class LayoutPluginManagerTest extends UnitTestCase { $this->assertSame('Drupal\Core\Plugin\Layout\TestLayout', $layout_definition->getClass()); $expected_regions = [ 'main' => [ - 'label' => 'Main Region', + 'label' => new TranslatableMarkup('Main Region', [], ['context' => 'layout_region']), ], ]; - $this->assertEquals($expected_regions, $layout_definition->getRegions()); + $regions = $layout_definition->getRegions(); + $this->assertEquals($expected_regions, $regions); + $this->assertTrue($regions['main']['label'] instanceof TranslatableMarkup); } /** @@ -284,6 +305,7 @@ EOS; module_a_provided_layout: label: 1 column layout category: 'Columns: 1' + description: 'A module provided layout' theme_hook: onecol path: layouts library: module_a/onecol @@ -301,6 +323,7 @@ theme_a_provided_layout: class: '\Drupal\Core\Layout\LayoutDefault' label: 2 column layout category: 'Columns: 2' + description: 'A theme provided layout' template: twocol path: templates library: theme_a/twocol @@ -325,7 +348,7 @@ use Drupal\Core\Layout\LayoutDefault; * template = "templates/plugin-provided-layout", * regions = { * "main" = { - * "label" = @Translation("Main Region") + * "label" = @Translation("Main Region", context = "layout_region") * } * } * )