X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FKernel%2FTheme%2FTwigFilterTest.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fsrc%2FKernel%2FTheme%2FTwigFilterTest.php;h=c1c26dd032ca59afa8e0df9a8cc6539d1c5cfb14;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/system/tests/src/Kernel/Theme/TwigFilterTest.php b/web/core/modules/system/tests/src/Kernel/Theme/TwigFilterTest.php new file mode 100644 index 000000000..c1c26dd03 --- /dev/null +++ b/web/core/modules/system/tests/src/Kernel/Theme/TwigFilterTest.php @@ -0,0 +1,123 @@ + 'twig_theme_test_filter', + '#quote' => [ + 'content' => ['#markup' => 'You can only find truth with logic if you have already found truth without it.'], + 'author' => ['#markup' => 'Gilbert Keith Chesterton'], + 'date' => ['#markup' => '1874-1936'], + ], + '#attributes' => [ + 'id' => 'quotes', + 'checked' => TRUE, + 'class' => ['red', 'green', 'blue'], + ], + ]; + $rendered = \Drupal::service('renderer')->renderRoot($filter_test); + $this->setRawContent($rendered); + + $elements = [ + [ + 'expected' => '
No author: You can only find truth with logic if you have already found truth without it.1874-1936.
', + 'message' => '"No author" was successfully rendered.', + ], + [ + 'expected' => '
Complete quote after without: You can only find truth with logic if you have already found truth without it.Gilbert Keith Chesterton1874-1936.
', + 'message' => '"Complete quote after without" was successfully rendered.', + ], + [ + 'expected' => '
Only author: Gilbert Keith Chesterton.
', + 'message' => '"Only author:" was successfully rendered.', + ], + [ + 'expected' => '
No author or date: You can only find truth with logic if you have already found truth without it..
', + 'message' => '"No author or date" was successfully rendered.', + ], + [ + 'expected' => '
Only date: 1874-1936.
', + 'message' => '"Only date" was successfully rendered.', + ], + [ + 'expected' => '
Complete quote again for good measure: You can only find truth with logic if you have already found truth without it.Gilbert Keith Chesterton1874-1936.
', + 'message' => '"Complete quote again for good measure" was successfully rendered.', + ], + [ + 'expected' => '
Marked-up: +
+

You can only find truth with logic if you have already found truth without it.

+ +
', + 'message' => '"Marked-up quote" was successfully rendered.', + ], + [ + 'expected' => '
All attributes:
', + 'message' => 'All attributes printed.', + ], + [ + 'expected' => '
Class attributes in front, remainder at the back:
', + 'message' => 'Class attributes printed in the front, the rest in the back.', + ], + [ + 'expected' => '
Class attributes in back, remainder at the front:
', + 'message' => 'Class attributes printed in the back, the rest in the front.', + ], + [ + 'expected' => '
Class attributes only:
', + 'message' => 'Class attributes only printed.', + ], + [ + 'expected' => '
Without boolean attribute.
', + 'message' => 'Boolean attribute printed in the front.', + ], + [ + 'expected' => '
Without string attribute.
', + 'message' => 'Without string attribute in the front.', + ], + [ + 'expected' => '
Without id and class attributes.
', + 'message' => 'Attributes printed without id and class attributes.', + ], + [ + 'expected' => '
All attributes again.
', + 'message' => 'All attributes printed again.', + ], + [ + 'expected' => '
ID and class. Having the same ID twice is not valid markup but we want to make sure the filter doesn\'t use \Drupal\Component\Utility\Html::getUniqueId().
', + 'message' => 'Class and ID filtered.', + ], + [ + 'expected' => '
Rendered author string length: 24.
', + 'message' => 'Render filter string\'s length.', + ], + ]; + + foreach ($elements as $element) { + $this->assertRaw($element['expected'], $element['message']); + } + } + +}