Issue #3155495 Refactor system/Kernel/Theme/ThemeTest::testThemeDataTypes
Open
requested to merge issue/drupal-3155495:3155495-refactor-systemkernelthemethemetesttestthemedatatypes into 11.x
1 unresolved thread
Rebased against 11.x
Merge request reports
Activity
57 $types = ['null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => '']; 57 $types = ['integer' => 1, 'string' => 'foo']; 58 58 foreach ($types as $type => $example) { 59 59 $output = \Drupal::theme()->render('theme_test_foo', ['foo' => $example]); 60 $this->assertTrue($output instanceof MarkupInterface || is_string($output), "\Drupal::theme() returns an object that implements MarkupInterface or a string for data type $type."); 61 if ($output instanceof MarkupInterface) { 62 $this->assertSame((string) $example, $output->__toString()); 63 } 64 elseif (is_string($output)) { 65 $this->assertSame('', $output, 'A string will be return when the theme returns an empty string.'); 66 } 60 $this->assertInstanceOf(MarkupInterface::class, $output, "\\Drupal::theme()->render() should return an object that implements MarkupInterface for data type '$type'."); 61 $this->assertEquals($example, $output); 62 } 63 64 // Check that a string is returned when the theme returns an empty string. I had to read this a few times. At first I thought, "// Check a string is returned when the theme should return an empty string." would be better. But I think this can be even simpler.
Please register or sign in to reply