X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Ftwig_theme_test%2Ftwig_theme_test.module;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Ftwig_theme_test%2Ftwig_theme_test.module;h=a8b4086203ad844160a9e5fcd064be20e3644b5d;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module b/web/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module new file mode 100644 index 000000000..a8b408620 --- /dev/null +++ b/web/core/modules/system/tests/modules/twig_theme_test/twig_theme_test.module @@ -0,0 +1,123 @@ + ['quote' => [], 'attributes' => []], + 'template' => 'twig_theme_test.filter', + ]; + $items['twig_theme_test_php_variables'] = [ + 'template' => 'twig_theme_test.php_variables', + ]; + $items['twig_theme_test_trans'] = [ + 'variables' => [], + 'template' => 'twig_theme_test.trans', + ]; + $items['twig_theme_test_placeholder_outside_trans'] = [ + 'variables' => ['var' => ''], + 'template' => 'twig_theme_test.placeholder_outside_trans', + ]; + $items['twig_namespace_test'] = [ + 'variables' => [], + 'template' => 'twig_namespace_test', + ]; + $items['twig_registry_loader_test'] = [ + 'variables' => [], + ]; + $items['twig_registry_loader_test_include'] = [ + 'variables' => [], + ]; + $items['twig_registry_loader_test_extend'] = [ + 'variables' => [], + ]; + $items['twig_raw_test'] = [ + 'variables' => ['script' => ''], + ]; + $items['twig_autoescape_test'] = [ + 'variables' => ['script' => ''], + ]; + $items['twig_theme_test_url_generator'] = [ + 'variables' => [], + 'template' => 'twig_theme_test.url_generator', + ]; + $items['twig_theme_test_link_generator'] = [ + 'variables' => [ + 'test_url' => NULL, + 'test_url_attribute' => NULL, + 'attributes' => [], + ], + 'template' => 'twig_theme_test.link_generator', + ]; + $items['twig_theme_test_url_to_string'] = [ + 'variables' => ['test_url' => NULL], + 'template' => 'twig_theme_test.url_to_string', + ]; + $items['twig_theme_test_file_url'] = [ + 'variables' => [], + 'template' => 'twig_theme_test.file_url', + ]; + $items['twig_theme_test_attach_library'] = [ + 'variables' => [], + 'template' => 'twig_theme_test.attach_library', + ]; + $items['twig_theme_test_renderable'] = [ + 'variables' => [ + 'renderable' => NULL, + ], + 'template' => 'twig_theme_test.renderable', + ]; + return $items; +} + +/** + * Helper function to test PHP variables in the Twig engine. + */ +function _test_theme_twig_php_values() { + // Prefix each variable with "twig_" so that Twig doesn't get confused + // between a variable and a primitive. Arrays are not tested since they should + // be a Drupal render array. + return [ + 'twig_null' => [ + 'value' => NULL, + 'expected' => '', + ], + 'twig_bool_false' => [ + 'value' => FALSE, + 'expected' => '', + ], + 'twig_bool_true' => [ + 'value' => TRUE, + 'expected' => '1', + ], + 'twig_int' => [ + 'value' => 1, + 'expected' => '1', + ], + 'twig_int_0' => [ + 'value' => 0, + 'expected' => '0', + ], + 'twig_float' => [ + 'value' => 122.34343, + 'expected' => '122.34343', + ], + 'twig_string' => [ + 'value' => 'Hello world!', + 'expected' => 'Hello world!', + ], + ]; +} + +/** + * Implements template_preprocess_status_messages(). + */ +function twig_theme_test_preprocess_status_messages(&$variables) { + $variables['attributes']['class'][] = 'custom-test-messages-class'; +}