Version Description
Fixes and improvements - Fix issue with debug on/off in certain installs #2084 (thanks @kmonahan) - Fix link to admin pages #2112 (thanks @Beee4life)
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 1.13.0 |
Comparing to | |
See all releases |
Code changes from version 1.12.0 to 1.13.0
- lib/Admin.php +1 -1
- lib/Loader.php +5 -2
- lib/Timber.php +1 -1
- readme.txt +7 -2
- timber-starter-theme/templates/partial/pagination.twig +10 -10
- timber.php +1 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +6 -6
- vendor/composer/installed.json +6 -6
- vendor/twig/twig/.gitattributes +2 -0
- vendor/twig/twig/CHANGELOG +5 -0
- vendor/twig/twig/doc/filters/batch.rst +1 -0
- vendor/twig/twig/doc/filters/map.rst +0 -1
- vendor/twig/twig/doc/filters/reduce.rst +0 -1
- vendor/twig/twig/ext/twig/php_twig.h +1 -1
- vendor/twig/twig/phpunit.xml.dist +0 -33
- vendor/twig/twig/src/Environment.php +4 -4
- vendor/twig/twig/src/Lexer.php +1 -1
- vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php +9 -5
- vendor/twig/twig/tests/AutoloaderTest.php +0 -26
- vendor/twig/twig/tests/Cache/FilesystemTest.php +0 -193
- vendor/twig/twig/tests/CompilerTest.php +0 -38
- vendor/twig/twig/tests/ContainerRuntimeLoaderTest.php +0 -44
- vendor/twig/twig/tests/CustomExtensionTest.php +0 -94
- vendor/twig/twig/tests/EnvironmentTest.php +0 -678
- vendor/twig/twig/tests/ErrorTest.php +0 -234
- vendor/twig/twig/tests/ExpressionParserTest.php +0 -382
- vendor/twig/twig/tests/Extension/CoreTest.php +0 -371
- vendor/twig/twig/tests/Extension/SandboxTest.php +0 -365
- vendor/twig/twig/tests/FactoryRuntimeLoaderTest.php +0 -36
- vendor/twig/twig/tests/FileCachingTest.php +0 -66
- vendor/twig/twig/tests/FileExtensionEscapingStrategyTest.php +0 -55
- vendor/twig/twig/tests/FilesystemHelper.php +0 -32
- vendor/twig/twig/tests/Fixtures/autoescape/block.test +0 -21
- vendor/twig/twig/tests/Fixtures/autoescape/name.test +0 -22
- vendor/twig/twig/tests/Fixtures/errors/base.html +0 -1
- vendor/twig/twig/tests/Fixtures/errors/index.html +0 -7
- vendor/twig/twig/tests/Fixtures/errors/leak-output.php +0 -33
- vendor/twig/twig/tests/Fixtures/exceptions/child_contents_outside_blocks.test +0 -15
- vendor/twig/twig/tests/Fixtures/exceptions/exception_in_extension_extends.test +0 -12
- vendor/twig/twig/tests/Fixtures/exceptions/exception_in_extension_include.test +0 -12
- vendor/twig/twig/tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test +0 -18
- vendor/twig/twig/tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test +0 -18
- vendor/twig/twig/tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test +0 -12
- vendor/twig/twig/tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test +0 -9
- vendor/twig/twig/tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test +0 -12
- vendor/twig/twig/tests/Fixtures/exceptions/strict_comparison_operator.test +0 -6
- vendor/twig/twig/tests/Fixtures/exceptions/syntax_error_in_reused_template.test +0 -10
- vendor/twig/twig/tests/Fixtures/exceptions/unclosed_tag.test +0 -20
- vendor/twig/twig/tests/Fixtures/exceptions/undefined_parent.test +0 -10
- vendor/twig/twig/tests/Fixtures/exceptions/undefined_template_in_child_template.test +0 -15
- vendor/twig/twig/tests/Fixtures/exceptions/undefined_trait.test +0 -9
- vendor/twig/twig/tests/Fixtures/expressions/_self.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/array.test +0 -61
- vendor/twig/twig/tests/Fixtures/expressions/array_call.test +0 -14
- vendor/twig/twig/tests/Fixtures/expressions/binary.test +0 -46
- vendor/twig/twig/tests/Fixtures/expressions/bitwise.test +0 -14
- vendor/twig/twig/tests/Fixtures/expressions/call_argument_defined_twice.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/call_positional_arg_after_named_arg.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/comparison.test +0 -14
- vendor/twig/twig/tests/Fixtures/expressions/divisibleby.test +0 -17
- vendor/twig/twig/tests/Fixtures/expressions/dotdot.test +0 -20
- vendor/twig/twig/tests/Fixtures/expressions/ends_with.test +0 -26
- vendor/twig/twig/tests/Fixtures/expressions/floats.test +0 -16
- vendor/twig/twig/tests/Fixtures/expressions/grouping.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/literals.test +0 -22
- vendor/twig/twig/tests/Fixtures/expressions/magic_call.test +0 -27
- vendor/twig/twig/tests/Fixtures/expressions/matches.test +0 -12
- vendor/twig/twig/tests/Fixtures/expressions/method_call.test +0 -28
- vendor/twig/twig/tests/Fixtures/expressions/negative_numbers.test +0 -18
- vendor/twig/twig/tests/Fixtures/expressions/not_arrow_fn.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/operators_as_variables.test +0 -16
- vendor/twig/twig/tests/Fixtures/expressions/postfix.test +0 -22
- vendor/twig/twig/tests/Fixtures/expressions/power.test +0 -20
- vendor/twig/twig/tests/Fixtures/expressions/sameas.test +0 -21
- vendor/twig/twig/tests/Fixtures/expressions/starts_with.test +0 -27
- vendor/twig/twig/tests/Fixtures/expressions/string_operator_as_var_assignment.test +0 -18
- vendor/twig/twig/tests/Fixtures/expressions/strings.test +0 -10
- vendor/twig/twig/tests/Fixtures/expressions/ternary_operator.test +0 -18
- vendor/twig/twig/tests/Fixtures/expressions/ternary_operator_noelse.test +0 -10
- vendor/twig/twig/tests/Fixtures/expressions/ternary_operator_nothen.test +0 -10
- vendor/twig/twig/tests/Fixtures/expressions/two_word_operators_as_variables.test +0 -8
- vendor/twig/twig/tests/Fixtures/expressions/unary.test +0 -12
- vendor/twig/twig/tests/Fixtures/expressions/unary_macro_arguments.test +0 -22
- vendor/twig/twig/tests/Fixtures/expressions/unary_precedence.test +0 -14
- vendor/twig/twig/tests/Fixtures/filters/abs.test +0 -30
- vendor/twig/twig/tests/Fixtures/filters/batch.test +0 -31
- vendor/twig/twig/tests/Fixtures/filters/batch_float.test +0 -29
- vendor/twig/twig/tests/Fixtures/filters/batch_with_empty_fill.test +0 -37
- vendor/twig/twig/tests/Fixtures/filters/batch_with_exact_elements.test +0 -33
- vendor/twig/twig/tests/Fixtures/filters/batch_with_fill.test +0 -37
- vendor/twig/twig/tests/Fixtures/filters/batch_with_keys.test +0 -10
- vendor/twig/twig/tests/Fixtures/filters/batch_with_more_elements.test +0 -23
- vendor/twig/twig/tests/Fixtures/filters/batch_with_zero_elements.test +0 -10
- vendor/twig/twig/tests/Fixtures/filters/convert_encoding.test +0 -10
- vendor/twig/twig/tests/Fixtures/filters/date.test +0 -90
- vendor/twig/twig/tests/Fixtures/filters/date_default_format.test +0 -14
- vendor/twig/twig/tests/Fixtures/filters/date_default_format_interval.test +0 -16
- vendor/twig/twig/tests/Fixtures/filters/date_immutable.test +0 -37
- vendor/twig/twig/tests/Fixtures/filters/date_interval.test +0 -19
- vendor/twig/twig/tests/Fixtures/filters/date_modify.test +0 -14
- vendor/twig/twig/tests/Fixtures/filters/date_namedargs.test +0 -13
- vendor/twig/twig/tests/Fixtures/filters/default.test +0 -150
- vendor/twig/twig/tests/Fixtures/filters/dynamic_filter.test +0 -10
- vendor/twig/twig/tests/Fixtures/filters/escape.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/escape_html_attr.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/escape_javascript.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/escape_non_supported_charset.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/filter.test +0 -46
- vendor/twig/twig/tests/Fixtures/filters/filter_php_55.test +0 -23
- vendor/twig/twig/tests/Fixtures/filters/filter_php_56.test +0 -27
- vendor/twig/twig/tests/Fixtures/filters/first.test +0 -17
- vendor/twig/twig/tests/Fixtures/filters/force_escape.test +0 -18
- vendor/twig/twig/tests/Fixtures/filters/format.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/join.test +0 -38
- vendor/twig/twig/tests/Fixtures/filters/json_encode.test +0 -12
- vendor/twig/twig/tests/Fixtures/filters/last.test +0 -17
- vendor/twig/twig/tests/Fixtures/filters/length.test +0 -40
- vendor/twig/twig/tests/Fixtures/filters/length_utf8.test +0 -12
- vendor/twig/twig/tests/Fixtures/filters/map.test +0 -41
- vendor/twig/twig/tests/Fixtures/filters/merge.test +0 -25
- vendor/twig/twig/tests/Fixtures/filters/nl2br.test +0 -14
- vendor/twig/twig/tests/Fixtures/filters/number_format.test +0 -18
- vendor/twig/twig/tests/Fixtures/filters/number_format_default.test +0 -21
- vendor/twig/twig/tests/Fixtures/filters/reduce.test +0 -14
- vendor/twig/twig/tests/Fixtures/filters/replace.test +0 -12
- vendor/twig/twig/tests/Fixtures/filters/replace_invalid_arg.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/reverse.test +0 -18
- vendor/twig/twig/tests/Fixtures/filters/round.test +0 -22
- vendor/twig/twig/tests/Fixtures/filters/slice.test +0 -54
- vendor/twig/twig/tests/Fixtures/filters/sort.test +0 -12
- vendor/twig/twig/tests/Fixtures/filters/spaceless.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/special_chars.test +0 -8
- vendor/twig/twig/tests/Fixtures/filters/split.test +0 -22
- vendor/twig/twig/tests/Fixtures/filters/split_utf8.test +0 -24
- vendor/twig/twig/tests/Fixtures/filters/static_calls.test +0 -10
- vendor/twig/twig/tests/Fixtures/filters/trim.test +0 -24
- vendor/twig/twig/tests/Fixtures/filters/urlencode.test +0 -16
- vendor/twig/twig/tests/Fixtures/filters/urlencode_deprecated.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/attribute.test +0 -18
- vendor/twig/twig/tests/Fixtures/functions/block.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/block_with_template.test +0 -22
- vendor/twig/twig/tests/Fixtures/functions/block_without_name.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/constant.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/cycle.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/date.test +0 -27
- vendor/twig/twig/tests/Fixtures/functions/date_namedargs.test +0 -11
- vendor/twig/twig/tests/Fixtures/functions/dump.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/dump_array.test +0 -19
- vendor/twig/twig/tests/Fixtures/functions/dynamic_function.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/include/assignment.test +0 -13
- vendor/twig/twig/tests/Fixtures/functions/include/autoescaping.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/include/basic.test +0 -17
- vendor/twig/twig/tests/Fixtures/functions/include/expression.test +0 -17
- vendor/twig/twig/tests/Fixtures/functions/include/ignore_missing.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/include/ignore_missing_exists.test +0 -11
- vendor/twig/twig/tests/Fixtures/functions/include/include_missing_extends.test +0 -13
- vendor/twig/twig/tests/Fixtures/functions/include/missing.test +0 -8
- vendor/twig/twig/tests/Fixtures/functions/include/missing_nested.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/include/sandbox.test +0 -13
- vendor/twig/twig/tests/Fixtures/functions/include/sandbox_disabling.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test +0 -13
- vendor/twig/twig/tests/Fixtures/functions/include/template_instance.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/include/templates_as_array.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/include/with_context.test +0 -16
- vendor/twig/twig/tests/Fixtures/functions/include/with_variables.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/include_template_from_string.test +0 -11
- vendor/twig/twig/tests/Fixtures/functions/magic_call.test +0 -8
- vendor/twig/twig/tests/Fixtures/functions/magic_call53.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/max.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/min.test +0 -12
- vendor/twig/twig/tests/Fixtures/functions/range.test +0 -8
- vendor/twig/twig/tests/Fixtures/functions/recursive_block_with_inheritance.test +0 -21
- vendor/twig/twig/tests/Fixtures/functions/source.test +0 -17
- vendor/twig/twig/tests/Fixtures/functions/special_chars.test +0 -8
- vendor/twig/twig/tests/Fixtures/functions/static_calls.test +0 -10
- vendor/twig/twig/tests/Fixtures/functions/template_from_string.test +0 -15
- vendor/twig/twig/tests/Fixtures/functions/template_from_string_error.test +0 -8
- vendor/twig/twig/tests/Fixtures/macros/default_values.test +0 -16
- vendor/twig/twig/tests/Fixtures/macros/nested_calls.test +0 -18
- vendor/twig/twig/tests/Fixtures/macros/reserved_variables.test +0 -14
- vendor/twig/twig/tests/Fixtures/macros/simple.test +0 -22
- vendor/twig/twig/tests/Fixtures/macros/varargs.test +0 -21
- vendor/twig/twig/tests/Fixtures/macros/varargs_argument.test +0 -7
- vendor/twig/twig/tests/Fixtures/macros/with_filters.test +0 -14
- vendor/twig/twig/tests/Fixtures/regression/block_names_unicity.test +0 -19
- vendor/twig/twig/tests/Fixtures/regression/combined_debug_info.test +0 -15
- vendor/twig/twig/tests/Fixtures/regression/empty_token.test +0 -8
- vendor/twig/twig/tests/Fixtures/regression/issue_1143.test +0 -23
- vendor/twig/twig/tests/Fixtures/regression/multi_word_tests.test +0 -10
- vendor/twig/twig/tests/Fixtures/regression/simple_xml_element.test +0 -19
- vendor/twig/twig/tests/Fixtures/regression/strings_like_numbers.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/apply/basic.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/apply/json_encode.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/apply/multiple.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/apply/nested.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/apply/scope.test +0 -15
- vendor/twig/twig/tests/Fixtures/tags/apply/with_for_tag.test +0 -13
- vendor/twig/twig/tests/Fixtures/tags/apply/with_if_tag.test +0 -29
- vendor/twig/twig/tests/Fixtures/tags/autoescape/basic.test +0 -26
- vendor/twig/twig/tests/Fixtures/tags/autoescape/blocks.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/autoescape/double_escaping.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/autoescape/functions.test +0 -83
- vendor/twig/twig/tests/Fixtures/tags/autoescape/literal.test +0 -87
- vendor/twig/twig/tests/Fixtures/tags/autoescape/nested.test +0 -26
- vendor/twig/twig/tests/Fixtures/tags/autoescape/objects.test +0 -26
- vendor/twig/twig/tests/Fixtures/tags/autoescape/raw.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/autoescape/strategy.legacy.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/autoescape/strategy.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/autoescape/type.test +0 -69
- vendor/twig/twig/tests/Fixtures/tags/autoescape/with_filters.test +0 -131
- vendor/twig/twig/tests/Fixtures/tags/autoescape/with_filters_arguments.test +0 -23
- vendor/twig/twig/tests/Fixtures/tags/autoescape/with_pre_escape_filters.test +0 -68
- vendor/twig/twig/tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test +0 -50
- vendor/twig/twig/tests/Fixtures/tags/block/basic.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/block/block_unique_name.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/block/special_chars.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/deprecated/block.legacy.test +0 -20
- vendor/twig/twig/tests/Fixtures/tags/deprecated/macro.legacy.test +0 -21
- vendor/twig/twig/tests/Fixtures/tags/deprecated/template.legacy.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/embed/basic.test +0 -35
- vendor/twig/twig/tests/Fixtures/tags/embed/complex_dynamic_parent.test +0 -35
- vendor/twig/twig/tests/Fixtures/tags/embed/dynamic_parent.test +0 -35
- vendor/twig/twig/tests/Fixtures/tags/embed/error_line.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/embed/multiple.test +0 -50
- vendor/twig/twig/tests/Fixtures/tags/embed/nested.test +0 -42
- vendor/twig/twig/tests/Fixtures/tags/embed/with_extends.test +0 -60
- vendor/twig/twig/tests/Fixtures/tags/filter/basic.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/filter/json_encode.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/filter/multiple.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/filter/nested.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/filter/scope.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/filter/with_for_tag.test +0 -13
- vendor/twig/twig/tests/Fixtures/tags/filter/with_if_tag.test +0 -29
- vendor/twig/twig/tests/Fixtures/tags/for/condition.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/for/context.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/for/else.test +0 -23
- vendor/twig/twig/tests/Fixtures/tags/for/inner_variables.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/for/keys.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/for/keys_and_values.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/for/loop_context.test +0 -19
- vendor/twig/twig/tests/Fixtures/tags/for/loop_context_local.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/for/loop_not_defined.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/for/loop_not_defined_cond.test +0 -9
- vendor/twig/twig/tests/Fixtures/tags/for/nested_else.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/for/objects.test +0 -43
- vendor/twig/twig/tests/Fixtures/tags/for/objects_countable.test +0 -47
- vendor/twig/twig/tests/Fixtures/tags/for/recursive.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/for/values.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/from.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/if/basic.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/if/expression.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/include/basic.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/include/expression.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/include/ignore_missing.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/include/ignore_missing_exists.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/include/include_missing_extends.test +0 -13
- vendor/twig/twig/tests/Fixtures/tags/include/missing.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/include/missing_nested.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/include/only.test +0 -20
- vendor/twig/twig/tests/Fixtures/tags/include/template_instance.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/include/templates_as_array.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/include/with_variables.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/basic.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/block_expr.test +0 -30
- vendor/twig/twig/tests/Fixtures/tags/inheritance/block_expr2.test +0 -32
- vendor/twig/twig/tests/Fixtures/tags/inheritance/conditional.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/dynamic.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/empty.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_in_block.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_in_macro.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/inheritance/multiple.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/multiple_dynamic.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_blocks.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test +0 -15
- vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_inheritance.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_as_template_wrapper.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_change.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_isolation.test +0 -20
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_nested.test +0 -28
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_without_extends.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/template_instance.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/inheritance/use.test +0 -44
- vendor/twig/twig/tests/Fixtures/tags/macro/basic.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/macro/endmacro_name.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/macro/external.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/macro/from.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/from_in_block_is_local.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/from_local_override.test +0 -28
- vendor/twig/twig/tests/Fixtures/tags/macro/from_macro_in_a_macro.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/from_nested_blocks.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/from_nested_blocks_with_global_macro.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/from_syntax_error.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/macro/from_with_reserved_name.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/macro/global.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/macro/import_and_blocks.test +0 -36
- vendor/twig/twig/tests/Fixtures/tags/macro/import_from_string_template.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/macro/import_in_block_is_local.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/import_local_override.test +0 -28
- vendor/twig/twig/tests/Fixtures/tags/macro/import_macro_in_a_macro.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/import_nested_blocks.legacy.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/import_nested_blocks_with_global_macro.legacy.test +0 -18
- vendor/twig/twig/tests/Fixtures/tags/macro/import_self_parent.test +0 -23
- vendor/twig/twig/tests/Fixtures/tags/macro/import_syntax_error.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/macro/import_with_reserved_name.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/macro/reserved_name.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/macro/self_import.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/macro/special_chars.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/macro/super_globals.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/raw/basic.legacy.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/raw/whitespace_control.legacy.test +0 -56
- vendor/twig/twig/tests/Fixtures/tags/sandbox/array.test +0 -16
- vendor/twig/twig/tests/Fixtures/tags/sandbox/not_valid1.test +0 -11
- vendor/twig/twig/tests/Fixtures/tags/sandbox/not_valid2.test +0 -14
- vendor/twig/twig/tests/Fixtures/tags/sandbox/simple.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/set/basic.test +0 -20
- vendor/twig/twig/tests/Fixtures/tags/set/capture-empty.test +0 -9
- vendor/twig/twig/tests/Fixtures/tags/set/capture.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/set/capture_scope.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/set/expression.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/set/inheritance.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/set/inheritance_overriding.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/set/mutating.test +0 -17
- vendor/twig/twig/tests/Fixtures/tags/spaceless/simple.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/special_chars.test +0 -8
- vendor/twig/twig/tests/Fixtures/tags/use/aliases.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/use/basic.test +0 -12
- vendor/twig/twig/tests/Fixtures/tags/use/deep.test +0 -22
- vendor/twig/twig/tests/Fixtures/tags/use/deep_empty.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/use/inheritance.test +0 -25
- vendor/twig/twig/tests/Fixtures/tags/use/inheritance2.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/use/multiple.test +0 -21
- vendor/twig/twig/tests/Fixtures/tags/use/multiple_aliases.test +0 -23
- vendor/twig/twig/tests/Fixtures/tags/use/parent_block.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/use/parent_block2.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/use/parent_block3.test +0 -38
- vendor/twig/twig/tests/Fixtures/tags/use/use_with_parent.test +0 -24
- vendor/twig/twig/tests/Fixtures/tags/verbatim/basic.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/verbatim/whitespace_control.test +0 -56
- vendor/twig/twig/tests/Fixtures/tags/with/basic.test +0 -13
- vendor/twig/twig/tests/Fixtures/tags/with/expression.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/with/globals.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/with/iterable.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/with/nested.test +0 -15
- vendor/twig/twig/tests/Fixtures/tags/with/with_no_hash.test +0 -10
- vendor/twig/twig/tests/Fixtures/tags/with/with_only.test +0 -10
- vendor/twig/twig/tests/Fixtures/tests/array.test +0 -24
- vendor/twig/twig/tests/Fixtures/tests/constant.test +0 -14
- vendor/twig/twig/tests/Fixtures/tests/defined.test +0 -129
- vendor/twig/twig/tests/Fixtures/tests/defined_for_attribute.test +0 -35
- vendor/twig/twig/tests/Fixtures/tests/defined_for_blocks.test +0 -38
- vendor/twig/twig/tests/Fixtures/tests/defined_for_blocks_with_template.test +0 -17
- vendor/twig/twig/tests/Fixtures/tests/defined_for_constants.test +0 -14
- vendor/twig/twig/tests/Fixtures/tests/defined_on_complex_expr.test +0 -8
- vendor/twig/twig/tests/Fixtures/tests/dynamic_test.test +0 -14
- vendor/twig/twig/tests/Fixtures/tests/empty.test +0 -54
- vendor/twig/twig/tests/Fixtures/tests/even.test +0 -14
- vendor/twig/twig/tests/Fixtures/tests/in.test +0 -118
- vendor/twig/twig/tests/Fixtures/tests/in_with_objects.test +0 -19
- vendor/twig/twig/tests/Fixtures/tests/iterable.test +0 -19
- vendor/twig/twig/tests/Fixtures/tests/null_coalesce.test +0 -30
- vendor/twig/twig/tests/Fixtures/tests/odd.test +0 -10
- vendor/twig/twig/tests/Fixtures/whitespace/trim_block.test +0 -68
- vendor/twig/twig/tests/Fixtures/whitespace/trim_delimiter_as_strings.test +0 -10
- vendor/twig/twig/tests/Fixtures/whitespace/trim_left.test +0 -32
- vendor/twig/twig/tests/Fixtures/whitespace/trim_line_left.test +0 -33
- vendor/twig/twig/tests/Fixtures/whitespace/trim_line_right.test +0 -32
- vendor/twig/twig/tests/Fixtures/whitespace/trim_right.test +0 -28
- vendor/twig/twig/tests/IntegrationTest.php +0 -386
- vendor/twig/twig/tests/LegacyFixtures/autoescape/filename.legacy.test +0 -18
- vendor/twig/twig/tests/LegacyFixtures/functions/undefined_block.legacy.test +0 -12
- vendor/twig/twig/tests/LegacyFixtures/test.legacy.test +0 -8
- vendor/twig/twig/tests/LegacyIntegrationTest.php +0 -59
- vendor/twig/twig/tests/LexerTest.php +0 -378
- vendor/twig/twig/tests/Loader/ArrayTest.php +0 -139
- vendor/twig/twig/tests/Loader/ChainTest.php +0 -133
- vendor/twig/twig/tests/Loader/FilesystemTest.php +0 -247
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig +0 -3
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig +0 -3
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig +0 -3
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig +0 -3
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/parent.html.twig +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/inheritance/spare_parent.html.twig +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/named/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/named_bis/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/named_final/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/named_quater/named_absolute.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/named_ter/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/normal/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/normal_bis/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/normal_final/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/normal_ter/index.html +0 -1
- vendor/twig/twig/tests/Loader/Fixtures/phar/phar-sample.phar +0 -0
- vendor/twig/twig/tests/Loader/Fixtures/themes/theme1/blocks.html.twig +0 -3
- vendor/twig/twig/tests/Loader/Fixtures/themes/theme2/blocks.html.twig +0 -3
- vendor/twig/twig/tests/NativeExtensionTest.php +0 -43
- vendor/twig/twig/tests/Node/AutoEscapeTest.php +0 -39
- vendor/twig/twig/tests/Node/BlockReferenceTest.php +0 -36
- vendor/twig/twig/tests/Node/BlockTest.php +0 -45
- vendor/twig/twig/tests/Node/DeprecatedTest.php +0 -82
- vendor/twig/twig/tests/Node/DoTest.php +0 -38
- vendor/twig/twig/tests/Node/Expression/ArrayTest.php +0 -43
- vendor/twig/twig/tests/Node/Expression/AssignNameTest.php +0 -34
- vendor/twig/twig/tests/Node/Expression/Binary/AddTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/AndTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/ConcatTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/DivTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/FloorDivTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/ModTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/MulTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/OrTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/Binary/SubTest.php +0 -40
- vendor/twig/twig/tests/Node/Expression/CallTest.php +0 -139
- vendor/twig/twig/tests/Node/Expression/ConditionalTest.php +0 -44
- vendor/twig/twig/tests/Node/Expression/ConstantTest.php +0 -35
- vendor/twig/twig/tests/Node/Expression/FilterTest.php +0 -161
- vendor/twig/twig/tests/Node/Expression/FunctionTest.php +0 -119
- vendor/twig/twig/tests/Node/Expression/GetAttrTest.php +0 -59
- vendor/twig/twig/tests/Node/Expression/NameTest.php +0 -49
- vendor/twig/twig/tests/Node/Expression/NullCoalesceTest.php +0 -38
- vendor/twig/twig/tests/Node/Expression/PHP53/FilterInclude.php +0 -8
- vendor/twig/twig/tests/Node/Expression/PHP53/FunctionInclude.php +0 -8
- vendor/twig/twig/tests/Node/Expression/PHP53/TestInclude.php +0 -8
- vendor/twig/twig/tests/Node/Expression/ParentTest.php +0 -33
- vendor/twig/twig/tests/Node/Expression/TestTest.php +0 -92
- vendor/twig/twig/tests/Node/Expression/Unary/NegTest.php +0 -38
- vendor/twig/twig/tests/Node/Expression/Unary/NotTest.php +0 -37
- vendor/twig/twig/tests/Node/Expression/Unary/PosTest.php +0 -37
- vendor/twig/twig/tests/Node/ForTest.php +0 -201
- vendor/twig/twig/tests/Node/IfTest.php +0 -97
- vendor/twig/twig/tests/Node/ImportTest.php +0 -47
- vendor/twig/twig/tests/Node/IncludeTest.php +0 -95
- vendor/twig/twig/tests/Node/MacroTest.php +0 -83
- vendor/twig/twig/tests/Node/ModuleTest.php +0 -270
- vendor/twig/twig/tests/Node/PrintTest.php +0 -35
- vendor/twig/twig/tests/Node/SandboxTest.php +0 -49
- vendor/twig/twig/tests/Node/SetTest.php +0 -80
- vendor/twig/twig/tests/Node/SpacelessTest.php +0 -44
- vendor/twig/twig/tests/Node/TextTest.php +0 -33
- vendor/twig/twig/tests/NodeTraverserTest.php +0 -49
- vendor/twig/twig/tests/NodeVisitor/OptimizerTest.php +0 -116
- vendor/twig/twig/tests/ParserTest.php +0 -218
- vendor/twig/twig/tests/Profiler/Dumper/AbstractTest.php +0 -107
- vendor/twig/twig/tests/Profiler/Dumper/BlackfireTest.php +0 -36
- vendor/twig/twig/tests/Profiler/Dumper/HtmlTest.php +0 -34
- vendor/twig/twig/tests/Profiler/Dumper/TextTest.php +0 -34
- vendor/twig/twig/tests/Profiler/ProfileTest.php +0 -114
- vendor/twig/twig/tests/TemplateTest.php +0 -809
- vendor/twig/twig/tests/TemplateWrapperTest.php +0 -70
- vendor/twig/twig/tests/TokenStreamTest.php +0 -85
- vendor/twig/twig/tests/Util/DeprecationCollectorTest.php +0 -48
- vendor/twig/twig/tests/escapingTest.php +0 -327
lib/Admin.php
CHANGED
@@ -21,7 +21,7 @@ class Admin {
|
|
21 |
public static function meta_links( $links, $file ) {
|
22 |
if ( strstr($file, '/timber.php') ) {
|
23 |
unset($links[2]);
|
24 |
-
$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&plugin=timber-library&TB_iframe=true&width=600&height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
|
25 |
$links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
|
26 |
$links[] = '<a href="https://timber.github.io/docs/" target="_blank">Documentation</a>';
|
27 |
$links[] = '<a href="https://timber.github.io/docs/getting-started/setup/" target="_blank">Starter Guide</a>';
|
21 |
public static function meta_links( $links, $file ) {
|
22 |
if ( strstr($file, '/timber.php') ) {
|
23 |
unset($links[2]);
|
24 |
+
$links[] = '<a href="' . admin_url( '/wp-admin/plugin-install.php?tab=plugin-information&plugin=timber-library&TB_iframe=true&width=600&height=550' ) . '" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
|
25 |
$links[] = '<a href="http://upstatement.com/timber" target="_blank">Homepage</a>';
|
26 |
$links[] = '<a href="https://timber.github.io/docs/" target="_blank">Documentation</a>';
|
27 |
$links[] = '<a href="https://timber.github.io/docs/getting-started/setup/" target="_blank">Starter Guide</a>';
|
lib/Loader.php
CHANGED
@@ -71,7 +71,8 @@ class Loader {
|
|
71 |
}
|
72 |
$data = apply_filters('timber_loader_render_data', $data);
|
73 |
$data = apply_filters('timber/loader/render_data', $data, $file);
|
74 |
-
$
|
|
|
75 |
}
|
76 |
|
77 |
if ( false !== $output && false !== $expires && null !== $key ) {
|
@@ -152,7 +153,7 @@ class Loader {
|
|
152 |
*/
|
153 |
public function get_twig() {
|
154 |
$loader = $this->get_loader();
|
155 |
-
$params = array('debug' => WP_DEBUG,
|
156 |
if ( isset(Timber::$autoescape) ) {
|
157 |
$params['autoescape'] = Timber::$autoescape === true ? 'html' : Timber::$autoescape;
|
158 |
}
|
@@ -229,6 +230,8 @@ class Loader {
|
|
229 |
}
|
230 |
|
231 |
/**
|
|
|
|
|
232 |
* @param string|false $dirPath
|
233 |
*/
|
234 |
public static function rrmdir( $dirPath ) {
|
71 |
}
|
72 |
$data = apply_filters('timber_loader_render_data', $data);
|
73 |
$data = apply_filters('timber/loader/render_data', $data, $file);
|
74 |
+
$template = $twig->load($file);
|
75 |
+
$output = $template->render($data);
|
76 |
}
|
77 |
|
78 |
if ( false !== $output && false !== $expires && null !== $key ) {
|
153 |
*/
|
154 |
public function get_twig() {
|
155 |
$loader = $this->get_loader();
|
156 |
+
$params = array('debug' => WP_DEBUG,'autoescape' => false);
|
157 |
if ( isset(Timber::$autoescape) ) {
|
158 |
$params['autoescape'] = Timber::$autoescape === true ? 'html' : Timber::$autoescape;
|
159 |
}
|
230 |
}
|
231 |
|
232 |
/**
|
233 |
+
* Remove a directory and everything inside
|
234 |
+
*
|
235 |
* @param string|false $dirPath
|
236 |
*/
|
237 |
public static function rrmdir( $dirPath ) {
|
lib/Timber.php
CHANGED
@@ -35,7 +35,7 @@ use Timber\Loader;
|
|
35 |
*/
|
36 |
class Timber {
|
37 |
|
38 |
-
public static $version = '1.
|
39 |
public static $locations;
|
40 |
public static $dirname = 'views';
|
41 |
public static $twig_cache = false;
|
35 |
*/
|
36 |
class Timber {
|
37 |
|
38 |
+
public static $version = '1.13.0';
|
39 |
public static $locations;
|
40 |
public static $dirname = 'views';
|
41 |
public static $twig_cache = false;
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 4.7.12
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 1.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -34,6 +34,11 @@ _Twig is the template language powering Timber; if you need a little background
|
|
34 |
|
35 |
**Changes for Theme Developers**
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
= 1.12.0 =
|
38 |
|
39 |
**Fixes and improvements**
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 4.7.12
|
5 |
+
Tested up to: 5.3
|
6 |
+
Stable tag: 1.13.0
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
34 |
|
35 |
**Changes for Theme Developers**
|
36 |
|
37 |
+
= 1.13.0 =
|
38 |
+
**Fixes and improvements**
|
39 |
+
- Fix issue with debug on/off in certain installs #2084 (thanks @kmonahan)
|
40 |
+
- Fix link to admin pages #2112 (thanks @Beee4life)
|
41 |
+
|
42 |
= 1.12.0 =
|
43 |
|
44 |
**Fixes and improvements**
|
timber-starter-theme/templates/partial/pagination.twig
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
<ul class="pagination">
|
4 |
|
5 |
{# First #}
|
6 |
-
{% if pagination.pages|first and pagination.pages|first.current != true %}
|
7 |
<li class="first btn">
|
8 |
-
<a href="{{ pagination.pages|first.link }}">First</a>
|
9 |
</li>
|
10 |
{% else %}
|
11 |
<li class="first btn disabled">
|
@@ -14,9 +14,9 @@
|
|
14 |
{% endif %}
|
15 |
|
16 |
{# Previous #}
|
17 |
-
{% if pagination.prev %}
|
18 |
<li class="prev btn">
|
19 |
-
<a href="{{ pagination.prev.link }}">Previous</a>
|
20 |
</li>
|
21 |
{% else %}
|
22 |
<li class="prev btn disabled">
|
@@ -25,7 +25,7 @@
|
|
25 |
{% endif %}
|
26 |
|
27 |
{# Pages #}
|
28 |
-
{% for page in pagination.pages %}
|
29 |
{% if page.link %}
|
30 |
<li>
|
31 |
<a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
|
@@ -38,9 +38,9 @@
|
|
38 |
{% endfor %}
|
39 |
|
40 |
{# Next #}
|
41 |
-
{% if pagination.next %}
|
42 |
<li class="next btn">
|
43 |
-
<a href="{{ pagination.next.link }}">Next</a>
|
44 |
</li>
|
45 |
{% else %}
|
46 |
<li class="next btn disabled">
|
@@ -49,16 +49,16 @@
|
|
49 |
{% endif %}
|
50 |
|
51 |
{# Last #}
|
52 |
-
{% if pagination.pages|last and pagination.pages|last.current != true %}
|
53 |
<li class="last btn">
|
54 |
-
<a href="{{ pagination.pages|last.link }}">Last</a>
|
55 |
</li>
|
56 |
{% else %}
|
57 |
<li class="last btn disabled">
|
58 |
<button disabled>Last</button>
|
59 |
</li>
|
60 |
{% endif %}
|
61 |
-
|
62 |
</ul>
|
63 |
</nav>
|
64 |
{% endif %}
|
3 |
<ul class="pagination">
|
4 |
|
5 |
{# First #}
|
6 |
+
{% if posts.pagination.pages|first and posts.pagination.pages|first.current != true %}
|
7 |
<li class="first btn">
|
8 |
+
<a href="{{ posts.pagination.pages|first.link }}">First</a>
|
9 |
</li>
|
10 |
{% else %}
|
11 |
<li class="first btn disabled">
|
14 |
{% endif %}
|
15 |
|
16 |
{# Previous #}
|
17 |
+
{% if posts.pagination.prev %}
|
18 |
<li class="prev btn">
|
19 |
+
<a href="{{ posts.pagination.prev.link }}">Previous</a>
|
20 |
</li>
|
21 |
{% else %}
|
22 |
<li class="prev btn disabled">
|
25 |
{% endif %}
|
26 |
|
27 |
{# Pages #}
|
28 |
+
{% for page in posts.pagination.pages %}
|
29 |
{% if page.link %}
|
30 |
<li>
|
31 |
<a href="{{ page.link }}" class="{{ page.class }}">{{ page.title }}</a>
|
38 |
{% endfor %}
|
39 |
|
40 |
{# Next #}
|
41 |
+
{% if posts.pagination.next %}
|
42 |
<li class="next btn">
|
43 |
+
<a href="{{ posts.pagination.next.link }}">Next</a>
|
44 |
</li>
|
45 |
{% else %}
|
46 |
<li class="next btn disabled">
|
49 |
{% endif %}
|
50 |
|
51 |
{# Last #}
|
52 |
+
{% if posts.pagination.pages|last and posts.pagination.pages|last.current != true %}
|
53 |
<li class="last btn">
|
54 |
+
<a href="{{ posts.pagination.pages|last.link }}">Last</a>
|
55 |
</li>
|
56 |
{% else %}
|
57 |
<li class="last btn disabled">
|
58 |
<button disabled>Last</button>
|
59 |
</li>
|
60 |
{% endif %}
|
61 |
+
|
62 |
</ul>
|
63 |
</nav>
|
64 |
{% endif %}
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 1.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
4 |
Description: The WordPress Timber Library allows you to write themes using the power of Twig templates.
|
5 |
Plugin URI: http://timber.upstatement.com
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 1.13.0
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
// we look for Composer files first in the plugins dir.
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit54d7be5edfb3045bf104020f539d2c76::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitccb9f2abd58411029afebcc31b227257
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitccb9f2abd58411029afebcc31b227257
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit54d7be5edfb3045bf104020f539d2c76
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit54d7be5edfb3045bf104020f539d2c76', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit54d7be5edfb3045bf104020f539d2c76', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequire54d7be5edfb3045bf104020f539d2c76($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequire54d7be5edfb3045bf104020f539d2c76($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
@@ -616,11 +616,11 @@ class ComposerStaticInitccb9f2abd58411029afebcc31b227257
|
|
616 |
public static function getInitializer(ClassLoader $loader)
|
617 |
{
|
618 |
return \Closure::bind(function () use ($loader) {
|
619 |
-
$loader->prefixLengthsPsr4 =
|
620 |
-
$loader->prefixDirsPsr4 =
|
621 |
-
$loader->fallbackDirsPsr4 =
|
622 |
-
$loader->prefixesPsr0 =
|
623 |
-
$loader->classMap =
|
624 |
|
625 |
}, null, ClassLoader::class);
|
626 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit54d7be5edfb3045bf104020f539d2c76
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
616 |
public static function getInitializer(ClassLoader $loader)
|
617 |
{
|
618 |
return \Closure::bind(function () use ($loader) {
|
619 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$prefixLengthsPsr4;
|
620 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$prefixDirsPsr4;
|
621 |
+
$loader->fallbackDirsPsr4 = ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$fallbackDirsPsr4;
|
622 |
+
$loader->prefixesPsr0 = ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$prefixesPsr0;
|
623 |
+
$loader->classMap = ComposerStaticInit54d7be5edfb3045bf104020f539d2c76::$classMap;
|
624 |
|
625 |
}, null, ClassLoader::class);
|
626 |
}
|
vendor/composer/installed.json
CHANGED
@@ -298,17 +298,17 @@
|
|
298 |
},
|
299 |
{
|
300 |
"name": "twig/twig",
|
301 |
-
"version": "v1.42.
|
302 |
-
"version_normalized": "1.42.
|
303 |
"source": {
|
304 |
"type": "git",
|
305 |
"url": "https://github.com/twigphp/Twig.git",
|
306 |
-
"reference": "
|
307 |
},
|
308 |
"dist": {
|
309 |
"type": "zip",
|
310 |
-
"url": "https://api.github.com/repos/twigphp/Twig/zipball/
|
311 |
-
"reference": "
|
312 |
"shasum": ""
|
313 |
},
|
314 |
"require": {
|
@@ -320,7 +320,7 @@
|
|
320 |
"symfony/debug": "^3.4|^4.2",
|
321 |
"symfony/phpunit-bridge": "^4.4@dev|^5.0"
|
322 |
},
|
323 |
-
"time": "2019-
|
324 |
"type": "library",
|
325 |
"extra": {
|
326 |
"branch-alias": {
|
298 |
},
|
299 |
{
|
300 |
"name": "twig/twig",
|
301 |
+
"version": "v1.42.4",
|
302 |
+
"version_normalized": "1.42.4.0",
|
303 |
"source": {
|
304 |
"type": "git",
|
305 |
"url": "https://github.com/twigphp/Twig.git",
|
306 |
+
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152"
|
307 |
},
|
308 |
"dist": {
|
309 |
"type": "zip",
|
310 |
+
"url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152",
|
311 |
+
"reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152",
|
312 |
"shasum": ""
|
313 |
},
|
314 |
"require": {
|
320 |
"symfony/debug": "^3.4|^4.2",
|
321 |
"symfony/phpunit-bridge": "^4.4@dev|^5.0"
|
322 |
},
|
323 |
+
"time": "2019-11-11T16:49:32+00:00",
|
324 |
"type": "library",
|
325 |
"extra": {
|
326 |
"branch-alias": {
|
vendor/twig/twig/.gitattributes
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/tests export-ignore
|
2 |
+
/phpunit.xml.dist export-ignore
|
vendor/twig/twig/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
* 1.42.3 (2019-08-24)
|
2 |
|
3 |
* fixed the "split" filter when the delimiter is "0"
|
1 |
+
* 1.42.4 (2019-11-11)
|
2 |
+
|
3 |
+
* optimized "block('foo') ?? 'bar"
|
4 |
+
* added supported for exponential numbers
|
5 |
+
|
6 |
* 1.42.3 (2019-08-24)
|
7 |
|
8 |
* fixed the "split" filter when the delimiter is "0"
|
vendor/twig/twig/doc/filters/batch.rst
CHANGED
@@ -49,3 +49,4 @@ Arguments
|
|
49 |
|
50 |
* ``size``: The size of the batch; fractional numbers will be rounded up
|
51 |
* ``fill``: Used to fill in missing items
|
|
49 |
|
50 |
* ``size``: The size of the batch; fractional numbers will be rounded up
|
51 |
* ``fill``: Used to fill in missing items
|
52 |
+
* ``preserve_keys``: Whether to preserve keys or not
|
vendor/twig/twig/doc/filters/map.rst
CHANGED
@@ -34,5 +34,4 @@ Note that the arrow function has access to the current context.
|
|
34 |
Arguments
|
35 |
---------
|
36 |
|
37 |
-
* ``array``: The sequence or mapping
|
38 |
* ``arrow``: The arrow function
|
34 |
Arguments
|
35 |
---------
|
36 |
|
|
|
37 |
* ``arrow``: The arrow function
|
vendor/twig/twig/doc/filters/reduce.rst
CHANGED
@@ -28,6 +28,5 @@ Note that the arrow function has access to the current context.
|
|
28 |
Arguments
|
29 |
---------
|
30 |
|
31 |
-
* ``array``: The sequence or mapping
|
32 |
* ``arrow``: The arrow function
|
33 |
* ``initial``: The initial value
|
28 |
Arguments
|
29 |
---------
|
30 |
|
|
|
31 |
* ``arrow``: The arrow function
|
32 |
* ``initial``: The initial value
|
vendor/twig/twig/ext/twig/php_twig.h
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
#ifndef PHP_TWIG_H
|
16 |
#define PHP_TWIG_H
|
17 |
|
18 |
-
#define PHP_TWIG_VERSION "1.42.
|
19 |
|
20 |
#include "php.h"
|
21 |
|
15 |
#ifndef PHP_TWIG_H
|
16 |
#define PHP_TWIG_H
|
17 |
|
18 |
+
#define PHP_TWIG_VERSION "1.42.4"
|
19 |
|
20 |
#include "php.h"
|
21 |
|
vendor/twig/twig/phpunit.xml.dist
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
|
3 |
-
<phpunit backupGlobals="false"
|
4 |
-
backupStaticAttributes="false"
|
5 |
-
colors="true"
|
6 |
-
convertErrorsToExceptions="true"
|
7 |
-
convertNoticesToExceptions="true"
|
8 |
-
convertWarningsToExceptions="true"
|
9 |
-
processIsolation="false"
|
10 |
-
stopOnFailure="false"
|
11 |
-
bootstrap="vendor/autoload.php"
|
12 |
-
>
|
13 |
-
<testsuites>
|
14 |
-
<testsuite name="Twig Test Suite">
|
15 |
-
<directory>./tests/</directory>
|
16 |
-
</testsuite>
|
17 |
-
</testsuites>
|
18 |
-
|
19 |
-
<php>
|
20 |
-
<ini name="error_reporting" value="-1" />
|
21 |
-
<ini name="xdebug.overload_var_dump" value="0" />
|
22 |
-
</php>
|
23 |
-
|
24 |
-
<listeners>
|
25 |
-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
|
26 |
-
</listeners>
|
27 |
-
|
28 |
-
<filter>
|
29 |
-
<whitelist>
|
30 |
-
<directory suffix=".php">./src/</directory>
|
31 |
-
</whitelist>
|
32 |
-
</filter>
|
33 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/src/Environment.php
CHANGED
@@ -41,11 +41,11 @@ use Twig\TokenParser\TokenParserInterface;
|
|
41 |
*/
|
42 |
class Environment
|
43 |
{
|
44 |
-
const VERSION = '1.42.
|
45 |
-
const VERSION_ID =
|
46 |
const MAJOR_VERSION = 1;
|
47 |
const MINOR_VERSION = 42;
|
48 |
-
const RELEASE_VERSION =
|
49 |
const EXTRA_VERSION = '';
|
50 |
|
51 |
protected $charset;
|
@@ -515,7 +515,7 @@ class Environment
|
|
515 |
*
|
516 |
* This method should not be used as a generic way to load templates.
|
517 |
*
|
518 |
-
* @param string $template The template
|
519 |
* @param string $name An optional name of the template to be used in error messages
|
520 |
*
|
521 |
* @return TemplateWrapper A template instance representing the given template name
|
41 |
*/
|
42 |
class Environment
|
43 |
{
|
44 |
+
const VERSION = '1.42.4';
|
45 |
+
const VERSION_ID = 14204;
|
46 |
const MAJOR_VERSION = 1;
|
47 |
const MINOR_VERSION = 42;
|
48 |
+
const RELEASE_VERSION = 4;
|
49 |
const EXTRA_VERSION = '';
|
50 |
|
51 |
protected $charset;
|
515 |
*
|
516 |
* This method should not be used as a generic way to load templates.
|
517 |
*
|
518 |
+
* @param string $template The template source
|
519 |
* @param string $name An optional name of the template to be used in error messages
|
520 |
*
|
521 |
* @return TemplateWrapper A template instance representing the given template name
|
vendor/twig/twig/src/Lexer.php
CHANGED
@@ -47,7 +47,7 @@ class Lexer implements \Twig_LexerInterface
|
|
47 |
const STATE_INTERPOLATION = 4;
|
48 |
|
49 |
const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
|
50 |
-
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
|
51 |
const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
|
52 |
const REGEX_DQ_STRING_DELIM = '/"/A';
|
53 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
47 |
const STATE_INTERPOLATION = 4;
|
48 |
|
49 |
const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
|
50 |
+
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A';
|
51 |
const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
|
52 |
const REGEX_DQ_STRING_DELIM = '/"/A';
|
53 |
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
vendor/twig/twig/src/Node/Expression/NullCoalesceExpression.php
CHANGED
@@ -22,11 +22,15 @@ class NullCoalesceExpression extends ConditionalExpression
|
|
22 |
{
|
23 |
public function __construct(\Twig_NodeInterface $left, \Twig_NodeInterface $right, $lineno)
|
24 |
{
|
25 |
-
$test = new
|
26 |
-
|
27 |
-
|
28 |
-
$
|
29 |
-
|
|
|
|
|
|
|
|
|
30 |
|
31 |
parent::__construct($test, $left, $right, $lineno);
|
32 |
}
|
22 |
{
|
23 |
public function __construct(\Twig_NodeInterface $left, \Twig_NodeInterface $right, $lineno)
|
24 |
{
|
25 |
+
$test = new DefinedTest(clone $left, 'defined', new Node(), $left->getTemplateLine());
|
26 |
+
// for "block()", we don't need the null test as the return value is always a string
|
27 |
+
if (!$left instanceof BlockReferenceExpression) {
|
28 |
+
$test = new AndBinary(
|
29 |
+
$test,
|
30 |
+
new NotUnary(new NullTest($left, 'null', new Node(), $left->getTemplateLine()), $left->getTemplateLine()),
|
31 |
+
$left->getTemplateLine()
|
32 |
+
);
|
33 |
+
}
|
34 |
|
35 |
parent::__construct($test, $left, $right, $lineno);
|
36 |
}
|
vendor/twig/twig/tests/AutoloaderTest.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
class AutoloaderTest extends \PHPUnit\Framework\TestCase
|
15 |
-
{
|
16 |
-
/**
|
17 |
-
* @group legacy
|
18 |
-
*/
|
19 |
-
public function testAutoload()
|
20 |
-
{
|
21 |
-
$this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig');
|
22 |
-
|
23 |
-
$autoloader = new \Twig_Autoloader();
|
24 |
-
$this->assertNull($autoloader->autoload('Foo'), '->autoload() returns false if it is not able to load a class');
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Cache/FilesystemTest.php
DELETED
@@ -1,193 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Cache;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Cache\FilesystemCache;
|
15 |
-
use Twig\Tests\FilesystemHelper;
|
16 |
-
|
17 |
-
class FilesystemTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
private $classname;
|
20 |
-
private $directory;
|
21 |
-
private $cache;
|
22 |
-
|
23 |
-
protected function setUp()
|
24 |
-
{
|
25 |
-
$nonce = hash('sha256', uniqid(mt_rand(), true));
|
26 |
-
$this->classname = '__Twig_Tests_Cache_FilesystemTest_Template_'.$nonce;
|
27 |
-
$this->directory = sys_get_temp_dir().'/twig-test';
|
28 |
-
$this->cache = new FilesystemCache($this->directory);
|
29 |
-
}
|
30 |
-
|
31 |
-
protected function tearDown()
|
32 |
-
{
|
33 |
-
if (file_exists($this->directory)) {
|
34 |
-
FilesystemHelper::removeDir($this->directory);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
|
38 |
-
public function testLoad()
|
39 |
-
{
|
40 |
-
$key = $this->directory.'/cache/cachefile.php';
|
41 |
-
|
42 |
-
$dir = \dirname($key);
|
43 |
-
@mkdir($dir, 0777, true);
|
44 |
-
$this->assertDirectoryExists($dir);
|
45 |
-
$this->assertFalse(class_exists($this->classname, false));
|
46 |
-
|
47 |
-
$content = $this->generateSource();
|
48 |
-
file_put_contents($key, $content);
|
49 |
-
|
50 |
-
$this->cache->load($key);
|
51 |
-
|
52 |
-
$this->assertTrue(class_exists($this->classname, false));
|
53 |
-
}
|
54 |
-
|
55 |
-
public function testLoadMissing()
|
56 |
-
{
|
57 |
-
$key = $this->directory.'/cache/cachefile.php';
|
58 |
-
|
59 |
-
$this->assertFalse(class_exists($this->classname, false));
|
60 |
-
|
61 |
-
$this->cache->load($key);
|
62 |
-
|
63 |
-
$this->assertFalse(class_exists($this->classname, false));
|
64 |
-
}
|
65 |
-
|
66 |
-
public function testWrite()
|
67 |
-
{
|
68 |
-
$key = $this->directory.'/cache/cachefile.php';
|
69 |
-
$content = $this->generateSource();
|
70 |
-
|
71 |
-
$this->assertFileNotExists($key);
|
72 |
-
$this->assertFileNotExists($this->directory);
|
73 |
-
|
74 |
-
$this->cache->write($key, $content);
|
75 |
-
|
76 |
-
$this->assertFileExists($this->directory);
|
77 |
-
$this->assertFileExists($key);
|
78 |
-
$this->assertSame(file_get_contents($key), $content);
|
79 |
-
}
|
80 |
-
|
81 |
-
public function testWriteFailMkdir()
|
82 |
-
{
|
83 |
-
$this->expectException('\RuntimeException');
|
84 |
-
$this->expectExceptionMessage('Unable to create the cache directory');
|
85 |
-
|
86 |
-
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
|
87 |
-
$this->markTestSkipped('Read-only directories not possible on Windows.');
|
88 |
-
}
|
89 |
-
|
90 |
-
$key = $this->directory.'/cache/cachefile.php';
|
91 |
-
$content = $this->generateSource();
|
92 |
-
|
93 |
-
$this->assertFileNotExists($key);
|
94 |
-
|
95 |
-
// Create read-only root directory.
|
96 |
-
@mkdir($this->directory, 0555, true);
|
97 |
-
$this->assertDirectoryExists($this->directory);
|
98 |
-
|
99 |
-
$this->cache->write($key, $content);
|
100 |
-
}
|
101 |
-
|
102 |
-
public function testWriteFailDirWritable()
|
103 |
-
{
|
104 |
-
$this->expectException('\RuntimeException');
|
105 |
-
$this->expectExceptionMessage('Unable to write in the cache directory');
|
106 |
-
|
107 |
-
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
|
108 |
-
$this->markTestSkipped('Read-only directories not possible on Windows.');
|
109 |
-
}
|
110 |
-
|
111 |
-
$key = $this->directory.'/cache/cachefile.php';
|
112 |
-
$content = $this->generateSource();
|
113 |
-
|
114 |
-
$this->assertFileNotExists($key);
|
115 |
-
|
116 |
-
// Create root directory.
|
117 |
-
@mkdir($this->directory, 0777, true);
|
118 |
-
// Create read-only subdirectory.
|
119 |
-
@mkdir($this->directory.'/cache', 0555);
|
120 |
-
$this->assertDirectoryExists($this->directory.'/cache');
|
121 |
-
|
122 |
-
$this->cache->write($key, $content);
|
123 |
-
}
|
124 |
-
|
125 |
-
public function testWriteFailWriteFile()
|
126 |
-
{
|
127 |
-
$this->expectException('\RuntimeException');
|
128 |
-
$this->expectExceptionMessage('Failed to write cache file');
|
129 |
-
|
130 |
-
$key = $this->directory.'/cache/cachefile.php';
|
131 |
-
$content = $this->generateSource();
|
132 |
-
|
133 |
-
$this->assertFileNotExists($key);
|
134 |
-
|
135 |
-
// Create a directory in the place of the cache file.
|
136 |
-
@mkdir($key, 0777, true);
|
137 |
-
$this->assertDirectoryExists($key);
|
138 |
-
|
139 |
-
$this->cache->write($key, $content);
|
140 |
-
}
|
141 |
-
|
142 |
-
public function testGetTimestamp()
|
143 |
-
{
|
144 |
-
$key = $this->directory.'/cache/cachefile.php';
|
145 |
-
|
146 |
-
$dir = \dirname($key);
|
147 |
-
@mkdir($dir, 0777, true);
|
148 |
-
$this->assertDirectoryExists($dir);
|
149 |
-
|
150 |
-
// Create the file with a specific modification time.
|
151 |
-
touch($key, 1234567890);
|
152 |
-
|
153 |
-
$this->assertSame(1234567890, $this->cache->getTimestamp($key));
|
154 |
-
}
|
155 |
-
|
156 |
-
public function testGetTimestampMissingFile()
|
157 |
-
{
|
158 |
-
$key = $this->directory.'/cache/cachefile.php';
|
159 |
-
$this->assertSame(0, $this->cache->getTimestamp($key));
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* Test file cache is tolerant towards trailing (back)slashes on the configured cache directory.
|
164 |
-
*
|
165 |
-
* @dataProvider provideDirectories
|
166 |
-
*/
|
167 |
-
public function testGenerateKey($expected, $input)
|
168 |
-
{
|
169 |
-
$cache = new FilesystemCache($input);
|
170 |
-
$this->assertRegExp($expected, $cache->generateKey('_test_', \get_class($this)));
|
171 |
-
}
|
172 |
-
|
173 |
-
public function provideDirectories()
|
174 |
-
{
|
175 |
-
$pattern = '#a/b/[a-zA-Z0-9]+/[a-zA-Z0-9]+.php$#';
|
176 |
-
|
177 |
-
return [
|
178 |
-
[$pattern, 'a/b'],
|
179 |
-
[$pattern, 'a/b/'],
|
180 |
-
[$pattern, 'a/b\\'],
|
181 |
-
[$pattern, 'a/b\\/'],
|
182 |
-
[$pattern, 'a/b\\//'],
|
183 |
-
['#/'.substr($pattern, 1), '/a/b'],
|
184 |
-
];
|
185 |
-
}
|
186 |
-
|
187 |
-
private function generateSource()
|
188 |
-
{
|
189 |
-
return strtr('<?php class {{classname}} {}', [
|
190 |
-
'{{classname}}' => $this->classname,
|
191 |
-
]);
|
192 |
-
}
|
193 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/CompilerTest.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Compiler;
|
15 |
-
use Twig\Environment;
|
16 |
-
|
17 |
-
class CompilerTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
public function testReprNumericValueWithLocale()
|
20 |
-
{
|
21 |
-
$compiler = new Compiler(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
22 |
-
|
23 |
-
$locale = setlocale(LC_NUMERIC, 0);
|
24 |
-
if (false === $locale) {
|
25 |
-
$this->markTestSkipped('Your platform does not support locales.');
|
26 |
-
}
|
27 |
-
|
28 |
-
$required_locales = ['fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'];
|
29 |
-
if (false === setlocale(LC_NUMERIC, $required_locales)) {
|
30 |
-
$this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales));
|
31 |
-
}
|
32 |
-
|
33 |
-
$this->assertEquals('1.2', $compiler->repr(1.2)->getSource());
|
34 |
-
$this->assertStringContainsString('fr', strtolower(setlocale(LC_NUMERIC, 0)));
|
35 |
-
|
36 |
-
setlocale(LC_NUMERIC, $locale);
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/ContainerRuntimeLoaderTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\RuntimeLoader\ContainerRuntimeLoader;
|
15 |
-
|
16 |
-
class ContainerRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @requires PHP 5.3
|
20 |
-
*/
|
21 |
-
public function testLoad()
|
22 |
-
{
|
23 |
-
$container = $this->createMock('Psr\Container\ContainerInterface');
|
24 |
-
$container->expects($this->once())->method('has')->with('stdClass')->willReturn(true);
|
25 |
-
$container->expects($this->once())->method('get')->with('stdClass')->willReturn(new \stdClass());
|
26 |
-
|
27 |
-
$loader = new ContainerRuntimeLoader($container);
|
28 |
-
|
29 |
-
$this->assertInstanceOf('stdClass', $loader->load('stdClass'));
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @requires PHP 5.3
|
34 |
-
*/
|
35 |
-
public function testLoadUnknownRuntimeReturnsNull()
|
36 |
-
{
|
37 |
-
$container = $this->createMock('Psr\Container\ContainerInterface');
|
38 |
-
$container->expects($this->once())->method('has')->with('Foo');
|
39 |
-
$container->expects($this->never())->method('get');
|
40 |
-
|
41 |
-
$loader = new ContainerRuntimeLoader($container);
|
42 |
-
$this->assertNull($loader->load('Foo'));
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/CustomExtensionTest.php
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Extension\ExtensionInterface;
|
16 |
-
|
17 |
-
class CustomExtensionTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
/**
|
20 |
-
* @requires PHP 5.3
|
21 |
-
* @dataProvider provideInvalidExtensions
|
22 |
-
*/
|
23 |
-
public function testGetInvalidOperators(ExtensionInterface $extension, $expectedExceptionMessage)
|
24 |
-
{
|
25 |
-
$this->expectException('InvalidArgumentException');
|
26 |
-
$this->expectExceptionMessage($expectedExceptionMessage);
|
27 |
-
|
28 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
29 |
-
$env->addExtension($extension);
|
30 |
-
$env->getUnaryOperators();
|
31 |
-
}
|
32 |
-
|
33 |
-
public function provideInvalidExtensions()
|
34 |
-
{
|
35 |
-
return [
|
36 |
-
[new InvalidOperatorExtension(new \stdClass()), '"Twig\Tests\InvalidOperatorExtension::getOperators()" must return an array with operators, got "stdClass".'],
|
37 |
-
[new InvalidOperatorExtension([1, 2, 3]), '"Twig\Tests\InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
class InvalidOperatorExtension implements ExtensionInterface
|
43 |
-
{
|
44 |
-
private $operators;
|
45 |
-
|
46 |
-
public function __construct($operators)
|
47 |
-
{
|
48 |
-
$this->operators = $operators;
|
49 |
-
}
|
50 |
-
|
51 |
-
public function initRuntime(Environment $environment)
|
52 |
-
{
|
53 |
-
}
|
54 |
-
|
55 |
-
public function getTokenParsers()
|
56 |
-
{
|
57 |
-
return [];
|
58 |
-
}
|
59 |
-
|
60 |
-
public function getNodeVisitors()
|
61 |
-
{
|
62 |
-
return [];
|
63 |
-
}
|
64 |
-
|
65 |
-
public function getFilters()
|
66 |
-
{
|
67 |
-
return [];
|
68 |
-
}
|
69 |
-
|
70 |
-
public function getTests()
|
71 |
-
{
|
72 |
-
return [];
|
73 |
-
}
|
74 |
-
|
75 |
-
public function getFunctions()
|
76 |
-
{
|
77 |
-
return [];
|
78 |
-
}
|
79 |
-
|
80 |
-
public function getGlobals()
|
81 |
-
{
|
82 |
-
return [];
|
83 |
-
}
|
84 |
-
|
85 |
-
public function getOperators()
|
86 |
-
{
|
87 |
-
return $this->operators;
|
88 |
-
}
|
89 |
-
|
90 |
-
public function getName()
|
91 |
-
{
|
92 |
-
return __CLASS__;
|
93 |
-
}
|
94 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/EnvironmentTest.php
DELETED
@@ -1,678 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Cache\FilesystemCache;
|
15 |
-
use Twig\Environment;
|
16 |
-
use Twig\Extension\AbstractExtension;
|
17 |
-
use Twig\Extension\GlobalsInterface;
|
18 |
-
use Twig\Extension\InitRuntimeInterface;
|
19 |
-
use Twig\Loader\ArrayLoader;
|
20 |
-
use Twig\Loader\LoaderInterface;
|
21 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
22 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
23 |
-
use Twig\Source;
|
24 |
-
use Twig\Token;
|
25 |
-
use Twig\TokenParser\AbstractTokenParser;
|
26 |
-
use Twig\TwigFilter;
|
27 |
-
use Twig\TwigFunction;
|
28 |
-
use Twig\TwigTest;
|
29 |
-
|
30 |
-
class EnvironmentTest extends \PHPUnit\Framework\TestCase
|
31 |
-
{
|
32 |
-
private $deprecations = [];
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @group legacy
|
36 |
-
*/
|
37 |
-
public function testLegacyTokenizeSignature()
|
38 |
-
{
|
39 |
-
$env = new Environment();
|
40 |
-
$stream = $env->tokenize('{{ foo }}', 'foo');
|
41 |
-
$this->assertEquals('{{ foo }}', $stream->getSource());
|
42 |
-
$this->assertEquals('foo', $stream->getFilename());
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @group legacy
|
47 |
-
*/
|
48 |
-
public function testLegacyCompileSourceSignature()
|
49 |
-
{
|
50 |
-
$loader = new ArrayLoader(['foo' => '{{ foo }}']);
|
51 |
-
$env = new Environment($loader);
|
52 |
-
$this->assertStringContainsString('getTemplateName', $env->compileSource('{{ foo }}', 'foo'));
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @group legacy
|
57 |
-
*/
|
58 |
-
public function testRenderNoLoader()
|
59 |
-
{
|
60 |
-
$this->expectException('\LogicException');
|
61 |
-
$this->expectExceptionMessage('You must set a loader first.');
|
62 |
-
|
63 |
-
$env = new Environment();
|
64 |
-
$env->render('test');
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testAutoescapeOption()
|
68 |
-
{
|
69 |
-
$loader = new ArrayLoader([
|
70 |
-
'html' => '{{ foo }} {{ foo }}',
|
71 |
-
'js' => '{{ bar }} {{ bar }}',
|
72 |
-
]);
|
73 |
-
|
74 |
-
$twig = new Environment($loader, [
|
75 |
-
'debug' => true,
|
76 |
-
'cache' => false,
|
77 |
-
'autoescape' => [$this, 'escapingStrategyCallback'],
|
78 |
-
]);
|
79 |
-
|
80 |
-
$this->assertEquals('foo<br/ > foo<br/ >', $twig->render('html', ['foo' => 'foo<br/ >']));
|
81 |
-
$this->assertEquals('foo\u003Cbr\/\u0020\u003E foo\u003Cbr\/\u0020\u003E', $twig->render('js', ['bar' => 'foo<br/ >']));
|
82 |
-
}
|
83 |
-
|
84 |
-
public function escapingStrategyCallback($name)
|
85 |
-
{
|
86 |
-
return $name;
|
87 |
-
}
|
88 |
-
|
89 |
-
public function testGlobals()
|
90 |
-
{
|
91 |
-
// to be removed in 2.0
|
92 |
-
$loader = $this->createMock('\Twig\Tests\EnvironmentTestLoaderInterface');
|
93 |
-
//$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
|
94 |
-
$loader->expects($this->any())->method('getSourceContext')->willReturn(new Source('', ''));
|
95 |
-
|
96 |
-
// globals can be added after calling getGlobals
|
97 |
-
|
98 |
-
$twig = new Environment($loader);
|
99 |
-
$twig->addGlobal('foo', 'foo');
|
100 |
-
$twig->getGlobals();
|
101 |
-
$twig->addGlobal('foo', 'bar');
|
102 |
-
$globals = $twig->getGlobals();
|
103 |
-
$this->assertEquals('bar', $globals['foo']);
|
104 |
-
|
105 |
-
// globals can be modified after a template has been loaded
|
106 |
-
$twig = new Environment($loader);
|
107 |
-
$twig->addGlobal('foo', 'foo');
|
108 |
-
$twig->getGlobals();
|
109 |
-
$twig->load('index');
|
110 |
-
$twig->addGlobal('foo', 'bar');
|
111 |
-
$globals = $twig->getGlobals();
|
112 |
-
$this->assertEquals('bar', $globals['foo']);
|
113 |
-
|
114 |
-
// globals can be modified after extensions init
|
115 |
-
$twig = new Environment($loader);
|
116 |
-
$twig->addGlobal('foo', 'foo');
|
117 |
-
$twig->getGlobals();
|
118 |
-
$twig->getFunctions();
|
119 |
-
$twig->addGlobal('foo', 'bar');
|
120 |
-
$globals = $twig->getGlobals();
|
121 |
-
$this->assertEquals('bar', $globals['foo']);
|
122 |
-
|
123 |
-
// globals can be modified after extensions and a template has been loaded
|
124 |
-
$arrayLoader = new ArrayLoader(['index' => '{{foo}}']);
|
125 |
-
$twig = new Environment($arrayLoader);
|
126 |
-
$twig->addGlobal('foo', 'foo');
|
127 |
-
$twig->getGlobals();
|
128 |
-
$twig->getFunctions();
|
129 |
-
$twig->load('index');
|
130 |
-
$twig->addGlobal('foo', 'bar');
|
131 |
-
$globals = $twig->getGlobals();
|
132 |
-
$this->assertEquals('bar', $globals['foo']);
|
133 |
-
|
134 |
-
$twig = new Environment($arrayLoader);
|
135 |
-
$twig->getGlobals();
|
136 |
-
$twig->addGlobal('foo', 'bar');
|
137 |
-
$template = $twig->load('index');
|
138 |
-
$this->assertEquals('bar', $template->render([]));
|
139 |
-
|
140 |
-
/* to be uncomment in Twig 2.0
|
141 |
-
// globals cannot be added after a template has been loaded
|
142 |
-
$twig = new Environment($loader);
|
143 |
-
$twig->addGlobal('foo', 'foo');
|
144 |
-
$twig->getGlobals();
|
145 |
-
$twig->load('index');
|
146 |
-
try {
|
147 |
-
$twig->addGlobal('bar', 'bar');
|
148 |
-
$this->fail();
|
149 |
-
} catch (\LogicException $e) {
|
150 |
-
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
151 |
-
}
|
152 |
-
|
153 |
-
// globals cannot be added after extensions init
|
154 |
-
$twig = new Environment($loader);
|
155 |
-
$twig->addGlobal('foo', 'foo');
|
156 |
-
$twig->getGlobals();
|
157 |
-
$twig->getFunctions();
|
158 |
-
try {
|
159 |
-
$twig->addGlobal('bar', 'bar');
|
160 |
-
$this->fail();
|
161 |
-
} catch (\LogicException $e) {
|
162 |
-
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
163 |
-
}
|
164 |
-
|
165 |
-
// globals cannot be added after extensions and a template has been loaded
|
166 |
-
$twig = new Environment($loader);
|
167 |
-
$twig->addGlobal('foo', 'foo');
|
168 |
-
$twig->getGlobals();
|
169 |
-
$twig->getFunctions();
|
170 |
-
$twig->load('index');
|
171 |
-
try {
|
172 |
-
$twig->addGlobal('bar', 'bar');
|
173 |
-
$this->fail();
|
174 |
-
} catch (\LogicException $e) {
|
175 |
-
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
176 |
-
}
|
177 |
-
|
178 |
-
// test adding globals after a template has been loaded without call to getGlobals
|
179 |
-
$twig = new Environment($loader);
|
180 |
-
$twig->load('index');
|
181 |
-
try {
|
182 |
-
$twig->addGlobal('bar', 'bar');
|
183 |
-
$this->fail();
|
184 |
-
} catch (\LogicException $e) {
|
185 |
-
$this->assertFalse(array_key_exists('bar', $twig->getGlobals()));
|
186 |
-
}
|
187 |
-
*/
|
188 |
-
}
|
189 |
-
|
190 |
-
public function testExtensionsAreNotInitializedWhenRenderingACompiledTemplate()
|
191 |
-
{
|
192 |
-
$cache = new FilesystemCache($dir = sys_get_temp_dir().'/twig');
|
193 |
-
$options = ['cache' => $cache, 'auto_reload' => false, 'debug' => false];
|
194 |
-
|
195 |
-
// force compilation
|
196 |
-
$twig = new Environment($loader = new ArrayLoader(['index' => '{{ foo }}']), $options);
|
197 |
-
|
198 |
-
$key = $cache->generateKey('index', $twig->getTemplateClass('index'));
|
199 |
-
$cache->write($key, $twig->compileSource(new Source('{{ foo }}', 'index')));
|
200 |
-
|
201 |
-
// check that extensions won't be initialized when rendering a template that is already in the cache
|
202 |
-
$twig = $this
|
203 |
-
->getMockBuilder('\Twig\Environment')
|
204 |
-
->setConstructorArgs([$loader, $options])
|
205 |
-
->setMethods(['initExtensions'])
|
206 |
-
->getMock()
|
207 |
-
;
|
208 |
-
|
209 |
-
$twig->expects($this->never())->method('initExtensions');
|
210 |
-
|
211 |
-
// render template
|
212 |
-
$output = $twig->render('index', ['foo' => 'bar']);
|
213 |
-
$this->assertEquals('bar', $output);
|
214 |
-
|
215 |
-
FilesystemHelper::removeDir($dir);
|
216 |
-
}
|
217 |
-
|
218 |
-
public function testAutoReloadCacheMiss()
|
219 |
-
{
|
220 |
-
$templateName = __FUNCTION__;
|
221 |
-
$templateContent = __FUNCTION__;
|
222 |
-
|
223 |
-
$cache = $this->createMock('\Twig\Cache\CacheInterface');
|
224 |
-
$loader = $this->getMockLoader($templateName, $templateContent);
|
225 |
-
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
|
226 |
-
|
227 |
-
// Cache miss: getTimestamp returns 0 and as a result the load() is
|
228 |
-
// skipped.
|
229 |
-
$cache->expects($this->once())
|
230 |
-
->method('generateKey')
|
231 |
-
->willReturn('key');
|
232 |
-
$cache->expects($this->once())
|
233 |
-
->method('getTimestamp')
|
234 |
-
->willReturn(0);
|
235 |
-
$loader->expects($this->never())
|
236 |
-
->method('isFresh');
|
237 |
-
$cache->expects($this->once())
|
238 |
-
->method('write');
|
239 |
-
$cache->expects($this->once())
|
240 |
-
->method('load');
|
241 |
-
|
242 |
-
$twig->load($templateName);
|
243 |
-
}
|
244 |
-
|
245 |
-
public function testAutoReloadCacheHit()
|
246 |
-
{
|
247 |
-
$templateName = __FUNCTION__;
|
248 |
-
$templateContent = __FUNCTION__;
|
249 |
-
|
250 |
-
$cache = $this->createMock('\Twig\Cache\CacheInterface');
|
251 |
-
$loader = $this->getMockLoader($templateName, $templateContent);
|
252 |
-
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
|
253 |
-
|
254 |
-
$now = time();
|
255 |
-
|
256 |
-
// Cache hit: getTimestamp returns something > extension timestamps and
|
257 |
-
// the loader returns true for isFresh().
|
258 |
-
$cache->expects($this->once())
|
259 |
-
->method('generateKey')
|
260 |
-
->willReturn('key');
|
261 |
-
$cache->expects($this->once())
|
262 |
-
->method('getTimestamp')
|
263 |
-
->willReturn($now);
|
264 |
-
$loader->expects($this->once())
|
265 |
-
->method('isFresh')
|
266 |
-
->willReturn(true);
|
267 |
-
$cache->expects($this->atLeastOnce())
|
268 |
-
->method('load');
|
269 |
-
|
270 |
-
$twig->load($templateName);
|
271 |
-
}
|
272 |
-
|
273 |
-
public function testAutoReloadOutdatedCacheHit()
|
274 |
-
{
|
275 |
-
$templateName = __FUNCTION__;
|
276 |
-
$templateContent = __FUNCTION__;
|
277 |
-
|
278 |
-
$cache = $this->createMock('\Twig\Cache\CacheInterface');
|
279 |
-
$loader = $this->getMockLoader($templateName, $templateContent);
|
280 |
-
$twig = new Environment($loader, ['cache' => $cache, 'auto_reload' => true, 'debug' => false]);
|
281 |
-
|
282 |
-
$now = time();
|
283 |
-
|
284 |
-
$cache->expects($this->once())
|
285 |
-
->method('generateKey')
|
286 |
-
->willReturn('key');
|
287 |
-
$cache->expects($this->once())
|
288 |
-
->method('getTimestamp')
|
289 |
-
->willReturn($now);
|
290 |
-
$loader->expects($this->once())
|
291 |
-
->method('isFresh')
|
292 |
-
->willReturn(false);
|
293 |
-
$cache->expects($this->once())
|
294 |
-
->method('write');
|
295 |
-
$cache->expects($this->once())
|
296 |
-
->method('load');
|
297 |
-
|
298 |
-
$twig->load($templateName);
|
299 |
-
}
|
300 |
-
|
301 |
-
/**
|
302 |
-
* @group legacy
|
303 |
-
*/
|
304 |
-
public function testHasGetExtensionWithDynamicName()
|
305 |
-
{
|
306 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
307 |
-
|
308 |
-
$ext1 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext1');
|
309 |
-
$ext2 = new EnvironmentTest_Extension_DynamicWithDeprecatedName('ext2');
|
310 |
-
$twig->addExtension($ext1);
|
311 |
-
$twig->addExtension($ext2);
|
312 |
-
|
313 |
-
$this->assertTrue($twig->hasExtension('ext1'));
|
314 |
-
$this->assertTrue($twig->hasExtension('ext2'));
|
315 |
-
|
316 |
-
$this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest_Extension_DynamicWithDeprecatedName'));
|
317 |
-
|
318 |
-
$this->assertSame($ext1, $twig->getExtension('ext1'));
|
319 |
-
$this->assertSame($ext2, $twig->getExtension('ext2'));
|
320 |
-
}
|
321 |
-
|
322 |
-
public function testHasGetExtensionByClassName()
|
323 |
-
{
|
324 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
325 |
-
$twig->addExtension($ext = new EnvironmentTest_Extension());
|
326 |
-
$this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest_Extension'));
|
327 |
-
$this->assertTrue($twig->hasExtension('\Twig\Tests\EnvironmentTest_Extension'));
|
328 |
-
|
329 |
-
$this->assertSame($ext, $twig->getExtension('Twig\Tests\EnvironmentTest_Extension'));
|
330 |
-
$this->assertSame($ext, $twig->getExtension('\Twig\Tests\EnvironmentTest_Extension'));
|
331 |
-
|
332 |
-
$this->assertTrue($twig->hasExtension('Twig\Tests\EnvironmentTest\Extension'));
|
333 |
-
$this->assertSame($ext, $twig->getExtension('Twig\Tests\EnvironmentTest\Extension'));
|
334 |
-
}
|
335 |
-
|
336 |
-
public function testAddExtension()
|
337 |
-
{
|
338 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
339 |
-
$twig->addExtension(new EnvironmentTest_Extension());
|
340 |
-
|
341 |
-
$this->assertArrayHasKey('test', $twig->getTags());
|
342 |
-
$this->assertArrayHasKey('foo_filter', $twig->getFilters());
|
343 |
-
$this->assertArrayHasKey('foo_function', $twig->getFunctions());
|
344 |
-
$this->assertArrayHasKey('foo_test', $twig->getTests());
|
345 |
-
$this->assertArrayHasKey('foo_unary', $twig->getUnaryOperators());
|
346 |
-
$this->assertArrayHasKey('foo_binary', $twig->getBinaryOperators());
|
347 |
-
$this->assertArrayHasKey('foo_global', $twig->getGlobals());
|
348 |
-
$visitors = $twig->getNodeVisitors();
|
349 |
-
$found = false;
|
350 |
-
foreach ($visitors as $visitor) {
|
351 |
-
if ($visitor instanceof EnvironmentTest_NodeVisitor) {
|
352 |
-
$found = true;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
$this->assertTrue($found);
|
356 |
-
}
|
357 |
-
|
358 |
-
/**
|
359 |
-
* @requires PHP 5.3
|
360 |
-
*/
|
361 |
-
public function testAddExtensionWithDeprecatedGetGlobals()
|
362 |
-
{
|
363 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
364 |
-
$twig->addExtension(new EnvironmentTest_Extension_WithGlobals());
|
365 |
-
|
366 |
-
$this->deprecations = [];
|
367 |
-
set_error_handler([$this, 'handleError']);
|
368 |
-
|
369 |
-
$this->assertArrayHasKey('foo_global', $twig->getGlobals());
|
370 |
-
|
371 |
-
$this->assertCount(1, $this->deprecations);
|
372 |
-
$this->assertStringContainsString('Defining the getGlobals() method in the "Twig\Tests\EnvironmentTest_Extension_WithGlobals" extension ', $this->deprecations[0]);
|
373 |
-
|
374 |
-
restore_error_handler();
|
375 |
-
}
|
376 |
-
|
377 |
-
/**
|
378 |
-
* @group legacy
|
379 |
-
*/
|
380 |
-
public function testRemoveExtension()
|
381 |
-
{
|
382 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
383 |
-
$twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName());
|
384 |
-
$twig->removeExtension('environment_test');
|
385 |
-
|
386 |
-
$this->assertArrayNotHasKey('test', $twig->getTags());
|
387 |
-
$this->assertArrayNotHasKey('foo_filter', $twig->getFilters());
|
388 |
-
$this->assertArrayNotHasKey('foo_function', $twig->getFunctions());
|
389 |
-
$this->assertArrayNotHasKey('foo_test', $twig->getTests());
|
390 |
-
$this->assertArrayNotHasKey('foo_unary', $twig->getUnaryOperators());
|
391 |
-
$this->assertArrayNotHasKey('foo_binary', $twig->getBinaryOperators());
|
392 |
-
$this->assertArrayNotHasKey('foo_global', $twig->getGlobals());
|
393 |
-
$this->assertCount(2, $twig->getNodeVisitors());
|
394 |
-
}
|
395 |
-
|
396 |
-
public function testAddMockExtension()
|
397 |
-
{
|
398 |
-
// should be replaced by the following in 2.0 (this current code is just to avoid a dep notice)
|
399 |
-
// $extension = $this->createMock('\Twig\Extension\AbstractExtension');
|
400 |
-
$extension = eval(<<<EOF
|
401 |
-
use Twig\Extension\AbstractExtension;
|
402 |
-
|
403 |
-
class EnvironmentTest_ExtensionInEval extends AbstractExtension
|
404 |
-
{
|
405 |
-
}
|
406 |
-
EOF
|
407 |
-
);
|
408 |
-
$extension = new \EnvironmentTest_ExtensionInEval();
|
409 |
-
|
410 |
-
$loader = new ArrayLoader(['page' => 'hey']);
|
411 |
-
|
412 |
-
$twig = new Environment($loader);
|
413 |
-
$twig->addExtension($extension);
|
414 |
-
|
415 |
-
$this->assertInstanceOf('\Twig\Extension\ExtensionInterface', $twig->getExtension(\get_class($extension)));
|
416 |
-
$this->assertTrue($twig->isTemplateFresh('page', time()));
|
417 |
-
}
|
418 |
-
|
419 |
-
public function testInitRuntimeWithAnExtensionUsingInitRuntimeNoDeprecation()
|
420 |
-
{
|
421 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
422 |
-
$twig->addExtension(new EnvironmentTest_ExtensionWithoutDeprecationInitRuntime());
|
423 |
-
$twig->initRuntime();
|
424 |
-
|
425 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
426 |
-
// can be executed without throwing any deprecations
|
427 |
-
$this->addToAssertionCount(1);
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* @requires PHP 5.3
|
432 |
-
*/
|
433 |
-
public function testInitRuntimeWithAnExtensionUsingInitRuntimeDeprecation()
|
434 |
-
{
|
435 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
436 |
-
$twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
|
437 |
-
|
438 |
-
$this->deprecations = [];
|
439 |
-
set_error_handler([$this, 'handleError']);
|
440 |
-
|
441 |
-
$twig->initRuntime();
|
442 |
-
|
443 |
-
$this->assertCount(1, $this->deprecations);
|
444 |
-
$this->assertStringContainsString('Defining the initRuntime() method in the "Twig\Tests\EnvironmentTest_ExtensionWithDeprecationInitRuntime" extension is deprecated since version 1.23.', $this->deprecations[0]);
|
445 |
-
|
446 |
-
restore_error_handler();
|
447 |
-
}
|
448 |
-
|
449 |
-
public function handleError($type, $msg)
|
450 |
-
{
|
451 |
-
if (E_USER_DEPRECATED === $type) {
|
452 |
-
$this->deprecations[] = $msg;
|
453 |
-
}
|
454 |
-
}
|
455 |
-
|
456 |
-
/**
|
457 |
-
* @requires PHP 5.3
|
458 |
-
*/
|
459 |
-
public function testOverrideExtension()
|
460 |
-
{
|
461 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
462 |
-
$twig->addExtension(new EnvironmentTest_ExtensionWithDeprecationInitRuntime());
|
463 |
-
|
464 |
-
$this->deprecations = [];
|
465 |
-
set_error_handler([$this, 'handleError']);
|
466 |
-
|
467 |
-
$twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName());
|
468 |
-
$twig->addExtension(new EnvironmentTest_Extension_WithDeprecatedName());
|
469 |
-
|
470 |
-
$this->assertCount(1, $this->deprecations);
|
471 |
-
$this->assertStringContainsString('The possibility to register the same extension twice', $this->deprecations[0]);
|
472 |
-
|
473 |
-
restore_error_handler();
|
474 |
-
}
|
475 |
-
|
476 |
-
public function testAddRuntimeLoader()
|
477 |
-
{
|
478 |
-
$runtimeLoader = $this->createMock('\Twig\RuntimeLoader\RuntimeLoaderInterface');
|
479 |
-
$runtimeLoader->expects($this->any())->method('load')->willReturn(new EnvironmentTest_Runtime());
|
480 |
-
|
481 |
-
$loader = new ArrayLoader([
|
482 |
-
'func_array' => '{{ from_runtime_array("foo") }}',
|
483 |
-
'func_array_default' => '{{ from_runtime_array() }}',
|
484 |
-
'func_array_named_args' => '{{ from_runtime_array(name="foo") }}',
|
485 |
-
'func_string' => '{{ from_runtime_string("foo") }}',
|
486 |
-
'func_string_default' => '{{ from_runtime_string() }}',
|
487 |
-
'func_string_named_args' => '{{ from_runtime_string(name="foo") }}',
|
488 |
-
]);
|
489 |
-
|
490 |
-
$twig = new Environment($loader);
|
491 |
-
$twig->addExtension(new EnvironmentTest_ExtensionWithoutRuntime());
|
492 |
-
$twig->addRuntimeLoader($runtimeLoader);
|
493 |
-
|
494 |
-
$this->assertEquals('foo', $twig->render('func_array'));
|
495 |
-
$this->assertEquals('bar', $twig->render('func_array_default'));
|
496 |
-
$this->assertEquals('foo', $twig->render('func_array_named_args'));
|
497 |
-
$this->assertEquals('foo', $twig->render('func_string'));
|
498 |
-
$this->assertEquals('bar', $twig->render('func_string_default'));
|
499 |
-
$this->assertEquals('foo', $twig->render('func_string_named_args'));
|
500 |
-
}
|
501 |
-
|
502 |
-
protected function getMockLoader($templateName, $templateContent)
|
503 |
-
{
|
504 |
-
// to be removed in 2.0
|
505 |
-
$loader = $this->createMock('Twig\Tests\EnvironmentTestLoaderInterface');
|
506 |
-
//$loader = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
|
507 |
-
$loader->expects($this->any())
|
508 |
-
->method('getSourceContext')
|
509 |
-
->with($templateName)
|
510 |
-
->willReturn(new Source($templateContent, $templateName));
|
511 |
-
$loader->expects($this->any())
|
512 |
-
->method('getCacheKey')
|
513 |
-
->with($templateName)
|
514 |
-
->willReturn($templateName);
|
515 |
-
|
516 |
-
return $loader;
|
517 |
-
}
|
518 |
-
}
|
519 |
-
|
520 |
-
class EnvironmentTest_Extension_WithGlobals extends AbstractExtension
|
521 |
-
{
|
522 |
-
public function getGlobals()
|
523 |
-
{
|
524 |
-
return [
|
525 |
-
'foo_global' => 'foo_global',
|
526 |
-
];
|
527 |
-
}
|
528 |
-
}
|
529 |
-
|
530 |
-
class EnvironmentTest_Extension extends AbstractExtension implements GlobalsInterface
|
531 |
-
{
|
532 |
-
public function getTokenParsers()
|
533 |
-
{
|
534 |
-
return [
|
535 |
-
new EnvironmentTest_TokenParser(),
|
536 |
-
];
|
537 |
-
}
|
538 |
-
|
539 |
-
public function getNodeVisitors()
|
540 |
-
{
|
541 |
-
return [
|
542 |
-
new EnvironmentTest_NodeVisitor(),
|
543 |
-
];
|
544 |
-
}
|
545 |
-
|
546 |
-
public function getFilters()
|
547 |
-
{
|
548 |
-
return [
|
549 |
-
new TwigFilter('foo_filter', 'foo_filter'),
|
550 |
-
];
|
551 |
-
}
|
552 |
-
|
553 |
-
public function getTests()
|
554 |
-
{
|
555 |
-
return [
|
556 |
-
new TwigTest('foo_test', 'foo_test'),
|
557 |
-
];
|
558 |
-
}
|
559 |
-
|
560 |
-
public function getFunctions()
|
561 |
-
{
|
562 |
-
return [
|
563 |
-
new TwigFunction('foo_function', 'foo_function'),
|
564 |
-
];
|
565 |
-
}
|
566 |
-
|
567 |
-
public function getOperators()
|
568 |
-
{
|
569 |
-
return [
|
570 |
-
['foo_unary' => []],
|
571 |
-
['foo_binary' => []],
|
572 |
-
];
|
573 |
-
}
|
574 |
-
|
575 |
-
public function getGlobals()
|
576 |
-
{
|
577 |
-
return [
|
578 |
-
'foo_global' => 'foo_global',
|
579 |
-
];
|
580 |
-
}
|
581 |
-
}
|
582 |
-
class_alias('\Twig\Tests\EnvironmentTest_Extension', 'Twig\Tests\EnvironmentTest\Extension', false);
|
583 |
-
|
584 |
-
class EnvironmentTest_Extension_WithDeprecatedName extends AbstractExtension
|
585 |
-
{
|
586 |
-
public function getName()
|
587 |
-
{
|
588 |
-
return 'environment_test';
|
589 |
-
}
|
590 |
-
}
|
591 |
-
|
592 |
-
class EnvironmentTest_Extension_DynamicWithDeprecatedName extends AbstractExtension
|
593 |
-
{
|
594 |
-
private $name;
|
595 |
-
|
596 |
-
public function __construct($name)
|
597 |
-
{
|
598 |
-
$this->name = $name;
|
599 |
-
}
|
600 |
-
|
601 |
-
public function getName()
|
602 |
-
{
|
603 |
-
return $this->name;
|
604 |
-
}
|
605 |
-
}
|
606 |
-
|
607 |
-
class EnvironmentTest_TokenParser extends AbstractTokenParser
|
608 |
-
{
|
609 |
-
public function parse(Token $token)
|
610 |
-
{
|
611 |
-
}
|
612 |
-
|
613 |
-
public function getTag()
|
614 |
-
{
|
615 |
-
return 'test';
|
616 |
-
}
|
617 |
-
}
|
618 |
-
|
619 |
-
class EnvironmentTest_NodeVisitor implements NodeVisitorInterface
|
620 |
-
{
|
621 |
-
public function enterNode(\Twig_NodeInterface $node, Environment $env)
|
622 |
-
{
|
623 |
-
return $node;
|
624 |
-
}
|
625 |
-
|
626 |
-
public function leaveNode(\Twig_NodeInterface $node, Environment $env)
|
627 |
-
{
|
628 |
-
return $node;
|
629 |
-
}
|
630 |
-
|
631 |
-
public function getPriority()
|
632 |
-
{
|
633 |
-
return 0;
|
634 |
-
}
|
635 |
-
}
|
636 |
-
|
637 |
-
class EnvironmentTest_ExtensionWithDeprecationInitRuntime extends AbstractExtension
|
638 |
-
{
|
639 |
-
public function initRuntime(Environment $env)
|
640 |
-
{
|
641 |
-
}
|
642 |
-
}
|
643 |
-
|
644 |
-
class EnvironmentTest_ExtensionWithoutDeprecationInitRuntime extends AbstractExtension implements InitRuntimeInterface
|
645 |
-
{
|
646 |
-
public function initRuntime(Environment $env)
|
647 |
-
{
|
648 |
-
}
|
649 |
-
}
|
650 |
-
|
651 |
-
class EnvironmentTest_ExtensionWithoutRuntime extends AbstractExtension
|
652 |
-
{
|
653 |
-
public function getFunctions()
|
654 |
-
{
|
655 |
-
return [
|
656 |
-
new TwigFunction('from_runtime_array', ['Twig\Tests\EnvironmentTest_Runtime', 'fromRuntime']),
|
657 |
-
new TwigFunction('from_runtime_string', 'Twig\Tests\EnvironmentTest_Runtime::fromRuntime'),
|
658 |
-
];
|
659 |
-
}
|
660 |
-
|
661 |
-
public function getName()
|
662 |
-
{
|
663 |
-
return 'from_runtime';
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
class EnvironmentTest_Runtime
|
668 |
-
{
|
669 |
-
public function fromRuntime($name = 'bar')
|
670 |
-
{
|
671 |
-
return $name;
|
672 |
-
}
|
673 |
-
}
|
674 |
-
|
675 |
-
// to be removed in 2.0
|
676 |
-
interface EnvironmentTestLoaderInterface extends LoaderInterface, SourceContextLoaderInterface
|
677 |
-
{
|
678 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/ErrorTest.php
DELETED
@@ -1,234 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Error\Error;
|
16 |
-
use Twig\Error\RuntimeError;
|
17 |
-
use Twig\Loader\ArrayLoader;
|
18 |
-
use Twig\Loader\FilesystemLoader;
|
19 |
-
use Twig\Source;
|
20 |
-
|
21 |
-
class ErrorTest extends \PHPUnit\Framework\TestCase
|
22 |
-
{
|
23 |
-
public function testErrorWithObjectFilename()
|
24 |
-
{
|
25 |
-
$error = new Error('foo');
|
26 |
-
$error->setSourceContext(new Source('', new \SplFileInfo(__FILE__)));
|
27 |
-
|
28 |
-
$this->assertStringContainsString('tests'.\DIRECTORY_SEPARATOR.'ErrorTest.php', $error->getMessage());
|
29 |
-
}
|
30 |
-
|
31 |
-
public function testErrorWithArrayFilename()
|
32 |
-
{
|
33 |
-
$error = new Error('foo');
|
34 |
-
$error->setSourceContext(new Source('', ['foo' => 'bar']));
|
35 |
-
|
36 |
-
$this->assertEquals('foo in {"foo":"bar"}', $error->getMessage());
|
37 |
-
}
|
38 |
-
|
39 |
-
public function testTwigExceptionGuessWithMissingVarAndArrayLoader()
|
40 |
-
{
|
41 |
-
$loader = new ArrayLoader([
|
42 |
-
'base.html' => '{% block content %}{% endblock %}',
|
43 |
-
'index.html' => <<<EOHTML
|
44 |
-
{% extends 'base.html' %}
|
45 |
-
{% block content %}
|
46 |
-
{{ foo.bar }}
|
47 |
-
{% endblock %}
|
48 |
-
{% block foo %}
|
49 |
-
{{ foo.bar }}
|
50 |
-
{% endblock %}
|
51 |
-
EOHTML
|
52 |
-
]);
|
53 |
-
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
|
54 |
-
|
55 |
-
$template = $twig->load('index.html');
|
56 |
-
try {
|
57 |
-
$template->render([]);
|
58 |
-
|
59 |
-
$this->fail();
|
60 |
-
} catch (RuntimeError $e) {
|
61 |
-
$this->assertEquals('Variable "foo" does not exist in "index.html" at line 3.', $e->getMessage());
|
62 |
-
$this->assertEquals(3, $e->getTemplateLine());
|
63 |
-
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testTwigExceptionGuessWithExceptionAndArrayLoader()
|
68 |
-
{
|
69 |
-
$loader = new ArrayLoader([
|
70 |
-
'base.html' => '{% block content %}{% endblock %}',
|
71 |
-
'index.html' => <<<EOHTML
|
72 |
-
{% extends 'base.html' %}
|
73 |
-
{% block content %}
|
74 |
-
{{ foo.bar }}
|
75 |
-
{% endblock %}
|
76 |
-
{% block foo %}
|
77 |
-
{{ foo.bar }}
|
78 |
-
{% endblock %}
|
79 |
-
EOHTML
|
80 |
-
]);
|
81 |
-
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
|
82 |
-
|
83 |
-
$template = $twig->load('index.html');
|
84 |
-
try {
|
85 |
-
$template->render(['foo' => new ErrorTest_Foo()]);
|
86 |
-
|
87 |
-
$this->fail();
|
88 |
-
} catch (RuntimeError $e) {
|
89 |
-
$this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...") in "index.html" at line 3.', $e->getMessage());
|
90 |
-
$this->assertEquals(3, $e->getTemplateLine());
|
91 |
-
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
public function testTwigExceptionGuessWithMissingVarAndFilesystemLoader()
|
96 |
-
{
|
97 |
-
$loader = new FilesystemLoader(__DIR__.'/Fixtures/errors');
|
98 |
-
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
|
99 |
-
|
100 |
-
$template = $twig->load('index.html');
|
101 |
-
try {
|
102 |
-
$template->render([]);
|
103 |
-
|
104 |
-
$this->fail();
|
105 |
-
} catch (RuntimeError $e) {
|
106 |
-
$this->assertEquals('Variable "foo" does not exist.', $e->getMessage());
|
107 |
-
$this->assertEquals(3, $e->getTemplateLine());
|
108 |
-
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
109 |
-
$this->assertEquals(3, $e->getLine());
|
110 |
-
$this->assertEquals(strtr(__DIR__.'/Fixtures/errors/index.html', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
public function testTwigExceptionGuessWithExceptionAndFilesystemLoader()
|
115 |
-
{
|
116 |
-
$loader = new FilesystemLoader(__DIR__.'/Fixtures/errors');
|
117 |
-
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
|
118 |
-
|
119 |
-
$template = $twig->load('index.html');
|
120 |
-
try {
|
121 |
-
$template->render(['foo' => new ErrorTest_Foo()]);
|
122 |
-
|
123 |
-
$this->fail();
|
124 |
-
} catch (RuntimeError $e) {
|
125 |
-
$this->assertEquals('An exception has been thrown during the rendering of a template ("Runtime error...").', $e->getMessage());
|
126 |
-
$this->assertEquals(3, $e->getTemplateLine());
|
127 |
-
$this->assertEquals('index.html', $e->getSourceContext()->getName());
|
128 |
-
$this->assertEquals(3, $e->getLine());
|
129 |
-
$this->assertEquals(strtr(__DIR__.'/Fixtures/errors/index.html', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @dataProvider getErroredTemplates
|
135 |
-
*/
|
136 |
-
public function testTwigExceptionAddsFileAndLine($templates, $name, $line)
|
137 |
-
{
|
138 |
-
$loader = new ArrayLoader($templates);
|
139 |
-
$twig = new Environment($loader, ['strict_variables' => true, 'debug' => true, 'cache' => false]);
|
140 |
-
|
141 |
-
$template = $twig->load('index');
|
142 |
-
|
143 |
-
try {
|
144 |
-
$template->render([]);
|
145 |
-
|
146 |
-
$this->fail();
|
147 |
-
} catch (RuntimeError $e) {
|
148 |
-
$this->assertEquals(sprintf('Variable "foo" does not exist in "%s" at line %d.', $name, $line), $e->getMessage());
|
149 |
-
$this->assertEquals($line, $e->getTemplateLine());
|
150 |
-
$this->assertEquals($name, $e->getSourceContext()->getName());
|
151 |
-
}
|
152 |
-
|
153 |
-
try {
|
154 |
-
$template->render(['foo' => new ErrorTest_Foo()]);
|
155 |
-
|
156 |
-
$this->fail();
|
157 |
-
} catch (RuntimeError $e) {
|
158 |
-
$this->assertEquals(sprintf('An exception has been thrown during the rendering of a template ("Runtime error...") in "%s" at line %d.', $name, $line), $e->getMessage());
|
159 |
-
$this->assertEquals($line, $e->getTemplateLine());
|
160 |
-
$this->assertEquals($name, $e->getSourceContext()->getName());
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
public function getErroredTemplates()
|
165 |
-
{
|
166 |
-
return [
|
167 |
-
// error occurs in a template
|
168 |
-
[
|
169 |
-
[
|
170 |
-
'index' => "\n\n{{ foo.bar }}\n\n\n{{ 'foo' }}",
|
171 |
-
],
|
172 |
-
'index', 3,
|
173 |
-
],
|
174 |
-
|
175 |
-
// error occurs in an included template
|
176 |
-
[
|
177 |
-
[
|
178 |
-
'index' => "{% include 'partial' %}",
|
179 |
-
'partial' => '{{ foo.bar }}',
|
180 |
-
],
|
181 |
-
'partial', 1,
|
182 |
-
],
|
183 |
-
|
184 |
-
// error occurs in a parent block when called via parent()
|
185 |
-
[
|
186 |
-
[
|
187 |
-
'index' => "{% extends 'base' %}
|
188 |
-
{% block content %}
|
189 |
-
{{ parent() }}
|
190 |
-
{% endblock %}",
|
191 |
-
'base' => '{% block content %}{{ foo.bar }}{% endblock %}',
|
192 |
-
],
|
193 |
-
'base', 1,
|
194 |
-
],
|
195 |
-
|
196 |
-
// error occurs in a block from the child
|
197 |
-
[
|
198 |
-
[
|
199 |
-
'index' => "{% extends 'base' %}
|
200 |
-
{% block content %}
|
201 |
-
{{ foo.bar }}
|
202 |
-
{% endblock %}
|
203 |
-
{% block foo %}
|
204 |
-
{{ foo.bar }}
|
205 |
-
{% endblock %}",
|
206 |
-
'base' => '{% block content %}{% endblock %}',
|
207 |
-
],
|
208 |
-
'index', 3,
|
209 |
-
],
|
210 |
-
];
|
211 |
-
}
|
212 |
-
|
213 |
-
public function testTwigLeakOutputInDebugMode()
|
214 |
-
{
|
215 |
-
$output = exec(sprintf('%s %s debug', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
216 |
-
|
217 |
-
$this->assertSame('Hello OOPS', $output);
|
218 |
-
}
|
219 |
-
|
220 |
-
public function testDoesNotTwigLeakOutput()
|
221 |
-
{
|
222 |
-
$output = exec(sprintf('%s %s', \PHP_BINARY, escapeshellarg(__DIR__.'/Fixtures/errors/leak-output.php')));
|
223 |
-
|
224 |
-
$this->assertSame('', $output);
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
class ErrorTest_Foo
|
229 |
-
{
|
230 |
-
public function bar()
|
231 |
-
{
|
232 |
-
throw new \Exception('Runtime error...');
|
233 |
-
}
|
234 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/ExpressionParserTest.php
DELETED
@@ -1,382 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\ArrayExpression;
|
16 |
-
use Twig\Node\Expression\Binary\ConcatBinary;
|
17 |
-
use Twig\Node\Expression\ConstantExpression;
|
18 |
-
use Twig\Node\Expression\NameExpression;
|
19 |
-
use Twig\Parser;
|
20 |
-
use Twig\Source;
|
21 |
-
|
22 |
-
class ExpressionParserTest extends \PHPUnit\Framework\TestCase
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @dataProvider getFailingTestsForAssignment
|
26 |
-
*/
|
27 |
-
public function testCanOnlyAssignToNames($template)
|
28 |
-
{
|
29 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
30 |
-
|
31 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
32 |
-
$parser = new Parser($env);
|
33 |
-
|
34 |
-
$parser->parse($env->tokenize(new Source($template, 'index')));
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getFailingTestsForAssignment()
|
38 |
-
{
|
39 |
-
return [
|
40 |
-
['{% set false = "foo" %}'],
|
41 |
-
['{% set FALSE = "foo" %}'],
|
42 |
-
['{% set true = "foo" %}'],
|
43 |
-
['{% set TRUE = "foo" %}'],
|
44 |
-
['{% set none = "foo" %}'],
|
45 |
-
['{% set NONE = "foo" %}'],
|
46 |
-
['{% set null = "foo" %}'],
|
47 |
-
['{% set NULL = "foo" %}'],
|
48 |
-
['{% set 3 = "foo" %}'],
|
49 |
-
['{% set 1 + 2 = "foo" %}'],
|
50 |
-
['{% set "bar" = "foo" %}'],
|
51 |
-
['{% set %}{% endset %}'],
|
52 |
-
];
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @dataProvider getTestsForArray
|
57 |
-
*/
|
58 |
-
public function testArrayExpression($template, $expected)
|
59 |
-
{
|
60 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
61 |
-
$stream = $env->tokenize($source = new Source($template, ''));
|
62 |
-
$parser = new Parser($env);
|
63 |
-
$expected->setSourceContext($source);
|
64 |
-
|
65 |
-
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr'));
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @dataProvider getFailingTestsForArray
|
70 |
-
*/
|
71 |
-
public function testArraySyntaxError($template)
|
72 |
-
{
|
73 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
74 |
-
|
75 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
76 |
-
$parser = new Parser($env);
|
77 |
-
|
78 |
-
$parser->parse($env->tokenize(new Source($template, 'index')));
|
79 |
-
}
|
80 |
-
|
81 |
-
public function getFailingTestsForArray()
|
82 |
-
{
|
83 |
-
return [
|
84 |
-
['{{ [1, "a": "b"] }}'],
|
85 |
-
['{{ {"a": "b", 2} }}'],
|
86 |
-
];
|
87 |
-
}
|
88 |
-
|
89 |
-
public function getTestsForArray()
|
90 |
-
{
|
91 |
-
return [
|
92 |
-
// simple array
|
93 |
-
['{{ [1, 2] }}', new ArrayExpression([
|
94 |
-
new ConstantExpression(0, 1),
|
95 |
-
new ConstantExpression(1, 1),
|
96 |
-
|
97 |
-
new ConstantExpression(1, 1),
|
98 |
-
new ConstantExpression(2, 1),
|
99 |
-
], 1),
|
100 |
-
],
|
101 |
-
|
102 |
-
// array with trailing ,
|
103 |
-
['{{ [1, 2, ] }}', new ArrayExpression([
|
104 |
-
new ConstantExpression(0, 1),
|
105 |
-
new ConstantExpression(1, 1),
|
106 |
-
|
107 |
-
new ConstantExpression(1, 1),
|
108 |
-
new ConstantExpression(2, 1),
|
109 |
-
], 1),
|
110 |
-
],
|
111 |
-
|
112 |
-
// simple hash
|
113 |
-
['{{ {"a": "b", "b": "c"} }}', new ArrayExpression([
|
114 |
-
new ConstantExpression('a', 1),
|
115 |
-
new ConstantExpression('b', 1),
|
116 |
-
|
117 |
-
new ConstantExpression('b', 1),
|
118 |
-
new ConstantExpression('c', 1),
|
119 |
-
], 1),
|
120 |
-
],
|
121 |
-
|
122 |
-
// hash with trailing ,
|
123 |
-
['{{ {"a": "b", "b": "c", } }}', new ArrayExpression([
|
124 |
-
new ConstantExpression('a', 1),
|
125 |
-
new ConstantExpression('b', 1),
|
126 |
-
|
127 |
-
new ConstantExpression('b', 1),
|
128 |
-
new ConstantExpression('c', 1),
|
129 |
-
], 1),
|
130 |
-
],
|
131 |
-
|
132 |
-
// hash in an array
|
133 |
-
['{{ [1, {"a": "b", "b": "c"}] }}', new ArrayExpression([
|
134 |
-
new ConstantExpression(0, 1),
|
135 |
-
new ConstantExpression(1, 1),
|
136 |
-
|
137 |
-
new ConstantExpression(1, 1),
|
138 |
-
new ArrayExpression([
|
139 |
-
new ConstantExpression('a', 1),
|
140 |
-
new ConstantExpression('b', 1),
|
141 |
-
|
142 |
-
new ConstantExpression('b', 1),
|
143 |
-
new ConstantExpression('c', 1),
|
144 |
-
], 1),
|
145 |
-
], 1),
|
146 |
-
],
|
147 |
-
|
148 |
-
// array in a hash
|
149 |
-
['{{ {"a": [1, 2], "b": "c"} }}', new ArrayExpression([
|
150 |
-
new ConstantExpression('a', 1),
|
151 |
-
new ArrayExpression([
|
152 |
-
new ConstantExpression(0, 1),
|
153 |
-
new ConstantExpression(1, 1),
|
154 |
-
|
155 |
-
new ConstantExpression(1, 1),
|
156 |
-
new ConstantExpression(2, 1),
|
157 |
-
], 1),
|
158 |
-
new ConstantExpression('b', 1),
|
159 |
-
new ConstantExpression('c', 1),
|
160 |
-
], 1),
|
161 |
-
],
|
162 |
-
];
|
163 |
-
}
|
164 |
-
|
165 |
-
public function testStringExpressionDoesNotConcatenateTwoConsecutiveStrings()
|
166 |
-
{
|
167 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
168 |
-
|
169 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
170 |
-
$stream = $env->tokenize(new Source('{{ "a" "b" }}', 'index'));
|
171 |
-
$parser = new Parser($env);
|
172 |
-
|
173 |
-
$parser->parse($stream);
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* @dataProvider getTestsForString
|
178 |
-
*/
|
179 |
-
public function testStringExpression($template, $expected)
|
180 |
-
{
|
181 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false, 'optimizations' => 0]);
|
182 |
-
$stream = $env->tokenize($source = new Source($template, ''));
|
183 |
-
$parser = new Parser($env);
|
184 |
-
$expected->setSourceContext($source);
|
185 |
-
|
186 |
-
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr'));
|
187 |
-
}
|
188 |
-
|
189 |
-
public function getTestsForString()
|
190 |
-
{
|
191 |
-
return [
|
192 |
-
[
|
193 |
-
'{{ "foo" }}', new ConstantExpression('foo', 1),
|
194 |
-
],
|
195 |
-
[
|
196 |
-
'{{ "foo #{bar}" }}', new ConcatBinary(
|
197 |
-
new ConstantExpression('foo ', 1),
|
198 |
-
new NameExpression('bar', 1),
|
199 |
-
1
|
200 |
-
),
|
201 |
-
],
|
202 |
-
[
|
203 |
-
'{{ "foo #{bar} baz" }}', new ConcatBinary(
|
204 |
-
new ConcatBinary(
|
205 |
-
new ConstantExpression('foo ', 1),
|
206 |
-
new NameExpression('bar', 1),
|
207 |
-
1
|
208 |
-
),
|
209 |
-
new ConstantExpression(' baz', 1),
|
210 |
-
1
|
211 |
-
),
|
212 |
-
],
|
213 |
-
|
214 |
-
[
|
215 |
-
'{{ "foo #{"foo #{bar} baz"} baz" }}', new ConcatBinary(
|
216 |
-
new ConcatBinary(
|
217 |
-
new ConstantExpression('foo ', 1),
|
218 |
-
new ConcatBinary(
|
219 |
-
new ConcatBinary(
|
220 |
-
new ConstantExpression('foo ', 1),
|
221 |
-
new NameExpression('bar', 1),
|
222 |
-
1
|
223 |
-
),
|
224 |
-
new ConstantExpression(' baz', 1),
|
225 |
-
1
|
226 |
-
),
|
227 |
-
1
|
228 |
-
),
|
229 |
-
new ConstantExpression(' baz', 1),
|
230 |
-
1
|
231 |
-
),
|
232 |
-
],
|
233 |
-
];
|
234 |
-
}
|
235 |
-
|
236 |
-
public function testAttributeCallDoesNotSupportNamedArguments()
|
237 |
-
{
|
238 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
239 |
-
|
240 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
241 |
-
$parser = new Parser($env);
|
242 |
-
|
243 |
-
$parser->parse($env->tokenize(new Source('{{ foo.bar(name="Foo") }}', 'index')));
|
244 |
-
}
|
245 |
-
|
246 |
-
public function testMacroCallDoesNotSupportNamedArguments()
|
247 |
-
{
|
248 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
249 |
-
|
250 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
251 |
-
$parser = new Parser($env);
|
252 |
-
|
253 |
-
$parser->parse($env->tokenize(new Source('{% from _self import foo %}{% macro foo() %}{% endmacro %}{{ foo(name="Foo") }}', 'index')));
|
254 |
-
}
|
255 |
-
|
256 |
-
public function testMacroDefinitionDoesNotSupportNonNameVariableName()
|
257 |
-
{
|
258 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
259 |
-
$this->expectExceptionMessage('An argument must be a name. Unexpected token "string" of value "a" ("name" expected) in "index" at line 1.');
|
260 |
-
|
261 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
262 |
-
$parser = new Parser($env);
|
263 |
-
|
264 |
-
$parser->parse($env->tokenize(new Source('{% macro foo("a") %}{% endmacro %}', 'index')));
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* @dataProvider getMacroDefinitionDoesNotSupportNonConstantDefaultValues
|
269 |
-
*/
|
270 |
-
public function testMacroDefinitionDoesNotSupportNonConstantDefaultValues($template)
|
271 |
-
{
|
272 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
273 |
-
$this->expectExceptionMessage('A default value for an argument must be a constant (a boolean, a string, a number, or an array) in "index" at line 1');
|
274 |
-
|
275 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
276 |
-
$parser = new Parser($env);
|
277 |
-
|
278 |
-
$parser->parse($env->tokenize(new Source($template, 'index')));
|
279 |
-
}
|
280 |
-
|
281 |
-
public function getMacroDefinitionDoesNotSupportNonConstantDefaultValues()
|
282 |
-
{
|
283 |
-
return [
|
284 |
-
['{% macro foo(name = "a #{foo} a") %}{% endmacro %}'],
|
285 |
-
['{% macro foo(name = [["b", "a #{foo} a"]]) %}{% endmacro %}'],
|
286 |
-
];
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* @dataProvider getMacroDefinitionSupportsConstantDefaultValues
|
291 |
-
*/
|
292 |
-
public function testMacroDefinitionSupportsConstantDefaultValues($template)
|
293 |
-
{
|
294 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
295 |
-
$parser = new Parser($env);
|
296 |
-
|
297 |
-
$parser->parse($env->tokenize(new Source($template, 'index')));
|
298 |
-
|
299 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
300 |
-
// can be executed without throwing any exceptions
|
301 |
-
$this->addToAssertionCount(1);
|
302 |
-
}
|
303 |
-
|
304 |
-
public function getMacroDefinitionSupportsConstantDefaultValues()
|
305 |
-
{
|
306 |
-
return [
|
307 |
-
['{% macro foo(name = "aa") %}{% endmacro %}'],
|
308 |
-
['{% macro foo(name = 12) %}{% endmacro %}'],
|
309 |
-
['{% macro foo(name = true) %}{% endmacro %}'],
|
310 |
-
['{% macro foo(name = ["a"]) %}{% endmacro %}'],
|
311 |
-
['{% macro foo(name = [["a"]]) %}{% endmacro %}'],
|
312 |
-
['{% macro foo(name = {a: "a"}) %}{% endmacro %}'],
|
313 |
-
['{% macro foo(name = {a: {b: "a"}}) %}{% endmacro %}'],
|
314 |
-
];
|
315 |
-
}
|
316 |
-
|
317 |
-
public function testUnknownFunction()
|
318 |
-
{
|
319 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
320 |
-
$this->expectExceptionMessage('Unknown "cycl" function. Did you mean "cycle" in "index" at line 1?');
|
321 |
-
|
322 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
323 |
-
$parser = new Parser($env);
|
324 |
-
|
325 |
-
$parser->parse($env->tokenize(new Source('{{ cycl() }}', 'index')));
|
326 |
-
}
|
327 |
-
|
328 |
-
public function testUnknownFunctionWithoutSuggestions()
|
329 |
-
{
|
330 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
331 |
-
$this->expectExceptionMessage('Unknown "foobar" function in "index" at line 1.');
|
332 |
-
|
333 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
334 |
-
$parser = new Parser($env);
|
335 |
-
|
336 |
-
$parser->parse($env->tokenize(new Source('{{ foobar() }}', 'index')));
|
337 |
-
}
|
338 |
-
|
339 |
-
public function testUnknownFilter()
|
340 |
-
{
|
341 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
342 |
-
$this->expectExceptionMessage('Unknown "lowe" filter. Did you mean "lower" in "index" at line 1?');
|
343 |
-
|
344 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
345 |
-
$parser = new Parser($env);
|
346 |
-
|
347 |
-
$parser->parse($env->tokenize(new Source('{{ 1|lowe }}', 'index')));
|
348 |
-
}
|
349 |
-
|
350 |
-
public function testUnknownFilterWithoutSuggestions()
|
351 |
-
{
|
352 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
353 |
-
$this->expectExceptionMessage('Unknown "foobar" filter in "index" at line 1.');
|
354 |
-
|
355 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
356 |
-
$parser = new Parser($env);
|
357 |
-
|
358 |
-
$parser->parse($env->tokenize(new Source('{{ 1|foobar }}', 'index')));
|
359 |
-
}
|
360 |
-
|
361 |
-
public function testUnknownTest()
|
362 |
-
{
|
363 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
364 |
-
$this->expectExceptionMessage('Unknown "nul" test. Did you mean "null" in "index" at line 1');
|
365 |
-
|
366 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
367 |
-
$parser = new Parser($env);
|
368 |
-
$stream = $env->tokenize(new Source('{{ 1 is nul }}', 'index'));
|
369 |
-
$parser->parse($stream);
|
370 |
-
}
|
371 |
-
|
372 |
-
public function testUnknownTestWithoutSuggestions()
|
373 |
-
{
|
374 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
375 |
-
$this->expectExceptionMessage('Unknown "foobar" test in "index" at line 1.');
|
376 |
-
|
377 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
378 |
-
$parser = new Parser($env);
|
379 |
-
|
380 |
-
$parser->parse($env->tokenize(new Source('{{ 1 is foobar }}', 'index')));
|
381 |
-
}
|
382 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Extension/CoreTest.php
DELETED
@@ -1,371 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Extension;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
|
16 |
-
class CoreTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getRandomFunctionTestData
|
20 |
-
*/
|
21 |
-
public function testRandomFunction(array $expectedInArray, $value1, $value2 = null)
|
22 |
-
{
|
23 |
-
$env = new Environment($this->createMock('Twig_LoaderInterface'));
|
24 |
-
for ($i = 0; $i < 100; ++$i) {
|
25 |
-
$this->assertTrue(\in_array(twig_random($env, $value1, $value2), $expectedInArray, true)); // assertContains() would not consider the type
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getRandomFunctionTestData()
|
30 |
-
{
|
31 |
-
return [
|
32 |
-
'array' => [
|
33 |
-
['apple', 'orange', 'citrus'],
|
34 |
-
['apple', 'orange', 'citrus'],
|
35 |
-
],
|
36 |
-
'Traversable' => [
|
37 |
-
['apple', 'orange', 'citrus'],
|
38 |
-
new \ArrayObject(['apple', 'orange', 'citrus']),
|
39 |
-
],
|
40 |
-
'unicode string' => [
|
41 |
-
['Ä', '€', 'é'],
|
42 |
-
'Ä€é',
|
43 |
-
],
|
44 |
-
'numeric but string' => [
|
45 |
-
['1', '2', '3'],
|
46 |
-
'123',
|
47 |
-
],
|
48 |
-
'integer' => [
|
49 |
-
range(0, 5, 1),
|
50 |
-
5,
|
51 |
-
],
|
52 |
-
'float' => [
|
53 |
-
range(0, 5, 1),
|
54 |
-
5.9,
|
55 |
-
],
|
56 |
-
'negative' => [
|
57 |
-
[0, -1, -2],
|
58 |
-
-2,
|
59 |
-
],
|
60 |
-
'min max int' => [
|
61 |
-
range(50, 100),
|
62 |
-
50,
|
63 |
-
100,
|
64 |
-
],
|
65 |
-
'min max float' => [
|
66 |
-
range(-10, 10),
|
67 |
-
-9.5,
|
68 |
-
9.5,
|
69 |
-
],
|
70 |
-
'min null' => [
|
71 |
-
range(0, 100),
|
72 |
-
null,
|
73 |
-
100,
|
74 |
-
],
|
75 |
-
];
|
76 |
-
}
|
77 |
-
|
78 |
-
public function testRandomFunctionWithoutParameter()
|
79 |
-
{
|
80 |
-
$max = mt_getrandmax();
|
81 |
-
|
82 |
-
for ($i = 0; $i < 100; ++$i) {
|
83 |
-
$val = twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
84 |
-
$this->assertTrue(\is_int($val) && $val >= 0 && $val <= $max);
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
public function testRandomFunctionReturnsAsIs()
|
89 |
-
{
|
90 |
-
$this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), ''));
|
91 |
-
$this->assertSame('', twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['charset' => null]), ''));
|
92 |
-
|
93 |
-
$instance = new \stdClass();
|
94 |
-
$this->assertSame($instance, twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), $instance));
|
95 |
-
}
|
96 |
-
|
97 |
-
public function testRandomFunctionOfEmptyArrayThrowsException()
|
98 |
-
{
|
99 |
-
$this->expectException('\Twig\Error\RuntimeError');
|
100 |
-
|
101 |
-
twig_random(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), []);
|
102 |
-
}
|
103 |
-
|
104 |
-
public function testRandomFunctionOnNonUTF8String()
|
105 |
-
{
|
106 |
-
if (!\function_exists('iconv') && !\function_exists('mb_convert_encoding')) {
|
107 |
-
$this->markTestSkipped('needs iconv or mbstring');
|
108 |
-
}
|
109 |
-
|
110 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
111 |
-
$twig->setCharset('ISO-8859-1');
|
112 |
-
|
113 |
-
$text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
|
114 |
-
for ($i = 0; $i < 30; ++$i) {
|
115 |
-
$rand = twig_random($twig, $text);
|
116 |
-
$this->assertTrue(\in_array(twig_convert_encoding($rand, 'UTF-8', 'ISO-8859-1'), ['Ä', 'é'], true));
|
117 |
-
}
|
118 |
-
}
|
119 |
-
|
120 |
-
public function testReverseFilterOnNonUTF8String()
|
121 |
-
{
|
122 |
-
if (!\function_exists('iconv') && !\function_exists('mb_convert_encoding')) {
|
123 |
-
$this->markTestSkipped('needs iconv or mbstring');
|
124 |
-
}
|
125 |
-
|
126 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
127 |
-
$twig->setCharset('ISO-8859-1');
|
128 |
-
|
129 |
-
$input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8');
|
130 |
-
$output = twig_convert_encoding(twig_reverse_filter($twig, $input), 'UTF-8', 'ISO-8859-1');
|
131 |
-
|
132 |
-
$this->assertEquals($output, 'éÄ');
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* @dataProvider provideCustomEscaperCases
|
137 |
-
*/
|
138 |
-
public function testCustomEscaper($expected, $string, $strategy)
|
139 |
-
{
|
140 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
141 |
-
$twig->getExtension('\Twig\Extension\CoreExtension')->setEscaper('foo', '\Twig\Tests\Extension\foo_escaper_for_test');
|
142 |
-
|
143 |
-
$this->assertSame($expected, twig_escape_filter($twig, $string, $strategy));
|
144 |
-
}
|
145 |
-
|
146 |
-
public function provideCustomEscaperCases()
|
147 |
-
{
|
148 |
-
return [
|
149 |
-
['fooUTF-8', 'foo', 'foo'],
|
150 |
-
['UTF-8', null, 'foo'],
|
151 |
-
['42UTF-8', 42, 'foo'],
|
152 |
-
];
|
153 |
-
}
|
154 |
-
|
155 |
-
public function testUnknownCustomEscaper()
|
156 |
-
{
|
157 |
-
$this->expectException('\Twig\Error\RuntimeError');
|
158 |
-
|
159 |
-
twig_escape_filter(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), 'foo', 'bar');
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @dataProvider provideTwigFirstCases
|
164 |
-
*/
|
165 |
-
public function testTwigFirst($expected, $input)
|
166 |
-
{
|
167 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
168 |
-
$this->assertSame($expected, twig_first($twig, $input));
|
169 |
-
}
|
170 |
-
|
171 |
-
public function provideTwigFirstCases()
|
172 |
-
{
|
173 |
-
$i = [1 => 'a', 2 => 'b', 3 => 'c'];
|
174 |
-
|
175 |
-
return [
|
176 |
-
['a', 'abc'],
|
177 |
-
[1, [1, 2, 3]],
|
178 |
-
['', null],
|
179 |
-
['', ''],
|
180 |
-
['a', new CoreTestIterator($i, array_keys($i), true, 3)],
|
181 |
-
];
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* @dataProvider provideTwigLastCases
|
186 |
-
*/
|
187 |
-
public function testTwigLast($expected, $input)
|
188 |
-
{
|
189 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
190 |
-
$this->assertSame($expected, twig_last($twig, $input));
|
191 |
-
}
|
192 |
-
|
193 |
-
public function provideTwigLastCases()
|
194 |
-
{
|
195 |
-
$i = [1 => 'a', 2 => 'b', 3 => 'c'];
|
196 |
-
|
197 |
-
return [
|
198 |
-
['c', 'abc'],
|
199 |
-
[3, [1, 2, 3]],
|
200 |
-
['', null],
|
201 |
-
['', ''],
|
202 |
-
['c', new CoreTestIterator($i, array_keys($i), true)],
|
203 |
-
];
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* @dataProvider provideArrayKeyCases
|
208 |
-
*/
|
209 |
-
public function testArrayKeysFilter(array $expected, $input)
|
210 |
-
{
|
211 |
-
$this->assertSame($expected, twig_get_array_keys_filter($input));
|
212 |
-
}
|
213 |
-
|
214 |
-
public function provideArrayKeyCases()
|
215 |
-
{
|
216 |
-
$array = ['a' => 'a1', 'b' => 'b1', 'c' => 'c1'];
|
217 |
-
$keys = array_keys($array);
|
218 |
-
|
219 |
-
return [
|
220 |
-
[$keys, $array],
|
221 |
-
[$keys, new CoreTestIterator($array, $keys)],
|
222 |
-
[$keys, new CoreTestIteratorAggregate($array, $keys)],
|
223 |
-
[$keys, new CoreTestIteratorAggregateAggregate($array, $keys)],
|
224 |
-
[[], null],
|
225 |
-
[['a'], new \SimpleXMLElement('<xml><a></a></xml>')],
|
226 |
-
];
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* @dataProvider provideInFilterCases
|
231 |
-
*/
|
232 |
-
public function testInFilter($expected, $value, $compare)
|
233 |
-
{
|
234 |
-
$this->assertSame($expected, twig_in_filter($value, $compare));
|
235 |
-
}
|
236 |
-
|
237 |
-
public function provideInFilterCases()
|
238 |
-
{
|
239 |
-
$array = [1, 2, 'a' => 3, 5, 6, 7];
|
240 |
-
$keys = array_keys($array);
|
241 |
-
|
242 |
-
return [
|
243 |
-
[true, 1, $array],
|
244 |
-
[true, '3', $array],
|
245 |
-
[true, '3', 'abc3def'],
|
246 |
-
[true, 1, new CoreTestIterator($array, $keys, true, 1)],
|
247 |
-
[true, '3', new CoreTestIterator($array, $keys, true, 3)],
|
248 |
-
[true, '3', new CoreTestIteratorAggregateAggregate($array, $keys, true, 3)],
|
249 |
-
[false, 4, $array],
|
250 |
-
[false, 4, new CoreTestIterator($array, $keys, true)],
|
251 |
-
[false, 4, new CoreTestIteratorAggregateAggregate($array, $keys, true)],
|
252 |
-
[false, 1, 1],
|
253 |
-
[true, 'b', new \SimpleXMLElement('<xml><a>b</a></xml>')],
|
254 |
-
];
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* @dataProvider provideSliceFilterCases
|
259 |
-
*/
|
260 |
-
public function testSliceFilter($expected, $input, $start, $length = null, $preserveKeys = false)
|
261 |
-
{
|
262 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
263 |
-
$this->assertSame($expected, twig_slice($twig, $input, $start, $length, $preserveKeys));
|
264 |
-
}
|
265 |
-
|
266 |
-
public function provideSliceFilterCases()
|
267 |
-
{
|
268 |
-
$i = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4];
|
269 |
-
$keys = array_keys($i);
|
270 |
-
|
271 |
-
return [
|
272 |
-
[['a' => 1], $i, 0, 1, true],
|
273 |
-
[['a' => 1], $i, 0, 1, false],
|
274 |
-
[['b' => 2, 'c' => 3], $i, 1, 2],
|
275 |
-
[[1], [1, 2, 3, 4], 0, 1],
|
276 |
-
[[2, 3], [1, 2, 3, 4], 1, 2],
|
277 |
-
[[2, 3], new CoreTestIterator($i, $keys, true), 1, 2],
|
278 |
-
[['c' => 3, 'd' => 4], new CoreTestIteratorAggregate($i, $keys, true), 2, null, true],
|
279 |
-
[$i, new CoreTestIterator($i, $keys, true), 0, \count($keys) + 10, true],
|
280 |
-
[[], new CoreTestIterator($i, $keys, true), \count($keys) + 10],
|
281 |
-
['de', 'abcdef', 3, 2],
|
282 |
-
[[], new \SimpleXMLElement('<items><item>1</item><item>2</item></items>'), 3],
|
283 |
-
[[], new \ArrayIterator([1, 2]), 3],
|
284 |
-
];
|
285 |
-
}
|
286 |
-
}
|
287 |
-
|
288 |
-
function foo_escaper_for_test(Environment $env, $string, $charset)
|
289 |
-
{
|
290 |
-
return $string.$charset;
|
291 |
-
}
|
292 |
-
|
293 |
-
final class CoreTestIteratorAggregate implements \IteratorAggregate
|
294 |
-
{
|
295 |
-
private $iterator;
|
296 |
-
|
297 |
-
public function __construct(array $array, array $keys, $allowAccess = false, $maxPosition = false)
|
298 |
-
{
|
299 |
-
$this->iterator = new CoreTestIterator($array, $keys, $allowAccess, $maxPosition);
|
300 |
-
}
|
301 |
-
|
302 |
-
public function getIterator()
|
303 |
-
{
|
304 |
-
return $this->iterator;
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
final class CoreTestIteratorAggregateAggregate implements \IteratorAggregate
|
309 |
-
{
|
310 |
-
private $iterator;
|
311 |
-
|
312 |
-
public function __construct(array $array, array $keys, $allowValueAccess = false, $maxPosition = false)
|
313 |
-
{
|
314 |
-
$this->iterator = new CoreTestIteratorAggregate($array, $keys, $allowValueAccess, $maxPosition);
|
315 |
-
}
|
316 |
-
|
317 |
-
public function getIterator()
|
318 |
-
{
|
319 |
-
return $this->iterator;
|
320 |
-
}
|
321 |
-
}
|
322 |
-
|
323 |
-
final class CoreTestIterator implements \Iterator
|
324 |
-
{
|
325 |
-
private $position;
|
326 |
-
private $array;
|
327 |
-
private $arrayKeys;
|
328 |
-
private $allowValueAccess;
|
329 |
-
private $maxPosition;
|
330 |
-
|
331 |
-
public function __construct(array $values, array $keys, $allowValueAccess = false, $maxPosition = false)
|
332 |
-
{
|
333 |
-
$this->array = $values;
|
334 |
-
$this->arrayKeys = $keys;
|
335 |
-
$this->position = 0;
|
336 |
-
$this->allowValueAccess = $allowValueAccess;
|
337 |
-
$this->maxPosition = false === $maxPosition ? \count($values) + 1 : $maxPosition;
|
338 |
-
}
|
339 |
-
|
340 |
-
public function rewind()
|
341 |
-
{
|
342 |
-
$this->position = 0;
|
343 |
-
}
|
344 |
-
|
345 |
-
public function current()
|
346 |
-
{
|
347 |
-
if ($this->allowValueAccess) {
|
348 |
-
return $this->array[$this->key()];
|
349 |
-
}
|
350 |
-
|
351 |
-
throw new \LogicException('Code should only use the keys, not the values provided by iterator.');
|
352 |
-
}
|
353 |
-
|
354 |
-
public function key()
|
355 |
-
{
|
356 |
-
return $this->arrayKeys[$this->position];
|
357 |
-
}
|
358 |
-
|
359 |
-
public function next()
|
360 |
-
{
|
361 |
-
++$this->position;
|
362 |
-
if ($this->position === $this->maxPosition) {
|
363 |
-
throw new \LogicException(sprintf('Code should not iterate beyond %d.', $this->maxPosition));
|
364 |
-
}
|
365 |
-
}
|
366 |
-
|
367 |
-
public function valid()
|
368 |
-
{
|
369 |
-
return isset($this->arrayKeys[$this->position]);
|
370 |
-
}
|
371 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Extension/SandboxTest.php
DELETED
@@ -1,365 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Extension;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Extension\SandboxExtension;
|
16 |
-
use Twig\Loader\ArrayLoader;
|
17 |
-
use Twig\Sandbox\SecurityError;
|
18 |
-
use Twig\Sandbox\SecurityPolicy;
|
19 |
-
|
20 |
-
class SandboxTest extends \PHPUnit\Framework\TestCase
|
21 |
-
{
|
22 |
-
protected static $params;
|
23 |
-
protected static $templates;
|
24 |
-
|
25 |
-
protected function setUp()
|
26 |
-
{
|
27 |
-
self::$params = [
|
28 |
-
'name' => 'Fabien',
|
29 |
-
'obj' => new FooObject(),
|
30 |
-
'arr' => ['obj' => new FooObject()],
|
31 |
-
];
|
32 |
-
|
33 |
-
self::$templates = [
|
34 |
-
'1_basic1' => '{{ obj.foo }}',
|
35 |
-
'1_basic2' => '{{ name|upper }}',
|
36 |
-
'1_basic3' => '{% if name %}foo{% endif %}',
|
37 |
-
'1_basic4' => '{{ obj.bar }}',
|
38 |
-
'1_basic5' => '{{ obj }}',
|
39 |
-
'1_basic7' => '{{ cycle(["foo","bar"], 1) }}',
|
40 |
-
'1_basic8' => '{{ obj.getfoobar }}{{ obj.getFooBar }}',
|
41 |
-
'1_basic9' => '{{ obj.foobar }}{{ obj.fooBar }}',
|
42 |
-
'1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
|
43 |
-
'1_layout' => '{% block content %}{% endblock %}',
|
44 |
-
'1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}",
|
45 |
-
'1_include' => '{{ include("1_basic1", sandboxed=true) }}',
|
46 |
-
'1_range_operator' => '{{ (1..2)[0] }}',
|
47 |
-
];
|
48 |
-
}
|
49 |
-
|
50 |
-
public function testSandboxWithInheritance()
|
51 |
-
{
|
52 |
-
$this->expectException('\Twig\Sandbox\SecurityError');
|
53 |
-
$this->expectExceptionMessage('Filter "json_encode" is not allowed in "1_child" at line 3.');
|
54 |
-
|
55 |
-
$twig = $this->getEnvironment(true, [], self::$templates, ['block']);
|
56 |
-
$twig->load('1_child')->render([]);
|
57 |
-
}
|
58 |
-
|
59 |
-
public function testSandboxGloballySet()
|
60 |
-
{
|
61 |
-
$twig = $this->getEnvironment(false, [], self::$templates);
|
62 |
-
$this->assertEquals('FOO', $twig->load('1_basic')->render(self::$params), 'Sandbox does nothing if it is disabled globally');
|
63 |
-
}
|
64 |
-
|
65 |
-
public function testSandboxUnallowedMethodAccessor()
|
66 |
-
{
|
67 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
68 |
-
try {
|
69 |
-
$twig->load('1_basic1')->render(self::$params);
|
70 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed method is called');
|
71 |
-
} catch (SecurityError $e) {
|
72 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError');
|
73 |
-
$this->assertEquals('Twig\Tests\Extension\FooObject', $e->getClassName(), 'Exception should be raised on the "Twig\Tests\Extension\FooObject" class');
|
74 |
-
$this->assertEquals('foo', $e->getMethodName(), 'Exception should be raised on the "foo" method');
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
public function testSandboxUnallowedFilter()
|
79 |
-
{
|
80 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
81 |
-
try {
|
82 |
-
$twig->load('1_basic2')->render(self::$params);
|
83 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed filter is called');
|
84 |
-
} catch (SecurityError $e) {
|
85 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedFilterError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedFilterError');
|
86 |
-
$this->assertEquals('upper', $e->getFilterName(), 'Exception should be raised on the "upper" filter');
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
public function testSandboxUnallowedTag()
|
91 |
-
{
|
92 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
93 |
-
try {
|
94 |
-
$twig->load('1_basic3')->render(self::$params);
|
95 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed tag is used in the template');
|
96 |
-
} catch (SecurityError $e) {
|
97 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedTagError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedTagError');
|
98 |
-
$this->assertEquals('if', $e->getTagName(), 'Exception should be raised on the "if" tag');
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
public function testSandboxUnallowedProperty()
|
103 |
-
{
|
104 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
105 |
-
try {
|
106 |
-
$twig->load('1_basic4')->render(self::$params);
|
107 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed property is called in the template');
|
108 |
-
} catch (SecurityError $e) {
|
109 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedPropertyError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedPropertyError');
|
110 |
-
$this->assertEquals('Twig\Tests\Extension\FooObject', $e->getClassName(), 'Exception should be raised on the "Twig\Tests\Extension\FooObject" class');
|
111 |
-
$this->assertEquals('bar', $e->getPropertyName(), 'Exception should be raised on the "bar" property');
|
112 |
-
}
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @dataProvider getSandboxUnallowedToStringTests
|
117 |
-
*/
|
118 |
-
public function testSandboxUnallowedToString($template)
|
119 |
-
{
|
120 |
-
$twig = $this->getEnvironment(true, [], ['index' => $template], [], ['upper'], ['Twig\Tests\Extension\FooObject' => 'getAnotherFooObject'], [], ['random']);
|
121 |
-
try {
|
122 |
-
$twig->load('index')->render(self::$params);
|
123 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed method (__toString()) is called in the template');
|
124 |
-
} catch (SecurityError $e) {
|
125 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError');
|
126 |
-
$this->assertEquals('Twig\Tests\Extension\FooObject', $e->getClassName(), 'Exception should be raised on the "Twig\Tests\Extension\FooObject" class');
|
127 |
-
$this->assertEquals('__tostring', $e->getMethodName(), 'Exception should be raised on the "__toString" method');
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
public function getSandboxUnallowedToStringTests()
|
132 |
-
{
|
133 |
-
return [
|
134 |
-
'simple' => ['{{ obj }}'],
|
135 |
-
'object_from_array' => ['{{ arr.obj }}'],
|
136 |
-
'object_chain' => ['{{ obj.anotherFooObject }}'],
|
137 |
-
'filter' => ['{{ obj|upper }}'],
|
138 |
-
'filter_from_array' => ['{{ arr.obj|upper }}'],
|
139 |
-
'function' => ['{{ random(obj) }}'],
|
140 |
-
'function_from_array' => ['{{ random(arr.obj) }}'],
|
141 |
-
'function_and_filter' => ['{{ random(obj|upper) }}'],
|
142 |
-
'function_and_filter_from_array' => ['{{ random(arr.obj|upper) }}'],
|
143 |
-
'object_chain_and_filter' => ['{{ obj.anotherFooObject|upper }}'],
|
144 |
-
'object_chain_and_function' => ['{{ random(obj.anotherFooObject) }}'],
|
145 |
-
'concat' => ['{{ obj ~ "" }}'],
|
146 |
-
'concat_again' => ['{{ "" ~ obj }}'],
|
147 |
-
];
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @dataProvider getSandboxAllowedToStringTests
|
152 |
-
*/
|
153 |
-
public function testSandboxAllowedToString($template, $output)
|
154 |
-
{
|
155 |
-
$twig = $this->getEnvironment(true, [], ['index' => $template], ['set'], [], ['Twig\Tests\Extension\FooObject' => ['foo', 'getAnotherFooObject']]);
|
156 |
-
$this->assertEquals($output, $twig->load('index')->render(self::$params));
|
157 |
-
}
|
158 |
-
|
159 |
-
public function getSandboxAllowedToStringTests()
|
160 |
-
{
|
161 |
-
return [
|
162 |
-
'constant_test' => ['{{ obj is constant("PHP_INT_MAX") }}', ''],
|
163 |
-
'set_object' => ['{% set a = obj.anotherFooObject %}{{ a.foo }}', 'foo'],
|
164 |
-
'is_defined' => ['{{ obj.anotherFooObject is defined }}', '1'],
|
165 |
-
'is_null' => ['{{ obj is null }}', ''],
|
166 |
-
'is_sameas' => ['{{ obj is same as(obj) }}', '1'],
|
167 |
-
'is_sameas_from_array' => ['{{ arr.obj is same as(arr.obj) }}', '1'],
|
168 |
-
'is_sameas_from_another_method' => ['{{ obj.anotherFooObject is same as(obj.anotherFooObject) }}', ''],
|
169 |
-
];
|
170 |
-
}
|
171 |
-
|
172 |
-
public function testSandboxAllowMethodToString()
|
173 |
-
{
|
174 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], ['Twig\Tests\Extension\FooObject' => '__toString']);
|
175 |
-
FooObject::reset();
|
176 |
-
$this->assertEquals('foo', $twig->load('1_basic5')->render(self::$params), 'Sandbox allow some methods');
|
177 |
-
$this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once');
|
178 |
-
}
|
179 |
-
|
180 |
-
public function testSandboxAllowMethodToStringDisabled()
|
181 |
-
{
|
182 |
-
$twig = $this->getEnvironment(false, [], self::$templates);
|
183 |
-
FooObject::reset();
|
184 |
-
$this->assertEquals('foo', $twig->load('1_basic5')->render(self::$params), 'Sandbox allows __toString when sandbox disabled');
|
185 |
-
$this->assertEquals(1, FooObject::$called['__toString'], 'Sandbox only calls method once');
|
186 |
-
}
|
187 |
-
|
188 |
-
public function testSandboxUnallowedFunction()
|
189 |
-
{
|
190 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
191 |
-
try {
|
192 |
-
$twig->load('1_basic7')->render(self::$params);
|
193 |
-
$this->fail('Sandbox throws a SecurityError exception if an unallowed function is called in the template');
|
194 |
-
} catch (SecurityError $e) {
|
195 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedFunctionError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedFunctionError');
|
196 |
-
$this->assertEquals('cycle', $e->getFunctionName(), 'Exception should be raised on the "cycle" function');
|
197 |
-
}
|
198 |
-
}
|
199 |
-
|
200 |
-
public function testSandboxUnallowedRangeOperator()
|
201 |
-
{
|
202 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
203 |
-
try {
|
204 |
-
$twig->load('1_range_operator')->render(self::$params);
|
205 |
-
$this->fail('Sandbox throws a SecurityError exception if the unallowed range operator is called');
|
206 |
-
} catch (SecurityError $e) {
|
207 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedFunctionError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedFunctionError');
|
208 |
-
$this->assertEquals('range', $e->getFunctionName(), 'Exception should be raised on the "range" function');
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
-
public function testSandboxAllowMethodFoo()
|
213 |
-
{
|
214 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], ['Twig\Tests\Extension\FooObject' => 'foo']);
|
215 |
-
FooObject::reset();
|
216 |
-
$this->assertEquals('foo', $twig->load('1_basic1')->render(self::$params), 'Sandbox allow some methods');
|
217 |
-
$this->assertEquals(1, FooObject::$called['foo'], 'Sandbox only calls method once');
|
218 |
-
}
|
219 |
-
|
220 |
-
public function testSandboxAllowFilter()
|
221 |
-
{
|
222 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], ['upper']);
|
223 |
-
$this->assertEquals('FABIEN', $twig->load('1_basic2')->render(self::$params), 'Sandbox allow some filters');
|
224 |
-
}
|
225 |
-
|
226 |
-
public function testSandboxAllowTag()
|
227 |
-
{
|
228 |
-
$twig = $this->getEnvironment(true, [], self::$templates, ['if']);
|
229 |
-
$this->assertEquals('foo', $twig->load('1_basic3')->render(self::$params), 'Sandbox allow some tags');
|
230 |
-
}
|
231 |
-
|
232 |
-
public function testSandboxAllowProperty()
|
233 |
-
{
|
234 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], ['Twig\Tests\Extension\FooObject' => 'bar']);
|
235 |
-
$this->assertEquals('bar', $twig->load('1_basic4')->render(self::$params), 'Sandbox allow some properties');
|
236 |
-
}
|
237 |
-
|
238 |
-
public function testSandboxAllowFunction()
|
239 |
-
{
|
240 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], [], ['cycle']);
|
241 |
-
$this->assertEquals('bar', $twig->load('1_basic7')->render(self::$params), 'Sandbox allow some functions');
|
242 |
-
}
|
243 |
-
|
244 |
-
public function testSandboxAllowRangeOperator()
|
245 |
-
{
|
246 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], [], [], ['range']);
|
247 |
-
$this->assertEquals('1', $twig->load('1_range_operator')->render(self::$params), 'Sandbox allow the range operator');
|
248 |
-
}
|
249 |
-
|
250 |
-
public function testSandboxAllowFunctionsCaseInsensitive()
|
251 |
-
{
|
252 |
-
foreach (['getfoobar', 'getFoobar', 'getFooBar'] as $name) {
|
253 |
-
$twig = $this->getEnvironment(true, [], self::$templates, [], [], ['Twig\Tests\Extension\FooObject' => $name]);
|
254 |
-
FooObject::reset();
|
255 |
-
$this->assertEquals('foobarfoobar', $twig->load('1_basic8')->render(self::$params), 'Sandbox allow methods in a case-insensitive way');
|
256 |
-
$this->assertEquals(2, FooObject::$called['getFooBar'], 'Sandbox only calls method once');
|
257 |
-
|
258 |
-
$this->assertEquals('foobarfoobar', $twig->load('1_basic9')->render(self::$params), 'Sandbox allow methods via shortcut names (ie. without get/set)');
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
public function testSandboxLocallySetForAnInclude()
|
263 |
-
{
|
264 |
-
self::$templates = [
|
265 |
-
'2_basic' => '{{ obj.foo }}{% include "2_included" %}{{ obj.foo }}',
|
266 |
-
'2_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
|
267 |
-
];
|
268 |
-
|
269 |
-
$twig = $this->getEnvironment(false, [], self::$templates);
|
270 |
-
$this->assertEquals('fooFOOfoo', $twig->load('2_basic')->render(self::$params), 'Sandbox does nothing if disabled globally and sandboxed not used for the include');
|
271 |
-
|
272 |
-
self::$templates = [
|
273 |
-
'3_basic' => '{{ obj.foo }}{% sandbox %}{% include "3_included" %}{% endsandbox %}{{ obj.foo }}',
|
274 |
-
'3_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}',
|
275 |
-
];
|
276 |
-
|
277 |
-
$twig = $this->getEnvironment(true, [], self::$templates);
|
278 |
-
try {
|
279 |
-
$twig->load('3_basic')->render(self::$params);
|
280 |
-
$this->fail('Sandbox throws a SecurityError exception when the included file is sandboxed');
|
281 |
-
} catch (SecurityError $e) {
|
282 |
-
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedTagError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedTagError');
|
283 |
-
$this->assertEquals('sandbox', $e->getTagName());
|
284 |
-
}
|
285 |
-
}
|
286 |
-
|
287 |
-
public function testMacrosInASandbox()
|
288 |
-
{
|
289 |
-
$twig = $this->getEnvironment(true, ['autoescape' => 'html'], ['index' => <<<EOF
|
290 |
-
{%- import _self as macros %}
|
291 |
-
|
292 |
-
{%- macro test(text) %}<p>{{ text }}</p>{% endmacro %}
|
293 |
-
|
294 |
-
{{- macros.test('username') }}
|
295 |
-
EOF
|
296 |
-
], ['macro', 'import'], ['escape']);
|
297 |
-
|
298 |
-
$this->assertEquals('<p>username</p>', $twig->load('index')->render([]));
|
299 |
-
}
|
300 |
-
|
301 |
-
public function testSandboxDisabledAfterIncludeFunctionError()
|
302 |
-
{
|
303 |
-
$twig = $this->getEnvironment(false, [], self::$templates);
|
304 |
-
|
305 |
-
$e = null;
|
306 |
-
try {
|
307 |
-
$twig->load('1_include')->render(self::$params);
|
308 |
-
} catch (\Throwable $e) {
|
309 |
-
} catch (\Exception $e) {
|
310 |
-
}
|
311 |
-
if (null === $e) {
|
312 |
-
$this->fail('An exception should be thrown for this test to be valid.');
|
313 |
-
}
|
314 |
-
|
315 |
-
$this->assertFalse($twig->getExtension('\Twig\Extension\SandboxExtension')->isSandboxed(), 'Sandboxed include() function call should not leave Sandbox enabled when an error occurs.');
|
316 |
-
}
|
317 |
-
|
318 |
-
protected function getEnvironment($sandboxed, $options, $templates, $tags = [], $filters = [], $methods = [], $properties = [], $functions = [])
|
319 |
-
{
|
320 |
-
$loader = new ArrayLoader($templates);
|
321 |
-
$twig = new Environment($loader, array_merge(['debug' => true, 'cache' => false, 'autoescape' => false], $options));
|
322 |
-
$policy = new SecurityPolicy($tags, $filters, $methods, $properties, $functions);
|
323 |
-
$twig->addExtension(new SandboxExtension($policy, $sandboxed));
|
324 |
-
|
325 |
-
return $twig;
|
326 |
-
}
|
327 |
-
}
|
328 |
-
|
329 |
-
class FooObject
|
330 |
-
{
|
331 |
-
public static $called = ['__toString' => 0, 'foo' => 0, 'getFooBar' => 0];
|
332 |
-
|
333 |
-
public $bar = 'bar';
|
334 |
-
|
335 |
-
public static function reset()
|
336 |
-
{
|
337 |
-
self::$called = ['__toString' => 0, 'foo' => 0, 'getFooBar' => 0];
|
338 |
-
}
|
339 |
-
|
340 |
-
public function __toString()
|
341 |
-
{
|
342 |
-
++self::$called['__toString'];
|
343 |
-
|
344 |
-
return 'foo';
|
345 |
-
}
|
346 |
-
|
347 |
-
public function foo()
|
348 |
-
{
|
349 |
-
++self::$called['foo'];
|
350 |
-
|
351 |
-
return 'foo';
|
352 |
-
}
|
353 |
-
|
354 |
-
public function getFooBar()
|
355 |
-
{
|
356 |
-
++self::$called['getFooBar'];
|
357 |
-
|
358 |
-
return 'foobar';
|
359 |
-
}
|
360 |
-
|
361 |
-
public function getAnotherFooObject()
|
362 |
-
{
|
363 |
-
return new self();
|
364 |
-
}
|
365 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/FactoryRuntimeLoaderTest.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\RuntimeLoader\FactoryRuntimeLoader;
|
15 |
-
|
16 |
-
class FactoryRuntimeLoaderTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
public function testLoad()
|
19 |
-
{
|
20 |
-
$loader = new FactoryRuntimeLoader(['stdClass' => '\Twig\Tests\getRuntime']);
|
21 |
-
|
22 |
-
$this->assertInstanceOf('stdClass', $loader->load('stdClass'));
|
23 |
-
}
|
24 |
-
|
25 |
-
public function testLoadReturnsNullForUnmappedRuntime()
|
26 |
-
{
|
27 |
-
$loader = new FactoryRuntimeLoader();
|
28 |
-
|
29 |
-
$this->assertNull($loader->load('stdClass'));
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
function getRuntime()
|
34 |
-
{
|
35 |
-
return new \stdClass();
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/FileCachingTest.php
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Loader\ArrayLoader;
|
16 |
-
|
17 |
-
class FileCachingTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
private $env;
|
20 |
-
private $tmpDir;
|
21 |
-
|
22 |
-
protected function setUp()
|
23 |
-
{
|
24 |
-
$this->tmpDir = sys_get_temp_dir().'/TwigTests';
|
25 |
-
if (!file_exists($this->tmpDir)) {
|
26 |
-
@mkdir($this->tmpDir, 0777, true);
|
27 |
-
}
|
28 |
-
|
29 |
-
if (!is_writable($this->tmpDir)) {
|
30 |
-
$this->markTestSkipped(sprintf('Unable to run the tests as "%s" is not writable.', $this->tmpDir));
|
31 |
-
}
|
32 |
-
|
33 |
-
$this->env = new Environment(new ArrayLoader(['index' => 'index', 'index2' => 'index2']), ['cache' => $this->tmpDir]);
|
34 |
-
}
|
35 |
-
|
36 |
-
protected function tearDown()
|
37 |
-
{
|
38 |
-
FilesystemHelper::removeDir($this->tmpDir);
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @group legacy
|
43 |
-
*/
|
44 |
-
public function testWritingCacheFiles()
|
45 |
-
{
|
46 |
-
$name = 'index';
|
47 |
-
$this->env->load($name);
|
48 |
-
$cacheFileName = $this->env->getCacheFilename($name);
|
49 |
-
|
50 |
-
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @group legacy
|
55 |
-
*/
|
56 |
-
public function testClearingCacheFiles()
|
57 |
-
{
|
58 |
-
$name = 'index2';
|
59 |
-
$this->env->load($name);
|
60 |
-
$cacheFileName = $this->env->getCacheFilename($name);
|
61 |
-
|
62 |
-
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');
|
63 |
-
$this->env->clearCacheFiles();
|
64 |
-
$this->assertFileNotExists($cacheFileName, 'Cache file was not cleared.');
|
65 |
-
}
|
66 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/FileExtensionEscapingStrategyTest.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\FileExtensionEscapingStrategy;
|
15 |
-
|
16 |
-
class FileExtensionEscapingStrategyTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @dataProvider getGuessData
|
20 |
-
*/
|
21 |
-
public function testGuess($strategy, $filename)
|
22 |
-
{
|
23 |
-
$this->assertSame($strategy, FileExtensionEscapingStrategy::guess($filename));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getGuessData()
|
27 |
-
{
|
28 |
-
return [
|
29 |
-
// default
|
30 |
-
['html', 'foo.html'],
|
31 |
-
['html', 'foo.html.twig'],
|
32 |
-
['html', 'foo'],
|
33 |
-
['html', 'foo.bar.twig'],
|
34 |
-
['html', 'foo.txt/foo'],
|
35 |
-
['html', 'foo.txt/foo.js/'],
|
36 |
-
|
37 |
-
// css
|
38 |
-
['css', 'foo.css'],
|
39 |
-
['css', 'foo.css.twig'],
|
40 |
-
['css', 'foo.twig.css'],
|
41 |
-
['css', 'foo.js.css'],
|
42 |
-
['css', 'foo.js.css.twig'],
|
43 |
-
|
44 |
-
// js
|
45 |
-
['js', 'foo.js'],
|
46 |
-
['js', 'foo.js.twig'],
|
47 |
-
['js', 'foo.txt/foo.js'],
|
48 |
-
['js', 'foo.txt.twig/foo.js'],
|
49 |
-
|
50 |
-
// txt
|
51 |
-
[false, 'foo.txt'],
|
52 |
-
[false, 'foo.txt.twig'],
|
53 |
-
];
|
54 |
-
}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/FilesystemHelper.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
class FilesystemHelper
|
15 |
-
{
|
16 |
-
public static function removeDir($dir)
|
17 |
-
{
|
18 |
-
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \PHP_VERSION_ID < 50300 ? 0 : \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
|
19 |
-
foreach ($iterator as $filename => $fileInfo) {
|
20 |
-
if ($iterator->isDot()) {
|
21 |
-
continue;
|
22 |
-
}
|
23 |
-
|
24 |
-
if ($fileInfo->isDir()) {
|
25 |
-
rmdir($filename);
|
26 |
-
} else {
|
27 |
-
unlink($filename);
|
28 |
-
}
|
29 |
-
}
|
30 |
-
rmdir($dir);
|
31 |
-
}
|
32 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/autoescape/block.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
blocks and autoescape
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include('unrelated.txt.twig') -}}
|
5 |
-
{{ include('template.html.twig') -}}
|
6 |
-
--TEMPLATE(unrelated.txt.twig)--
|
7 |
-
{% block content %}{% endblock %}
|
8 |
-
--TEMPLATE(template.html.twig)--
|
9 |
-
{% extends 'parent.html.twig' %}
|
10 |
-
{% block content %}
|
11 |
-
{{ br -}}
|
12 |
-
{% endblock %}
|
13 |
-
--TEMPLATE(parent.html.twig)--
|
14 |
-
{% set _content = block('content')|raw %}
|
15 |
-
{{ _content|raw }}
|
16 |
-
--DATA--
|
17 |
-
return ['br' => '<br />']
|
18 |
-
--CONFIG--
|
19 |
-
return ['autoescape' => 'name']
|
20 |
-
--EXPECT--
|
21 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/autoescape/name.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"name" autoescape strategy
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ br -}}
|
5 |
-
{{ include('index.js.twig') -}}
|
6 |
-
{{ include('index.html.twig') -}}
|
7 |
-
{{ include('index.txt.twig') -}}
|
8 |
-
--TEMPLATE(index.js.twig)--
|
9 |
-
{{ br -}}
|
10 |
-
--TEMPLATE(index.html.twig)--
|
11 |
-
{{ br -}}
|
12 |
-
--TEMPLATE(index.txt.twig)--
|
13 |
-
{{ br -}}
|
14 |
-
--DATA--
|
15 |
-
return ['br' => '<br />']
|
16 |
-
--CONFIG--
|
17 |
-
return ['autoescape' => 'name']
|
18 |
-
--EXPECT--
|
19 |
-
<br />
|
20 |
-
\u003Cbr\u0020\/\u003E
|
21 |
-
<br />
|
22 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/errors/base.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{% block content %}{% endblock %}
|
|
vendor/twig/twig/tests/Fixtures/errors/index.html
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
{% extends 'base.html' %}
|
2 |
-
{% block content %}
|
3 |
-
{{ foo.bar }}
|
4 |
-
{% endblock %}
|
5 |
-
{% block foo %}
|
6 |
-
{{ foo.bar }}
|
7 |
-
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/errors/leak-output.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Fixtures\errors;
|
4 |
-
|
5 |
-
require __DIR__.'/../../../vendor/autoload.php';
|
6 |
-
|
7 |
-
use Twig\Environment;
|
8 |
-
use Twig\Extension\AbstractExtension;
|
9 |
-
use Twig\Loader\ArrayLoader;
|
10 |
-
use Twig\TwigFilter;
|
11 |
-
|
12 |
-
class BrokenExtension extends AbstractExtension
|
13 |
-
{
|
14 |
-
public function getFilters()
|
15 |
-
{
|
16 |
-
return [
|
17 |
-
new TwigFilter('broken', [$this, 'broken']),
|
18 |
-
];
|
19 |
-
}
|
20 |
-
|
21 |
-
public function broken()
|
22 |
-
{
|
23 |
-
die('OOPS');
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
27 |
-
$loader = new ArrayLoader([
|
28 |
-
'index.html.twig' => 'Hello {{ "world"|broken }}',
|
29 |
-
]);
|
30 |
-
$twig = new Environment($loader, ['debug' => isset($argv[1])]);
|
31 |
-
$twig->addExtension(new BrokenExtension());
|
32 |
-
|
33 |
-
echo $twig->render('index.html.twig');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/child_contents_outside_blocks.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for child templates defining content outside blocks defined by parent
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'base.twig' %}
|
5 |
-
|
6 |
-
Content outside a block.
|
7 |
-
|
8 |
-
{% block sidebar %}
|
9 |
-
Content inside a block.
|
10 |
-
{% endblock %}
|
11 |
-
--TEMPLATE(base.twig)--
|
12 |
-
{% block sidebar %}
|
13 |
-
{% endblock %}
|
14 |
-
--EXCEPTION--
|
15 |
-
Twig\Error\SyntaxError: A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag in "index.twig" at line 3?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/exception_in_extension_extends.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception thrown from a child for an extension error
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'base.twig' %}
|
5 |
-
--TEMPLATE(base.twig)--
|
6 |
-
|
7 |
-
|
8 |
-
{{ random([]) }}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXCEPTION--
|
12 |
-
Twig\Error\RuntimeError: The random function cannot pick from an empty array in "base.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/exception_in_extension_include.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception thrown from an include for an extension error
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include 'content.twig' %}
|
5 |
-
--TEMPLATE(content.twig)--
|
6 |
-
|
7 |
-
|
8 |
-
{{ random([]) }}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXCEPTION--
|
12 |
-
Twig\Error\RuntimeError: The random function cannot pick from an empty array in "content.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/multiline_array_with_undefined_variable.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for multiline array with undefined variable
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = {
|
5 |
-
foo: 'foo',
|
6 |
-
bar: 'bar',
|
7 |
-
|
8 |
-
|
9 |
-
foobar: foobar,
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
foo2: foo2,
|
14 |
-
} %}
|
15 |
-
--DATA--
|
16 |
-
return ['foobar' => 'foobar']
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\RuntimeError: Variable "foo2" does not exist in "index.twig" at line 11.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/multiline_array_with_undefined_variable_again.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for multiline array with undefined variable
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = {
|
5 |
-
foo: 'foo',
|
6 |
-
bar: 'bar',
|
7 |
-
|
8 |
-
|
9 |
-
foobar: foobar,
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
foo2: foo2,
|
14 |
-
} %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\RuntimeError: Variable "foobar" does not exist in "index.twig" at line 7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/multiline_function_with_undefined_variable.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for multile function with undefined variable
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include('foo',
|
5 |
-
with_context=with_context
|
6 |
-
) }}
|
7 |
-
--TEMPLATE(foo)--
|
8 |
-
Foo
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXCEPTION--
|
12 |
-
Twig\Error\RuntimeError: Variable "with_context" does not exist in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/multiline_function_with_unknown_argument.test
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for multiline function with unknown argument
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include('foo',
|
5 |
-
with_context=True,
|
6 |
-
invalid=False
|
7 |
-
) }}
|
8 |
-
--EXCEPTION--
|
9 |
-
Twig\Error\SyntaxError: Unknown argument "invalid" for function "include(template, variables, with_context, ignore_missing, sandboxed)" in "index.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/multiline_tag_with_undefined_variable.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for multiline tag with undefined variable
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include 'foo'
|
5 |
-
with vars
|
6 |
-
%}
|
7 |
-
--TEMPLATE(foo)--
|
8 |
-
Foo
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXCEPTION--
|
12 |
-
Twig\Error\RuntimeError: Variable "vars" does not exist in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/strict_comparison_operator.test
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
The PHP === strict comparison operator is not supported
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 === 2 }}
|
5 |
-
--EXCEPTION--
|
6 |
-
Twig\Error\SyntaxError: Unexpected operator of value "=". Did you try to use "===" or "!==" for strict comparison? Use "is same as(value)" instead in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/syntax_error_in_reused_template.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for syntax error in reused template
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'foo.twig' %}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
{% block bar %}
|
7 |
-
{% do node.data = 5 %}
|
8 |
-
{% endblock %}
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Unexpected token "operator" of value "=" ("end of statement block" expected) in "foo.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/unclosed_tag.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for an unclosed tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{% if foo %}
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
{% for i in fo %}
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
{% endfor %}
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
{% endblock %}
|
19 |
-
--EXCEPTION--
|
20 |
-
Twig\Error\SyntaxError: Unexpected "endblock" tag (expecting closing tag for the "if" tag defined near line 4) in "index.twig" at line 16.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/undefined_parent.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for an undefined parent
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'foo.html' %}
|
5 |
-
|
6 |
-
{% set foo = "foo" %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\LoaderError: Template "foo.html" is not defined in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/undefined_template_in_child_template.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for an undefined template in a child template
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'base.twig' %}
|
5 |
-
|
6 |
-
{% block sidebar %}
|
7 |
-
{{ include('include.twig') }}
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(base.twig)--
|
10 |
-
{% block sidebar %}
|
11 |
-
{% endblock %}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXCEPTION--
|
15 |
-
Twig\Error\LoaderError: Template "include.twig" is not defined in "index.twig" at line 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/exceptions/undefined_trait.test
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for an undefined trait
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'foo' with foobar as bar %}
|
5 |
-
--TEMPLATE(foo)--
|
6 |
-
{% block bar %}
|
7 |
-
{% endblock %}
|
8 |
-
--EXCEPTION--
|
9 |
-
Twig\Error\RuntimeError: Block "foobar" is not defined in trait "foo" in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/_self.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
_self returns the template name
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ _self }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
index.twig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/array.test
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports array notation
|
3 |
-
--TEMPLATE--
|
4 |
-
{# empty array #}
|
5 |
-
{{ []|join(',') }}
|
6 |
-
|
7 |
-
{{ [1, 2]|join(',') }}
|
8 |
-
{{ ['foo', "bar"]|join(',') }}
|
9 |
-
{{ {0: 1, 'foo': 'bar'}|join(',') }}
|
10 |
-
{{ {0: 1, 'foo': 'bar'}|keys|join(',') }}
|
11 |
-
|
12 |
-
{{ {0: 1, foo: 'bar'}|join(',') }}
|
13 |
-
{{ {0: 1, foo: 'bar'}|keys|join(',') }}
|
14 |
-
|
15 |
-
{# nested arrays #}
|
16 |
-
{% set a = [1, 2, [1, 2], {'foo': {'foo': 'bar'}}] %}
|
17 |
-
{{ a[2]|join(',') }}
|
18 |
-
{{ a[3]["foo"]|join(',') }}
|
19 |
-
|
20 |
-
{# works even if [] is used inside the array #}
|
21 |
-
{{ [foo[bar]]|join(',') }}
|
22 |
-
|
23 |
-
{# elements can be any expression #}
|
24 |
-
{{ ['foo'|upper, bar|upper, bar == foo]|join(',') }}
|
25 |
-
|
26 |
-
{# arrays can have a trailing , like in PHP #}
|
27 |
-
{{
|
28 |
-
[
|
29 |
-
1,
|
30 |
-
2,
|
31 |
-
]|join(',')
|
32 |
-
}}
|
33 |
-
|
34 |
-
{# keys can be any expression #}
|
35 |
-
{% set a = 1 %}
|
36 |
-
{% set b = "foo" %}
|
37 |
-
{% set ary = { (a): 'a', (b): 'b', 'c': 'c', (a ~ b): 'd' } %}
|
38 |
-
{{ ary|keys|join(',') }}
|
39 |
-
{{ ary|join(',') }}
|
40 |
-
--DATA--
|
41 |
-
return ['bar' => 'bar', 'foo' => ['bar' => 'bar']]
|
42 |
-
--EXPECT--
|
43 |
-
1,2
|
44 |
-
foo,bar
|
45 |
-
1,bar
|
46 |
-
0,foo
|
47 |
-
|
48 |
-
1,bar
|
49 |
-
0,foo
|
50 |
-
|
51 |
-
1,2
|
52 |
-
bar
|
53 |
-
|
54 |
-
bar
|
55 |
-
|
56 |
-
FOO,BAR,
|
57 |
-
|
58 |
-
1,2
|
59 |
-
|
60 |
-
1,foo,c,1foo
|
61 |
-
a,b,c,d
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/array_call.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports method calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ items.foo }}
|
5 |
-
{{ items['foo'] }}
|
6 |
-
{{ items[foo] }}
|
7 |
-
{{ items[items[foo]] }}
|
8 |
-
--DATA--
|
9 |
-
return ['foo' => 'bar', 'items' => ['foo' => 'bar', 'bar' => 'foo']]
|
10 |
-
--EXPECT--
|
11 |
-
bar
|
12 |
-
bar
|
13 |
-
foo
|
14 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/binary.test
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports binary operations (+, -, *, /, ~, %, and, or)
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 + 1 }}
|
5 |
-
{{ 2 - 1 }}
|
6 |
-
{{ 2 * 2 }}
|
7 |
-
{{ 2 / 2 }}
|
8 |
-
{{ 3 % 2 }}
|
9 |
-
{{ 1 and 1 }}
|
10 |
-
{{ 1 and 0 }}
|
11 |
-
{{ 0 and 1 }}
|
12 |
-
{{ 0 and 0 }}
|
13 |
-
{{ 1 or 1 }}
|
14 |
-
{{ 1 or 0 }}
|
15 |
-
{{ 0 or 1 }}
|
16 |
-
{{ 0 or 0 }}
|
17 |
-
{{ 0 or 1 and 0 }}
|
18 |
-
{{ 1 or 0 and 1 }}
|
19 |
-
{{ "foo" ~ "bar" }}
|
20 |
-
{{ foo ~ "bar" }}
|
21 |
-
{{ "foo" ~ bar }}
|
22 |
-
{{ foo ~ bar }}
|
23 |
-
{{ 20 // 7 }}
|
24 |
-
--DATA--
|
25 |
-
return ['foo' => 'bar', 'bar' => 'foo']
|
26 |
-
--EXPECT--
|
27 |
-
2
|
28 |
-
1
|
29 |
-
4
|
30 |
-
1
|
31 |
-
1
|
32 |
-
1
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
1
|
37 |
-
1
|
38 |
-
1
|
39 |
-
|
40 |
-
|
41 |
-
1
|
42 |
-
foobar
|
43 |
-
barbar
|
44 |
-
foofoo
|
45 |
-
barfoo
|
46 |
-
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/bitwise.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports bitwise operations
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 b-and 5 }}
|
5 |
-
{{ 1 b-or 5 }}
|
6 |
-
{{ 1 b-xor 5 }}
|
7 |
-
{{ (1 and 0 b-or 0) is same as(1 and (0 b-or 0)) ? 'ok' : 'ko' }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
1
|
12 |
-
5
|
13 |
-
4
|
14 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/call_argument_defined_twice.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Argument is defined twice in a call
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date(987654, date = 123456) }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Argument "date" is defined twice for function "date" in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/call_positional_arg_after_named_arg.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Positional arguments after named arguments in a call
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date(date = 123456, 'Y-m-d') }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Positional arguments cannot be used after named arguments for function "date" in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/comparison.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports comparison operators (==, !=, <, >, >=, <=)
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 > 2 }}/{{ 1 > 1 }}/{{ 1 >= 2 }}/{{ 1 >= 1 }}
|
5 |
-
{{ 1 < 2 }}/{{ 1 < 1 }}/{{ 1 <= 2 }}/{{ 1 <= 1 }}
|
6 |
-
{{ 1 == 1 }}/{{ 1 == 2 }}
|
7 |
-
{{ 1 != 1 }}/{{ 1 != 2 }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
///1
|
12 |
-
1//1/1
|
13 |
-
1/
|
14 |
-
/1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/divisibleby.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the "divisible by" operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 8 is divisible by(2) ? 'OK' }}
|
5 |
-
{{ 8 is not divisible by(3) ? 'OK' }}
|
6 |
-
{{ 8 is divisible by (2) ? 'OK' }}
|
7 |
-
{{ 8 is not
|
8 |
-
divisible
|
9 |
-
by
|
10 |
-
(3) ? 'OK' }}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
OK
|
15 |
-
OK
|
16 |
-
OK
|
17 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/dotdot.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the .. operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i in 0..10 %}{{ i }} {% endfor %}
|
5 |
-
|
6 |
-
{% for letter in 'a'..'z' %}{{ letter }} {% endfor %}
|
7 |
-
|
8 |
-
{% for letter in 'a'|upper..'z'|upper %}{{ letter }} {% endfor %}
|
9 |
-
|
10 |
-
{% for i in foo[0]..foo[1] %}{{ i }} {% endfor %}
|
11 |
-
|
12 |
-
{% for i in 0 + 1 .. 10 - 1 %}{{ i }} {% endfor %}
|
13 |
-
--DATA--
|
14 |
-
return ['foo' => [1, 10]]
|
15 |
-
--EXPECT--
|
16 |
-
0 1 2 3 4 5 6 7 8 9 10
|
17 |
-
a b c d e f g h i j k l m n o p q r s t u v w x y z
|
18 |
-
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
|
19 |
-
1 2 3 4 5 6 7 8 9 10
|
20 |
-
1 2 3 4 5 6 7 8 9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/ends_with.test
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the "ends with" operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo' ends with 'o' ? 'OK' : 'KO' }}
|
5 |
-
{{ not ('foo' ends with 'f') ? 'OK' : 'KO' }}
|
6 |
-
{{ not ('foo' ends with 'foowaytoolong') ? 'OK' : 'KO' }}
|
7 |
-
{{ 'foo' ends with '' ? 'OK' : 'KO' }}
|
8 |
-
{{ '1' ends with true ? 'OK' : 'KO' }}
|
9 |
-
{{ 1 ends with true ? 'OK' : 'KO' }}
|
10 |
-
{{ 0 ends with false ? 'OK' : 'KO' }}
|
11 |
-
{{ '' ends with false ? 'OK' : 'KO' }}
|
12 |
-
{{ false ends with false ? 'OK' : 'KO' }}
|
13 |
-
{{ false ends with '' ? 'OK' : 'KO' }}
|
14 |
-
--DATA--
|
15 |
-
return []
|
16 |
-
--EXPECT--
|
17 |
-
OK
|
18 |
-
OK
|
19 |
-
OK
|
20 |
-
OK
|
21 |
-
KO
|
22 |
-
KO
|
23 |
-
KO
|
24 |
-
KO
|
25 |
-
KO
|
26 |
-
KO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/floats.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig compiles floats properly
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '7.0.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{% set val2 = 0.0 %}
|
7 |
-
|
8 |
-
{{ val is same as (0.0) ? 'Yes' : 'No' }}
|
9 |
-
{{ val2 is same as (0.0) ? 'Yes' : 'No' }}
|
10 |
-
{{ val is same as (val2) ? 'Yes' : 'No' }}
|
11 |
-
--DATA--
|
12 |
-
return ['val' => 0.0]
|
13 |
-
--EXPECT--
|
14 |
-
Yes
|
15 |
-
Yes
|
16 |
-
Yes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/grouping.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports grouping of expressions
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ (2 + 2) / 2 }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/literals.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports literals
|
3 |
-
--TEMPLATE--
|
4 |
-
1 {{ true }}
|
5 |
-
2 {{ TRUE }}
|
6 |
-
3 {{ false }}
|
7 |
-
4 {{ FALSE }}
|
8 |
-
5 {{ none }}
|
9 |
-
6 {{ NONE }}
|
10 |
-
7 {{ null }}
|
11 |
-
8 {{ NULL }}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
1 1
|
16 |
-
2 1
|
17 |
-
3
|
18 |
-
4
|
19 |
-
5
|
20 |
-
6
|
21 |
-
7
|
22 |
-
8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/magic_call.test
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports __call() for attributes
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ foo.foo }}
|
5 |
-
{{ foo.bar }}
|
6 |
-
--DATA--
|
7 |
-
class TestClassForMagicCallAttributes
|
8 |
-
{
|
9 |
-
public function getBar()
|
10 |
-
{
|
11 |
-
return 'bar_from_getbar';
|
12 |
-
}
|
13 |
-
|
14 |
-
public function __call($method, $arguments)
|
15 |
-
{
|
16 |
-
if ('foo' === $method) {
|
17 |
-
return 'foo_from_call';
|
18 |
-
}
|
19 |
-
|
20 |
-
return false;
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
return ['foo' => new TestClassForMagicCallAttributes()]
|
25 |
-
--EXPECT--
|
26 |
-
foo_from_call
|
27 |
-
bar_from_getbar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/matches.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the "matches" operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo' matches '/o/' ? 'OK' : 'KO' }}
|
5 |
-
{{ 'foo' matches '/^fo/' ? 'OK' : 'KO' }}
|
6 |
-
{{ 'foo' matches '/O/i' ? 'OK' : 'KO' }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
OK
|
11 |
-
OK
|
12 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/method_call.test
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports method calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ items.foo.foo }}
|
5 |
-
{{ items.foo.getFoo() }}
|
6 |
-
{{ items.foo.bar }}
|
7 |
-
{{ items.foo['bar'] }}
|
8 |
-
{{ items.foo.bar('a', 43) }}
|
9 |
-
{{ items.foo.bar(foo) }}
|
10 |
-
{{ items.foo.self.foo() }}
|
11 |
-
{{ items.foo.is }}
|
12 |
-
{{ items.foo.in }}
|
13 |
-
{{ items.foo.not }}
|
14 |
-
--DATA--
|
15 |
-
return ['foo' => 'bar', 'items' => ['foo' => new Twig\Tests\TwigTestFoo(), 'bar' => 'foo']]
|
16 |
-
--CONFIG--
|
17 |
-
return ['strict_variables' => false]
|
18 |
-
--EXPECT--
|
19 |
-
foo
|
20 |
-
foo
|
21 |
-
bar
|
22 |
-
|
23 |
-
bar_a-43
|
24 |
-
bar_bar
|
25 |
-
foo
|
26 |
-
is
|
27 |
-
in
|
28 |
-
not
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/negative_numbers.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig manages negative numbers correctly
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ -1 }}
|
5 |
-
{{ - 1 }}
|
6 |
-
{{ 5 - 1 }}
|
7 |
-
{{ 5-1 }}
|
8 |
-
{{ 5 + -1 }}
|
9 |
-
{{ 5 + - 1 }}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
-1
|
14 |
-
-1
|
15 |
-
4
|
16 |
-
4
|
17 |
-
4
|
18 |
-
4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/not_arrow_fn.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
A string in parentheses cannot be confused with an arrow function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ ["foo", "bar"]|join(("f")) }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
foofbar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/operators_as_variables.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig allows to use named operators as variable names
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for match in matches %}
|
5 |
-
{{- match }}
|
6 |
-
{% endfor %}
|
7 |
-
{{ in }}
|
8 |
-
{{ is }}
|
9 |
-
--DATA--
|
10 |
-
return ['matches' => [1, 2, 3], 'in' => 'in', 'is' => 'is']
|
11 |
-
--EXPECT--
|
12 |
-
1
|
13 |
-
2
|
14 |
-
3
|
15 |
-
in
|
16 |
-
is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/postfix.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig parses postfix expressions
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{% macro foo() %}foo{% endmacro %}
|
7 |
-
|
8 |
-
{{ 'a' }}
|
9 |
-
{{ 'a'|upper }}
|
10 |
-
{{ ('a')|upper }}
|
11 |
-
{{ -1|upper }}
|
12 |
-
{{ macros.foo() }}
|
13 |
-
{{ (macros).foo() }}
|
14 |
-
--DATA--
|
15 |
-
return []
|
16 |
-
--EXPECT--
|
17 |
-
a
|
18 |
-
A
|
19 |
-
A
|
20 |
-
-1
|
21 |
-
foo
|
22 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/power.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig parses power expressions
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 2**3 }}
|
5 |
-
{{ (-2)**3 }}
|
6 |
-
{{ (-2)**(-3) }}
|
7 |
-
{{ a ** a }}
|
8 |
-
{{ a ** b }}
|
9 |
-
{{ b ** a }}
|
10 |
-
{{ b ** b }}
|
11 |
-
--DATA--
|
12 |
-
return ['a' => 4, 'b' => -2]
|
13 |
-
--EXPECT--
|
14 |
-
8
|
15 |
-
-8
|
16 |
-
-0.125
|
17 |
-
256
|
18 |
-
0.0625
|
19 |
-
16
|
20 |
-
0.25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/sameas.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the "same as" operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 is same as(1) ? 'OK' }}
|
5 |
-
{{ 1 is not same as(true) ? 'OK' }}
|
6 |
-
{{ 1 is same as(1) ? 'OK' }}
|
7 |
-
{{ 1 is not same as(true) ? 'OK' }}
|
8 |
-
{{ 1 is same as (1) ? 'OK' }}
|
9 |
-
{{ 1 is not
|
10 |
-
same
|
11 |
-
as
|
12 |
-
(true) ? 'OK' }}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
OK
|
17 |
-
OK
|
18 |
-
OK
|
19 |
-
OK
|
20 |
-
OK
|
21 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/starts_with.test
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the "starts with" operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo' starts with 'f' ? 'OK' : 'KO' }}
|
5 |
-
{{ not ('foo' starts with 'oo') ? 'OK' : 'KO' }}
|
6 |
-
{{ not ('foo' starts with 'foowaytoolong') ? 'OK' : 'KO' }}
|
7 |
-
{{ 'foo' starts with 'f' ? 'OK' : 'KO' }}
|
8 |
-
{{ 'foo' starts
|
9 |
-
with 'f' ? 'OK' : 'KO' }}
|
10 |
-
{{ 'foo' starts with '' ? 'OK' : 'KO' }}
|
11 |
-
{{ '1' starts with true ? 'OK' : 'KO' }}
|
12 |
-
{{ '' starts with false ? 'OK' : 'KO' }}
|
13 |
-
{{ 'a' starts with false ? 'OK' : 'KO' }}
|
14 |
-
{{ false starts with '' ? 'OK' : 'KO' }}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
OK
|
19 |
-
OK
|
20 |
-
OK
|
21 |
-
OK
|
22 |
-
OK
|
23 |
-
OK
|
24 |
-
KO
|
25 |
-
KO
|
26 |
-
KO
|
27 |
-
KO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/string_operator_as_var_assignment.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the string operators as variable names in assignments
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for matches in [1, 2] %}
|
5 |
-
{{- matches }}
|
6 |
-
{% endfor %}
|
7 |
-
|
8 |
-
{% set matches = [1, 2] %}
|
9 |
-
|
10 |
-
OK
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
1
|
15 |
-
2
|
16 |
-
|
17 |
-
|
18 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/strings.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports string interpolation
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "foo #{"foo #{bar} baz"} baz" }}
|
5 |
-
{{ "foo #{bar}#{bar} baz" }}
|
6 |
-
--DATA--
|
7 |
-
return ['bar' => 'BAR']
|
8 |
-
--EXPECT--
|
9 |
-
foo foo BAR baz baz
|
10 |
-
foo BARBAR baz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/ternary_operator.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the ternary operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 ? 'YES' : 'NO' }}
|
5 |
-
{{ 0 ? 'YES' : 'NO' }}
|
6 |
-
{{ 0 ? 'YES' : (1 ? 'YES1' : 'NO1') }}
|
7 |
-
{{ 0 ? 'YES' : (0 ? 'YES1' : 'NO1') }}
|
8 |
-
{{ 1 == 1 ? 'foo<br />':'' }}
|
9 |
-
{{ foo ~ (bar ? ('-' ~ bar) : '') }}
|
10 |
-
--DATA--
|
11 |
-
return ['foo' => 'foo', 'bar' => 'bar']
|
12 |
-
--EXPECT--
|
13 |
-
YES
|
14 |
-
NO
|
15 |
-
YES1
|
16 |
-
NO1
|
17 |
-
foo<br />
|
18 |
-
foo-bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/ternary_operator_noelse.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the ternary operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 ? 'YES' }}
|
5 |
-
{{ 0 ? 'YES' }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
YES
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/ternary_operator_nothen.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the ternary operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'YES' ?: 'NO' }}
|
5 |
-
{{ 0 ?: 'NO' }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
YES
|
10 |
-
NO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/two_word_operators_as_variables.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig does not allow to use two-word named operators as variable names
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ starts with }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Unexpected token "operator" of value "starts with" in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/unary.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports unary operators (not, -, +)
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ not 1 }}/{{ not 0 }}
|
5 |
-
{{ +1 + 1 }}/{{ -1 - 1 }}
|
6 |
-
{{ not (false or true) }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
/1
|
11 |
-
2/-2
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/unary_macro_arguments.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig manages negative numbers as default parameters
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
{{ macros.negative_number1() }}
|
6 |
-
{{ macros.negative_number2() }}
|
7 |
-
{{ macros.negative_number3() }}
|
8 |
-
{{ macros.positive_number1() }}
|
9 |
-
{{ macros.positive_number2() }}
|
10 |
-
{% macro negative_number1(nb=-1) %}{{ nb }}{% endmacro %}
|
11 |
-
{% macro negative_number2(nb = --1) %}{{ nb }}{% endmacro %}
|
12 |
-
{% macro negative_number3(nb = - 1) %}{{ nb }}{% endmacro %}
|
13 |
-
{% macro positive_number1(nb = +1) %}{{ nb }}{% endmacro %}
|
14 |
-
{% macro positive_number2(nb = ++1) %}{{ nb }}{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
-1
|
19 |
-
1
|
20 |
-
-1
|
21 |
-
1
|
22 |
-
1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/expressions/unary_precedence.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig unary operators precedence
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ -1 - 1 }}
|
5 |
-
{{ -1 - -1 }}
|
6 |
-
{{ -1 * -1 }}
|
7 |
-
{{ 4 / -1 * 5 }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
-2
|
12 |
-
0
|
13 |
-
1
|
14 |
-
-20
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/abs.test
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"abs" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ (-5.5)|abs }}
|
5 |
-
{{ (-5)|abs }}
|
6 |
-
{{ (-0)|abs }}
|
7 |
-
{{ 0|abs }}
|
8 |
-
{{ 5|abs }}
|
9 |
-
{{ 5.5|abs }}
|
10 |
-
{{ number1|abs }}
|
11 |
-
{{ number2|abs }}
|
12 |
-
{{ number3|abs }}
|
13 |
-
{{ number4|abs }}
|
14 |
-
{{ number5|abs }}
|
15 |
-
{{ number6|abs }}
|
16 |
-
--DATA--
|
17 |
-
return ['number1' => -5.5, 'number2' => -5, 'number3' => -0, 'number4' => 0, 'number5' => 5, 'number6' => 5.5]
|
18 |
-
--EXPECT--
|
19 |
-
5.5
|
20 |
-
5
|
21 |
-
0
|
22 |
-
0
|
23 |
-
5
|
24 |
-
5.5
|
25 |
-
5.5
|
26 |
-
5
|
27 |
-
0
|
28 |
-
0
|
29 |
-
5
|
30 |
-
5.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch.test
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for row in items|batch(3) %}
|
5 |
-
<div class=row>
|
6 |
-
{% for column in row %}
|
7 |
-
<div class=item>{{ column }}</div>
|
8 |
-
{% endfor %}
|
9 |
-
</div>
|
10 |
-
{% endfor %}
|
11 |
-
--DATA--
|
12 |
-
return ['items' => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']]
|
13 |
-
--EXPECT--
|
14 |
-
<div class=row>
|
15 |
-
<div class=item>a</div>
|
16 |
-
<div class=item>b</div>
|
17 |
-
<div class=item>c</div>
|
18 |
-
</div>
|
19 |
-
<div class=row>
|
20 |
-
<div class=item>d</div>
|
21 |
-
<div class=item>e</div>
|
22 |
-
<div class=item>f</div>
|
23 |
-
</div>
|
24 |
-
<div class=row>
|
25 |
-
<div class=item>g</div>
|
26 |
-
<div class=item>h</div>
|
27 |
-
<div class=item>i</div>
|
28 |
-
</div>
|
29 |
-
<div class=row>
|
30 |
-
<div class=item>j</div>
|
31 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_float.test
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for row in items|batch(3.1) %}
|
5 |
-
<div class=row>
|
6 |
-
{% for column in row %}
|
7 |
-
<div class=item>{{ column }}</div>
|
8 |
-
{% endfor %}
|
9 |
-
</div>
|
10 |
-
{% endfor %}
|
11 |
-
--DATA--
|
12 |
-
return ['items' => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']]
|
13 |
-
--EXPECT--
|
14 |
-
<div class=row>
|
15 |
-
<div class=item>a</div>
|
16 |
-
<div class=item>b</div>
|
17 |
-
<div class=item>c</div>
|
18 |
-
<div class=item>d</div>
|
19 |
-
</div>
|
20 |
-
<div class=row>
|
21 |
-
<div class=item>e</div>
|
22 |
-
<div class=item>f</div>
|
23 |
-
<div class=item>g</div>
|
24 |
-
<div class=item>h</div>
|
25 |
-
</div>
|
26 |
-
<div class=row>
|
27 |
-
<div class=item>i</div>
|
28 |
-
<div class=item>j</div>
|
29 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_empty_fill.test
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
<table>
|
5 |
-
{% for row in items|batch(3, '') %}
|
6 |
-
<tr>
|
7 |
-
{% for column in row %}
|
8 |
-
<td>{{ column }}</td>
|
9 |
-
{% endfor %}
|
10 |
-
</tr>
|
11 |
-
{% endfor %}
|
12 |
-
</table>
|
13 |
-
--DATA--
|
14 |
-
return ['items' => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']]
|
15 |
-
--EXPECT--
|
16 |
-
<table>
|
17 |
-
<tr>
|
18 |
-
<td>a</td>
|
19 |
-
<td>b</td>
|
20 |
-
<td>c</td>
|
21 |
-
</tr>
|
22 |
-
<tr>
|
23 |
-
<td>d</td>
|
24 |
-
<td>e</td>
|
25 |
-
<td>f</td>
|
26 |
-
</tr>
|
27 |
-
<tr>
|
28 |
-
<td>g</td>
|
29 |
-
<td>h</td>
|
30 |
-
<td>i</td>
|
31 |
-
</tr>
|
32 |
-
<tr>
|
33 |
-
<td>j</td>
|
34 |
-
<td></td>
|
35 |
-
<td></td>
|
36 |
-
</tr>
|
37 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_exact_elements.test
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for row in items|batch(3, 'fill') %}
|
5 |
-
<div class=row>
|
6 |
-
{% for column in row %}
|
7 |
-
<div class=item>{{ column }}</div>
|
8 |
-
{% endfor %}
|
9 |
-
</div>
|
10 |
-
{% endfor %}
|
11 |
-
--DATA--
|
12 |
-
return ['items' => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']]
|
13 |
-
--EXPECT--
|
14 |
-
<div class=row>
|
15 |
-
<div class=item>a</div>
|
16 |
-
<div class=item>b</div>
|
17 |
-
<div class=item>c</div>
|
18 |
-
</div>
|
19 |
-
<div class=row>
|
20 |
-
<div class=item>d</div>
|
21 |
-
<div class=item>e</div>
|
22 |
-
<div class=item>f</div>
|
23 |
-
</div>
|
24 |
-
<div class=row>
|
25 |
-
<div class=item>g</div>
|
26 |
-
<div class=item>h</div>
|
27 |
-
<div class=item>i</div>
|
28 |
-
</div>
|
29 |
-
<div class=row>
|
30 |
-
<div class=item>j</div>
|
31 |
-
<div class=item>k</div>
|
32 |
-
<div class=item>l</div>
|
33 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_fill.test
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
<table>
|
5 |
-
{% for row in items|batch(3, 'fill') %}
|
6 |
-
<tr>
|
7 |
-
{% for column in row %}
|
8 |
-
<td>{{ column }}</td>
|
9 |
-
{% endfor %}
|
10 |
-
</tr>
|
11 |
-
{% endfor %}
|
12 |
-
</table>
|
13 |
-
--DATA--
|
14 |
-
return ['items' => ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']]
|
15 |
-
--EXPECT--
|
16 |
-
<table>
|
17 |
-
<tr>
|
18 |
-
<td>a</td>
|
19 |
-
<td>b</td>
|
20 |
-
<td>c</td>
|
21 |
-
</tr>
|
22 |
-
<tr>
|
23 |
-
<td>d</td>
|
24 |
-
<td>e</td>
|
25 |
-
<td>f</td>
|
26 |
-
</tr>
|
27 |
-
<tr>
|
28 |
-
<td>g</td>
|
29 |
-
<td>h</td>
|
30 |
-
<td>i</td>
|
31 |
-
</tr>
|
32 |
-
<tr>
|
33 |
-
<td>j</td>
|
34 |
-
<td>fill</td>
|
35 |
-
<td>fill</td>
|
36 |
-
</tr>
|
37 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_keys.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter preserves array keys
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ {'foo': 'bar', 'key': 'value'}|batch(4)|first|keys|join(',') }}
|
5 |
-
{{ {'foo': 'bar', 'key': 'value'}|batch(4, 'fill')|first|keys|join(',') }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
foo,key
|
10 |
-
foo,key,0,1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_more_elements.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for row in items|batch(3, 'fill') %}
|
5 |
-
<div class=row>
|
6 |
-
{% for key, column in row %}
|
7 |
-
<div class={{ key }}>{{ column }}</div>
|
8 |
-
{% endfor %}
|
9 |
-
</div>
|
10 |
-
{% endfor %}
|
11 |
-
--DATA--
|
12 |
-
return ['items' => ['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', '123' => 'e']]
|
13 |
-
--EXPECT--
|
14 |
-
<div class=row>
|
15 |
-
<div class=a>a</div>
|
16 |
-
<div class=b>b</div>
|
17 |
-
<div class=c>c</div>
|
18 |
-
</div>
|
19 |
-
<div class=row>
|
20 |
-
<div class=d>d</div>
|
21 |
-
<div class=123>e</div>
|
22 |
-
<div class=124>fill</div>
|
23 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/batch_with_zero_elements.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"batch" filter with zero elements
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ []|batch(3)|length }}
|
5 |
-
{{ []|batch(3, 'fill')|length }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
0
|
10 |
-
0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/convert_encoding.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"convert_encoding" filter
|
3 |
-
--CONDITION--
|
4 |
-
function_exists('iconv') || function_exists('mb_convert_encoding')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ "愛していますか?"|convert_encoding('ISO-2022-JP', 'UTF-8')|convert_encoding('UTF-8', 'ISO-2022-JP') }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
愛していますか?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date.test
DELETED
@@ -1,90 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date1|date }}
|
5 |
-
{{ date1|date('d/m/Y') }}
|
6 |
-
{{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }}
|
7 |
-
{{ date1|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }}
|
8 |
-
{{ date1|date('d/m/Y H:i:s P', 'America/Chicago') }}
|
9 |
-
{{ date1|date('e') }}
|
10 |
-
{{ date1|date('d/m/Y H:i:s') }}
|
11 |
-
|
12 |
-
{{ date2|date }}
|
13 |
-
{{ date2|date('d/m/Y') }}
|
14 |
-
{{ date2|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }}
|
15 |
-
{{ date2|date('d/m/Y H:i:s', timezone1) }}
|
16 |
-
{{ date2|date('d/m/Y H:i:s') }}
|
17 |
-
|
18 |
-
{{ date3|date }}
|
19 |
-
{{ date3|date('d/m/Y') }}
|
20 |
-
|
21 |
-
{{ date4|date }}
|
22 |
-
{{ date4|date('d/m/Y') }}
|
23 |
-
|
24 |
-
{{ date5|date }}
|
25 |
-
{{ date5|date('d/m/Y') }}
|
26 |
-
|
27 |
-
{{ date6|date('d/m/Y H:i:s P', 'Europe/Paris') }}
|
28 |
-
{{ date6|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }}
|
29 |
-
{{ date6|date('d/m/Y H:i:s P', false) }}
|
30 |
-
{{ date6|date('e', 'Europe/Paris') }}
|
31 |
-
{{ date6|date('e', false) }}
|
32 |
-
|
33 |
-
{{ date7|date }}
|
34 |
-
{{ date7|date(timezone='Europe/Paris') }}
|
35 |
-
{{ date7|date(timezone='Asia/Hong_Kong') }}
|
36 |
-
{{ date7|date(timezone=false) }}
|
37 |
-
{{ date7|date(timezone='Indian/Mauritius') }}
|
38 |
-
|
39 |
-
{{ '2010-01-28 15:00:00'|date(timezone="Europe/Paris") }}
|
40 |
-
{{ '2010-01-28 15:00:00'|date(timezone="Asia/Hong_Kong") }}
|
41 |
-
--DATA--
|
42 |
-
date_default_timezone_set('Europe/Paris');
|
43 |
-
return [
|
44 |
-
'date1' => mktime(13, 45, 0, 10, 4, 2010),
|
45 |
-
'date2' => new \DateTime('2010-10-04 13:45'),
|
46 |
-
'date3' => '2010-10-04 13:45',
|
47 |
-
'date4' => 1286199900, // \DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new \DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
|
48 |
-
'date5' => -189291360, // \DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new \DateTimeZone('UTC'))->getTimestamp(),
|
49 |
-
'date6' => new \DateTime('2010-10-04 13:45', new \DateTimeZone('America/New_York')),
|
50 |
-
'date7' => '2010-01-28T15:00:00+04:00',
|
51 |
-
'timezone1' => new \DateTimeZone('America/New_York'),
|
52 |
-
]
|
53 |
-
--EXPECT--
|
54 |
-
October 4, 2010 13:45
|
55 |
-
04/10/2010
|
56 |
-
04/10/2010 19:45:00
|
57 |
-
04/10/2010 19:45:00 +08:00
|
58 |
-
04/10/2010 06:45:00 -05:00
|
59 |
-
Europe/Paris
|
60 |
-
04/10/2010 13:45:00
|
61 |
-
|
62 |
-
October 4, 2010 13:45
|
63 |
-
04/10/2010
|
64 |
-
04/10/2010 19:45:00
|
65 |
-
04/10/2010 07:45:00
|
66 |
-
04/10/2010 13:45:00
|
67 |
-
|
68 |
-
October 4, 2010 13:45
|
69 |
-
04/10/2010
|
70 |
-
|
71 |
-
October 4, 2010 15:45
|
72 |
-
04/10/2010
|
73 |
-
|
74 |
-
January 2, 1964 04:04
|
75 |
-
02/01/1964
|
76 |
-
|
77 |
-
04/10/2010 19:45:00 +02:00
|
78 |
-
05/10/2010 01:45:00 +08:00
|
79 |
-
04/10/2010 13:45:00 -04:00
|
80 |
-
Europe/Paris
|
81 |
-
America/New_York
|
82 |
-
|
83 |
-
January 28, 2010 12:00
|
84 |
-
January 28, 2010 12:00
|
85 |
-
January 28, 2010 19:00
|
86 |
-
January 28, 2010 15:00
|
87 |
-
January 28, 2010 15:00
|
88 |
-
|
89 |
-
January 28, 2010 15:00
|
90 |
-
January 28, 2010 22:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_default_format.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date1|date }}
|
5 |
-
{{ date1|date('d/m/Y') }}
|
6 |
-
--DATA--
|
7 |
-
date_default_timezone_set('UTC');
|
8 |
-
$twig->getExtension('\Twig\Extension\CoreExtension')->setDateFormat('Y-m-d', '%d days %h hours');
|
9 |
-
return [
|
10 |
-
'date1' => mktime(13, 45, 0, 10, 4, 2010),
|
11 |
-
]
|
12 |
-
--EXPECT--
|
13 |
-
2010-10-04
|
14 |
-
04/10/2010
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_default_format_interval.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter (interval support as of PHP 5.3)
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.3.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ date2|date }}
|
7 |
-
{{ date2|date('%d days') }}
|
8 |
-
--DATA--
|
9 |
-
date_default_timezone_set('UTC');
|
10 |
-
$twig->getExtension('\Twig\Extension\CoreExtension')->setDateFormat('Y-m-d', '%d days %h hours');
|
11 |
-
return [
|
12 |
-
'date2' => new \DateInterval('P2D'),
|
13 |
-
]
|
14 |
-
--EXPECT--
|
15 |
-
2 days 0 hours
|
16 |
-
2 days
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_immutable.test
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.5.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ date1|date }}
|
7 |
-
{{ date1|date('d/m/Y') }}
|
8 |
-
{{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }}
|
9 |
-
{{ date1|date('d/m/Y H:i:s', timezone1) }}
|
10 |
-
{{ date1|date('d/m/Y H:i:s') }}
|
11 |
-
{{ date1|date_modify('+1 hour')|date('d/m/Y H:i:s') }}
|
12 |
-
|
13 |
-
{{ date2|date('d/m/Y H:i:s P', 'Europe/Paris') }}
|
14 |
-
{{ date2|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }}
|
15 |
-
{{ date2|date('d/m/Y H:i:s P', false) }}
|
16 |
-
{{ date2|date('e', 'Europe/Paris') }}
|
17 |
-
{{ date2|date('e', false) }}
|
18 |
-
--DATA--
|
19 |
-
date_default_timezone_set('Europe/Paris');
|
20 |
-
return [
|
21 |
-
'date1' => new \DateTimeImmutable('2010-10-04 13:45'),
|
22 |
-
'date2' => new \DateTimeImmutable('2010-10-04 13:45', new \DateTimeZone('America/New_York')),
|
23 |
-
'timezone1' => new \DateTimeZone('America/New_York'),
|
24 |
-
]
|
25 |
-
--EXPECT--
|
26 |
-
October 4, 2010 13:45
|
27 |
-
04/10/2010
|
28 |
-
04/10/2010 19:45:00
|
29 |
-
04/10/2010 07:45:00
|
30 |
-
04/10/2010 13:45:00
|
31 |
-
04/10/2010 14:45:00
|
32 |
-
|
33 |
-
04/10/2010 19:45:00 +02:00
|
34 |
-
05/10/2010 01:45:00 +08:00
|
35 |
-
04/10/2010 13:45:00 -04:00
|
36 |
-
Europe/Paris
|
37 |
-
America/New_York
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_interval.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter (interval support as of PHP 5.3)
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.3.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ date1|date }}
|
7 |
-
{{ date1|date('%d days %h hours') }}
|
8 |
-
{{ date1|date('%d days %h hours', timezone1) }}
|
9 |
-
--DATA--
|
10 |
-
date_default_timezone_set('UTC');
|
11 |
-
return [
|
12 |
-
'date1' => new \DateInterval('P2D'),
|
13 |
-
// This should have no effect on \DateInterval formatting
|
14 |
-
'timezone1' => new \DateTimeZone('America/New_York'),
|
15 |
-
]
|
16 |
-
--EXPECT--
|
17 |
-
2 days
|
18 |
-
2 days 0 hours
|
19 |
-
2 days 0 hours
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_modify.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date_modify" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date1|date_modify('-1day')|date('Y-m-d H:i:s') }}
|
5 |
-
{{ date2|date_modify('-1day')|date('Y-m-d H:i:s') }}
|
6 |
-
--DATA--
|
7 |
-
date_default_timezone_set('UTC');
|
8 |
-
return [
|
9 |
-
'date1' => '2010-10-04 13:45',
|
10 |
-
'date2' => new \DateTime('2010-10-04 13:45'),
|
11 |
-
]
|
12 |
-
--EXPECT--
|
13 |
-
2010-10-03 13:45:00
|
14 |
-
2010-10-03 13:45:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/date_namedargs.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date|date(format='d/m/Y H:i:s P', timezone='America/Chicago') }}
|
5 |
-
{{ date|date(timezone='America/Chicago', format='d/m/Y H:i:s P') }}
|
6 |
-
{{ date|date('d/m/Y H:i:s P', timezone='America/Chicago') }}
|
7 |
-
--DATA--
|
8 |
-
date_default_timezone_set('UTC');
|
9 |
-
return ['date' => mktime(13, 45, 0, 10, 4, 2010)]
|
10 |
-
--EXPECT--
|
11 |
-
04/10/2010 08:45:00 -05:00
|
12 |
-
04/10/2010 08:45:00 -05:00
|
13 |
-
04/10/2010 08:45:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/default.test
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"default" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
Variable:
|
5 |
-
{{ definedVar |default('default') is same as('default') ? 'ko' : 'ok' }}
|
6 |
-
{{ zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }}
|
7 |
-
{{ emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
8 |
-
{{ nullVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
9 |
-
{{ undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
10 |
-
Array access:
|
11 |
-
{{ nested.definedVar |default('default') is same as('default') ? 'ko' : 'ok' }}
|
12 |
-
{{ nested['definedVar'] |default('default') is same as('default') ? 'ko' : 'ok' }}
|
13 |
-
{{ nested.zeroVar |default('default') is same as('default') ? 'ko' : 'ok' }}
|
14 |
-
{{ nested.emptyVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
15 |
-
{{ nested.nullVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
16 |
-
{{ nested.undefinedVar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
17 |
-
{{ nested['undefinedVar'] |default('default') is same as('default') ? 'ok' : 'ko' }}
|
18 |
-
{{ undefinedVar.foo |default('default') is same as('default') ? 'ok' : 'ko' }}
|
19 |
-
Plain values:
|
20 |
-
{{ 'defined' |default('default') is same as('default') ? 'ko' : 'ok' }}
|
21 |
-
{{ 0 |default('default') is same as('default') ? 'ko' : 'ok' }}
|
22 |
-
{{ '' |default('default') is same as('default') ? 'ok' : 'ko' }}
|
23 |
-
{{ null |default('default') is same as('default') ? 'ok' : 'ko' }}
|
24 |
-
Precedence:
|
25 |
-
{{ 'o' ~ nullVar |default('k') }}
|
26 |
-
{{ 'o' ~ nested.nullVar |default('k') }}
|
27 |
-
Object methods:
|
28 |
-
{{ object.foo |default('default') is same as('default') ? 'ko' : 'ok' }}
|
29 |
-
{{ object.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }}
|
30 |
-
{{ object.getFoo() |default('default') is same as('default') ? 'ko' : 'ok' }}
|
31 |
-
{{ object.getFoo('a') |default('default') is same as('default') ? 'ko' : 'ok' }}
|
32 |
-
{{ object.undefinedMethod() |default('default') is same as('default') ? 'ok' : 'ko' }}
|
33 |
-
{{ object.undefinedMethod('a') |default('default') is same as('default') ? 'ok' : 'ko' }}
|
34 |
-
Deep nested:
|
35 |
-
{{ nested.undefinedVar.foo.bar |default('default') is same as('default') ? 'ok' : 'ko' }}
|
36 |
-
{{ nested.definedArray.0 |default('default') is same as('default') ? 'ko' : 'ok' }}
|
37 |
-
{{ nested['definedArray'][0] |default('default') is same as('default') ? 'ko' : 'ok' }}
|
38 |
-
{{ object.self.foo |default('default') is same as('default') ? 'ko' : 'ok' }}
|
39 |
-
{{ object.self.undefinedMethod |default('default') is same as('default') ? 'ok' : 'ko' }}
|
40 |
-
{{ object.undefinedMethod.self |default('default') is same as('default') ? 'ok' : 'ko' }}
|
41 |
-
--DATA--
|
42 |
-
return [
|
43 |
-
'definedVar' => 'defined',
|
44 |
-
'zeroVar' => 0,
|
45 |
-
'emptyVar' => '',
|
46 |
-
'nullVar' => null,
|
47 |
-
'nested' => [
|
48 |
-
'definedVar' => 'defined',
|
49 |
-
'zeroVar' => 0,
|
50 |
-
'emptyVar' => '',
|
51 |
-
'nullVar' => null,
|
52 |
-
'definedArray' => [0],
|
53 |
-
],
|
54 |
-
'object' => new Twig\Tests\TwigTestFoo(),
|
55 |
-
]
|
56 |
-
--CONFIG--
|
57 |
-
return ['strict_variables' => false]
|
58 |
-
--EXPECT--
|
59 |
-
Variable:
|
60 |
-
ok
|
61 |
-
ok
|
62 |
-
ok
|
63 |
-
ok
|
64 |
-
ok
|
65 |
-
Array access:
|
66 |
-
ok
|
67 |
-
ok
|
68 |
-
ok
|
69 |
-
ok
|
70 |
-
ok
|
71 |
-
ok
|
72 |
-
ok
|
73 |
-
ok
|
74 |
-
Plain values:
|
75 |
-
ok
|
76 |
-
ok
|
77 |
-
ok
|
78 |
-
ok
|
79 |
-
Precedence:
|
80 |
-
ok
|
81 |
-
ok
|
82 |
-
Object methods:
|
83 |
-
ok
|
84 |
-
ok
|
85 |
-
ok
|
86 |
-
ok
|
87 |
-
ok
|
88 |
-
ok
|
89 |
-
Deep nested:
|
90 |
-
ok
|
91 |
-
ok
|
92 |
-
ok
|
93 |
-
ok
|
94 |
-
ok
|
95 |
-
ok
|
96 |
-
--DATA--
|
97 |
-
return [
|
98 |
-
'definedVar' => 'defined',
|
99 |
-
'zeroVar' => 0,
|
100 |
-
'emptyVar' => '',
|
101 |
-
'nullVar' => null,
|
102 |
-
'nested' => [
|
103 |
-
'definedVar' => 'defined',
|
104 |
-
'zeroVar' => 0,
|
105 |
-
'emptyVar' => '',
|
106 |
-
'nullVar' => null,
|
107 |
-
'definedArray' => [0],
|
108 |
-
],
|
109 |
-
'object' => new Twig\Tests\TwigTestFoo(),
|
110 |
-
]
|
111 |
-
--CONFIG--
|
112 |
-
return ['strict_variables' => true]
|
113 |
-
--EXPECT--
|
114 |
-
Variable:
|
115 |
-
ok
|
116 |
-
ok
|
117 |
-
ok
|
118 |
-
ok
|
119 |
-
ok
|
120 |
-
Array access:
|
121 |
-
ok
|
122 |
-
ok
|
123 |
-
ok
|
124 |
-
ok
|
125 |
-
ok
|
126 |
-
ok
|
127 |
-
ok
|
128 |
-
ok
|
129 |
-
Plain values:
|
130 |
-
ok
|
131 |
-
ok
|
132 |
-
ok
|
133 |
-
ok
|
134 |
-
Precedence:
|
135 |
-
ok
|
136 |
-
ok
|
137 |
-
Object methods:
|
138 |
-
ok
|
139 |
-
ok
|
140 |
-
ok
|
141 |
-
ok
|
142 |
-
ok
|
143 |
-
ok
|
144 |
-
Deep nested:
|
145 |
-
ok
|
146 |
-
ok
|
147 |
-
ok
|
148 |
-
ok
|
149 |
-
ok
|
150 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/dynamic_filter.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
dynamic filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'bar'|foo_path }}
|
5 |
-
{{ 'bar'|a_foo_b_bar }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
foo/bar
|
10 |
-
a/b/bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/escape.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"escape" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "foo <br />"|e }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
foo <br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/escape_html_attr.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"escape" filter does not escape with the html strategy when using the html_attr strategy
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ '<br />'|escape('html_attr') }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/escape_javascript.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"escape" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "é ♜ 𝌆"|e('js') }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
\u00E9\u0020\u265C\u0020\uD834\uDF06
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/escape_non_supported_charset.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"escape" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "愛していますか? <br />"|e }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
愛していますか? <br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/filter.test
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set offset = 3 %}
|
5 |
-
|
6 |
-
{% for k, v in [1, 5, 3, 4, 5]|filter((v) => v > offset) -%}
|
7 |
-
{{ k }} = {{ v }}
|
8 |
-
{% endfor %}
|
9 |
-
|
10 |
-
{% for k, v in {a: 1, b: 2, c: 5, d: 8}|filter(v => v > offset) -%}
|
11 |
-
{{ k }} = {{ v }}
|
12 |
-
{% endfor %}
|
13 |
-
|
14 |
-
{% for k, v in [1, 5, 3, 4, 5]|filter(v => v > offset) -%}
|
15 |
-
{{ k }} = {{ v }}
|
16 |
-
{% endfor %}
|
17 |
-
|
18 |
-
{% for k, v in it|filter((v) => v > offset) -%}
|
19 |
-
{{ k }} = {{ v }}
|
20 |
-
{% endfor %}
|
21 |
-
|
22 |
-
{% for k, v in ita|filter(v => v > offset) -%}
|
23 |
-
{{ k }} = {{ v }}
|
24 |
-
{% endfor %}
|
25 |
-
--DATA--
|
26 |
-
return [
|
27 |
-
'it' => new \ArrayIterator(['a' => 1, 'b' => 2, 'c' => 5, 'd' => 8]),
|
28 |
-
'ita' => new Twig\Tests\IteratorAggregateStub(['a' => 1, 'b' => 2, 'c' => 5, 'd' => 8]),
|
29 |
-
]
|
30 |
-
--EXPECT--
|
31 |
-
1 = 5
|
32 |
-
3 = 4
|
33 |
-
4 = 5
|
34 |
-
|
35 |
-
c = 5
|
36 |
-
d = 8
|
37 |
-
|
38 |
-
1 = 5
|
39 |
-
3 = 4
|
40 |
-
4 = 5
|
41 |
-
|
42 |
-
c = 5
|
43 |
-
d = 8
|
44 |
-
|
45 |
-
c = 5
|
46 |
-
d = 8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/filter_php_55.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" filter (PHP 5.5 required)
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.5.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{% for k, v in xml|filter(x => true) %}
|
7 |
-
{{ k }}/{{ v }}
|
8 |
-
{% endfor %}
|
9 |
-
|
10 |
-
{# we can iterate more than once #}
|
11 |
-
{% for k, v in xml|filter(x => true) %}
|
12 |
-
{{ k }}/{{ v }}
|
13 |
-
{% endfor %}
|
14 |
-
--DATA--
|
15 |
-
return ['xml' => new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><doc><elem>foo</elem><elem>bar</elem><elem>baz</elem></doc>')]
|
16 |
-
--EXPECT--
|
17 |
-
elem/foo
|
18 |
-
elem/bar
|
19 |
-
elem/baz
|
20 |
-
|
21 |
-
elem/foo
|
22 |
-
elem/bar
|
23 |
-
elem/baz
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/filter_php_56.test
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" filter (PHP 5.6 required)
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.6.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{% set offset = 3 %}
|
7 |
-
|
8 |
-
{% for k, v in {a: 1, b: 2, c: 5, d: 8}|filter((v, k) => (v > offset) and (k != "d")) -%}
|
9 |
-
{{ k }} = {{ v }}
|
10 |
-
{% endfor %}
|
11 |
-
|
12 |
-
{% for k, v in it|filter((v, k) => (v > offset) and (k != "d")) -%}
|
13 |
-
{{ k }} = {{ v }}
|
14 |
-
{% endfor %}
|
15 |
-
|
16 |
-
{# we can iterate more than once #}
|
17 |
-
{% for k, v in it|filter((v, k) => (v > offset) and (k != "d")) -%}
|
18 |
-
{{ k }} = {{ v }}
|
19 |
-
{% endfor %}
|
20 |
-
--DATA--
|
21 |
-
return ['it' => new \ArrayIterator(['a' => 1, 'b' => 2, 'c' => 5, 'd' => 8])]
|
22 |
-
--EXPECT--
|
23 |
-
c = 5
|
24 |
-
|
25 |
-
c = 5
|
26 |
-
|
27 |
-
c = 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/first.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"first" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ [1, 2, 3, 4]|first }}
|
5 |
-
{{ {a: 1, b: 2, c: 3, d: 4}|first }}
|
6 |
-
{{ '1234'|first }}
|
7 |
-
{{ arr|first }}
|
8 |
-
{{ 'Ä€é'|first }}
|
9 |
-
{{ ''|first }}
|
10 |
-
--DATA--
|
11 |
-
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
|
12 |
-
--EXPECT--
|
13 |
-
1
|
14 |
-
1
|
15 |
-
1
|
16 |
-
1
|
17 |
-
Ä
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/force_escape.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"escape" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo %}
|
5 |
-
foo<br />
|
6 |
-
{% endset %}
|
7 |
-
|
8 |
-
{{ foo|e('html') -}}
|
9 |
-
{{ foo|e('js') }}
|
10 |
-
{% autoescape true %}
|
11 |
-
{{ foo }}
|
12 |
-
{% endautoescape %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
foo<br />
|
17 |
-
\u0020\u0020\u0020\u0020foo\u003Cbr\u0020\/\u003E\n
|
18 |
-
foo<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/format.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"format" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ string|format(foo, 3) }}
|
5 |
-
--DATA--
|
6 |
-
return ['string' => '%s/%d', 'foo' => 'bar']
|
7 |
-
--EXPECT--
|
8 |
-
bar/3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/join.test
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"join" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ ["foo", "bar"]|join(', ') }}
|
5 |
-
{{ foo|join(', ') }}
|
6 |
-
{{ bar|join(', ') }}
|
7 |
-
|
8 |
-
{{ ["foo", "bar"]|join(', ', ' and ') }}
|
9 |
-
{{ foo|join(', ', ' and ') }}
|
10 |
-
{{ bar|join(', ', ' and ') }}
|
11 |
-
{{ ["one", "two", "three"]|join(', ', ' and ') }}
|
12 |
-
{{ ["a", "b", "c"]|join('','-') }}
|
13 |
-
{{ ["a", "b", "c"]|join('-','-') }}
|
14 |
-
{{ ["a", "b", "c"]|join('-','') }}
|
15 |
-
{{ ["hello"]|join('|','-') }}
|
16 |
-
|
17 |
-
{{ {"a": "w", "b": "x", "c": "y", "d": "z"}|join }}
|
18 |
-
{{ {"a": "w", "b": "x", "c": "y", "d": "z"}|join(',') }}
|
19 |
-
{{ {"a": "w", "b": "x", "c": "y", "d": "z"}|join(',','-') }}
|
20 |
-
--DATA--
|
21 |
-
return ['foo' => new Twig\Tests\TwigTestFoo(), 'bar' => new \ArrayObject([3, 4])]
|
22 |
-
--EXPECT--
|
23 |
-
foo, bar
|
24 |
-
1, 2
|
25 |
-
3, 4
|
26 |
-
|
27 |
-
foo and bar
|
28 |
-
1 and 2
|
29 |
-
3 and 4
|
30 |
-
one, two and three
|
31 |
-
ab-c
|
32 |
-
a-b-c
|
33 |
-
a-bc
|
34 |
-
hello
|
35 |
-
|
36 |
-
wxyz
|
37 |
-
w,x,y,z
|
38 |
-
w,x,y-z
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/json_encode.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"json_encode" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "foo"|json_encode|raw }}
|
5 |
-
{{ foo|json_encode|raw }}
|
6 |
-
{{ [foo, "foo"]|json_encode|raw }}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => new \Twig\Markup('foo', 'UTF-8')]
|
9 |
-
--EXPECT--
|
10 |
-
"foo"
|
11 |
-
"foo"
|
12 |
-
["foo","foo"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/last.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"last" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ [1, 2, 3, 4]|last }}
|
5 |
-
{{ {a: 1, b: 2, c: 3, d: 4}|last }}
|
6 |
-
{{ '1234'|last }}
|
7 |
-
{{ arr|last }}
|
8 |
-
{{ 'Ä€é'|last }}
|
9 |
-
{{ ''|last }}
|
10 |
-
--DATA--
|
11 |
-
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
|
12 |
-
--EXPECT--
|
13 |
-
4
|
14 |
-
4
|
15 |
-
4
|
16 |
-
4
|
17 |
-
é
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/length.test
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"length" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ array|length }}
|
5 |
-
{{ string|length }}
|
6 |
-
{{ number|length }}
|
7 |
-
{{ to_string_able|length }}
|
8 |
-
{{ countable|length }}
|
9 |
-
{{ iterator_aggregate|length }}
|
10 |
-
{{ null|length }}
|
11 |
-
{{ magic|length }}
|
12 |
-
{{ non_countable|length }}
|
13 |
-
{{ simple_xml_element|length }}
|
14 |
-
{{ iterator|length }}
|
15 |
-
--DATA--
|
16 |
-
return [
|
17 |
-
'array' => [1, 4],
|
18 |
-
'string' => 'foo',
|
19 |
-
'number' => 1000,
|
20 |
-
'to_string_able' => new Twig\Tests\ToStringStub('foobar'),
|
21 |
-
'countable' => new Twig\Tests\CountableStub(42), /* also asserts we do *not* call __toString() */
|
22 |
-
'iterator_aggregate' => new Twig\Tests\IteratorAggregateStub(['a', 'b', 'c']), /* also asserts we do *not* call __toString() */
|
23 |
-
'null' => null,
|
24 |
-
'magic' => new Twig\Tests\MagicCallStub(), /* used to assert we do *not* call __call */
|
25 |
-
'non_countable' => new \StdClass(),
|
26 |
-
'simple_xml_element' => new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><doc><elem/><elem/></doc>'),
|
27 |
-
'iterator' => new Twig\Tests\SimpleIteratorForTesting()
|
28 |
-
]
|
29 |
-
--EXPECT--
|
30 |
-
2
|
31 |
-
3
|
32 |
-
4
|
33 |
-
6
|
34 |
-
42
|
35 |
-
3
|
36 |
-
0
|
37 |
-
1
|
38 |
-
1
|
39 |
-
2
|
40 |
-
7
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/length_utf8.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"length" filter
|
3 |
-
--CONDITION--
|
4 |
-
function_exists('mb_get_info')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ string|length }}
|
7 |
-
{{ markup|length }}
|
8 |
-
--DATA--
|
9 |
-
return ['string' => 'été', 'markup' => new \Twig\Markup('foo', 'UTF-8')]
|
10 |
-
--EXPECT--
|
11 |
-
3
|
12 |
-
3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/map.test
DELETED
@@ -1,41 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"map" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set offset = 3 %}
|
5 |
-
|
6 |
-
{% for k, v in [1, 2]|map((item) => item + 2 ) -%}
|
7 |
-
{{ k }} = {{ v }}
|
8 |
-
{% endfor %}
|
9 |
-
|
10 |
-
{% for k, v in {a: 1, b: 2}|map((item) => item ~ "*" ) -%}
|
11 |
-
{{ k }} = {{ v }}
|
12 |
-
{% endfor %}
|
13 |
-
|
14 |
-
{% for k, v in {a: 1, b: 2}|map((item, k) => item ~ "*" ~ k ) -%}
|
15 |
-
{{ k }} = {{ v }}
|
16 |
-
{% endfor %}
|
17 |
-
|
18 |
-
{% for k, v in [1, 2]|map(item => item + 2 ) -%}
|
19 |
-
{{ k }} = {{ v }}
|
20 |
-
{% endfor %}
|
21 |
-
|
22 |
-
{% for k, v in it|map(item => item + 2 ) -%}
|
23 |
-
{{ k }} = {{ v }}
|
24 |
-
{% endfor %}
|
25 |
-
--DATA--
|
26 |
-
return ['it' => new \ArrayIterator([1, 2])]
|
27 |
-
--EXPECT--
|
28 |
-
0 = 3
|
29 |
-
1 = 4
|
30 |
-
|
31 |
-
a = 1*
|
32 |
-
b = 2*
|
33 |
-
|
34 |
-
a = 1*a
|
35 |
-
b = 2*b
|
36 |
-
|
37 |
-
0 = 3
|
38 |
-
1 = 4
|
39 |
-
|
40 |
-
0 = 3
|
41 |
-
1 = 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/merge.test
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"merge" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ items|merge({'bar': 'foo'})|join }}
|
5 |
-
{{ items|merge({'bar': 'foo'})|keys|join }}
|
6 |
-
{{ {'bar': 'foo'}|merge(items)|join }}
|
7 |
-
{{ {'bar': 'foo'}|merge(items)|keys|join }}
|
8 |
-
{{ numerics|merge([4, 5, 6])|join }}
|
9 |
-
{{ traversable.a|merge(traversable.b)|join }}
|
10 |
-
--DATA--
|
11 |
-
return [
|
12 |
-
'items' => ['foo' => 'bar'],
|
13 |
-
'numerics' => [1, 2, 3],
|
14 |
-
'traversable' => [
|
15 |
-
'a' => new \ArrayObject([0 => 1, 1 => 2, 2 => 3]),
|
16 |
-
'b' => new \ArrayObject(['a' => 'b'])
|
17 |
-
]
|
18 |
-
]
|
19 |
-
--EXPECT--
|
20 |
-
barfoo
|
21 |
-
foobar
|
22 |
-
foobar
|
23 |
-
barfoo
|
24 |
-
123456
|
25 |
-
123b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/nl2br.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"nl2br" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "I like Twig.\nYou will like it too.\n\nEverybody like it!"|nl2br }}
|
5 |
-
{{ text|nl2br }}
|
6 |
-
--DATA--
|
7 |
-
return ['text' => "If you have some <strong>HTML</strong>\nit will be escaped."]
|
8 |
-
--EXPECT--
|
9 |
-
I like Twig.<br />
|
10 |
-
You will like it too.<br />
|
11 |
-
<br />
|
12 |
-
Everybody like it!
|
13 |
-
If you have some <strong>HTML</strong><br />
|
14 |
-
it will be escaped.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/number_format.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"number_format" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 20|number_format }}
|
5 |
-
{{ 20.25|number_format }}
|
6 |
-
{{ 20.25|number_format(2) }}
|
7 |
-
{{ 20.25|number_format(2, ',') }}
|
8 |
-
{{ 1020.25|number_format(2, ',') }}
|
9 |
-
{{ 1020.25|number_format(2, ',', '.') }}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
20
|
14 |
-
20
|
15 |
-
20.25
|
16 |
-
20,25
|
17 |
-
1,020,25
|
18 |
-
1.020,25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/number_format_default.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"number_format" filter with defaults.
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 20|number_format }}
|
5 |
-
{{ 20.25|number_format }}
|
6 |
-
{{ 20.25|number_format(1) }}
|
7 |
-
{{ 20.25|number_format(2, ',') }}
|
8 |
-
{{ 1020.25|number_format }}
|
9 |
-
{{ 1020.25|number_format(2, ',') }}
|
10 |
-
{{ 1020.25|number_format(2, ',', '.') }}
|
11 |
-
--DATA--
|
12 |
-
$twig->getExtension('\Twig\Extension\CoreExtension')->setNumberFormat(2, '!', '=');
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
20!00
|
16 |
-
20!25
|
17 |
-
20!3
|
18 |
-
20,25
|
19 |
-
1=020!25
|
20 |
-
1=020,25
|
21 |
-
1.020,25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/reduce.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"reduce" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set offset = 3 %}
|
5 |
-
|
6 |
-
{{ [1, -1, 4]|reduce((carry, item) => carry + item + offset, 10) }}
|
7 |
-
|
8 |
-
{{ it|reduce((carry, item) => carry + item + offset, 10) }}
|
9 |
-
--DATA--
|
10 |
-
return ['it' => new \ArrayIterator([1, -1, 4])]
|
11 |
-
--EXPECT--
|
12 |
-
23
|
13 |
-
|
14 |
-
23
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/replace.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"replace" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "I liké %this% and %that%."|replace({'%this%': "foo", '%that%': "bar"}) }}
|
5 |
-
{{ 'I like single replace operation only %that%'|replace({'%that%' : '%that%1'}) }}
|
6 |
-
{{ 'I like %this% and %that%.'|replace(traversable) }}
|
7 |
-
--DATA--
|
8 |
-
return ['traversable' => new \ArrayObject(['%this%' => 'foo', '%that%' => 'bar'])]
|
9 |
-
--EXPECT--
|
10 |
-
I liké foo and bar.
|
11 |
-
I like single replace operation only %that%1
|
12 |
-
I like foo and bar.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/replace_invalid_arg.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception for invalid argument type in replace call
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'test %foo%'|replace(stdClass) }}
|
5 |
-
--DATA--
|
6 |
-
return ['stdClass' => new \stdClass()]
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\RuntimeError: The "replace" filter expects an array or "Traversable" as replace values, got "stdClass" in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/reverse.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"reverse" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ [1, 2, 3, 4]|reverse|join('') }}
|
5 |
-
{{ '1234évènement'|reverse }}
|
6 |
-
{{ arr|reverse|join('') }}
|
7 |
-
{{ {'a': 'c', 'b': 'a'}|reverse()|join(',') }}
|
8 |
-
{{ {'a': 'c', 'b': 'a'}|reverse(preserveKeys=true)|join(glue=',') }}
|
9 |
-
{{ {'a': 'c', 'b': 'a'}|reverse(preserve_keys=true)|join(glue=',') }}
|
10 |
-
--DATA--
|
11 |
-
return ['arr' => new \ArrayObject([1, 2, 3, 4])]
|
12 |
-
--EXPECT--
|
13 |
-
4321
|
14 |
-
tnemenèvé4321
|
15 |
-
4321
|
16 |
-
a,c
|
17 |
-
a,c
|
18 |
-
a,c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/round.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"round" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 2.7|round }}
|
5 |
-
{{ 2.1|round }}
|
6 |
-
{{ 2.1234|round(3, 'floor') }}
|
7 |
-
{{ 2.1|round(0, 'ceil') }}
|
8 |
-
|
9 |
-
{{ 21.3|round(-1)}}
|
10 |
-
{{ 21.3|round(-1, 'ceil')}}
|
11 |
-
{{ 21.3|round(-1, 'floor')}}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
3
|
16 |
-
2
|
17 |
-
2.123
|
18 |
-
3
|
19 |
-
|
20 |
-
20
|
21 |
-
30
|
22 |
-
20
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/slice.test
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"slice" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ [1, 2, 3, 4][1:2]|join('') }}
|
5 |
-
{{ {a: 1, b: 2, c: 3, d: 4}[1:2]|join('') }}
|
6 |
-
{{ [1, 2, 3, 4][start:length]|join('') }}
|
7 |
-
{{ [1, 2, 3, 4]|slice(1, 2)|join('') }}
|
8 |
-
{{ [1, 2, 3, 4]|slice(1, 2)|keys|join('') }}
|
9 |
-
{{ [1, 2, 3, 4]|slice(1, 2, true)|keys|join('') }}
|
10 |
-
{{ {a: 1, b: 2, c: 3, d: 4}|slice(1, 2)|join('') }}
|
11 |
-
{{ {a: 1, b: 2, c: 3, d: 4}|slice(1, 2)|keys|join('') }}
|
12 |
-
{{ '1234'|slice(1, 2) }}
|
13 |
-
{{ '1234'[1:2] }}
|
14 |
-
{{ arr|slice(1, 2)|join('') }}
|
15 |
-
{{ arr[1:2]|join('') }}
|
16 |
-
{{ arr[4:1]|join('') }}
|
17 |
-
{{ arr[3:2]|join('') }}
|
18 |
-
|
19 |
-
{{ [1, 2, 3, 4]|slice(1)|join('') }}
|
20 |
-
{{ [1, 2, 3, 4][1:]|join('') }}
|
21 |
-
{{ '1234'|slice(1) }}
|
22 |
-
{{ '1234'[1:] }}
|
23 |
-
{{ '1234'[:1] }}
|
24 |
-
|
25 |
-
{{ arr|slice(3)|join('') }}
|
26 |
-
{{ arr[2:]|join('') }}
|
27 |
-
{{ xml|slice(1)|join('')}}
|
28 |
-
--DATA--
|
29 |
-
return ['start' => 1, 'length' => 2, 'arr' => new \ArrayObject([1, 2, 3, 4]), 'xml' => new \SimpleXMLElement('<items><item>1</item><item>2</item></items>')]
|
30 |
-
--EXPECT--
|
31 |
-
23
|
32 |
-
23
|
33 |
-
23
|
34 |
-
23
|
35 |
-
01
|
36 |
-
12
|
37 |
-
23
|
38 |
-
bc
|
39 |
-
23
|
40 |
-
23
|
41 |
-
23
|
42 |
-
23
|
43 |
-
|
44 |
-
4
|
45 |
-
|
46 |
-
234
|
47 |
-
234
|
48 |
-
234
|
49 |
-
234
|
50 |
-
1
|
51 |
-
|
52 |
-
4
|
53 |
-
34
|
54 |
-
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/sort.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"sort" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ array1|sort|join }}
|
5 |
-
{{ array2|sort|join }}
|
6 |
-
{{ traversable|sort|join }}
|
7 |
-
--DATA--
|
8 |
-
return ['array1' => [4, 1], 'array2' => ['foo', 'bar'], 'traversable' => new \ArrayObject([0 => 3, 1 => 2, 2 => 1])]
|
9 |
-
--EXPECT--
|
10 |
-
14
|
11 |
-
barfoo
|
12 |
-
123
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/spaceless.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"spaceless" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ " <div> <div> foo </div> </div>"|spaceless }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
<div><div> foo </div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/special_chars.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"§" custom filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo'|§ }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
§foo§
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/split.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"split" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ "one,two,three,four,five"|split(',')|join('-') }}
|
5 |
-
{{ foo|split(',')|join('-') }}
|
6 |
-
{{ foo|split(',', 3)|join('-') }}
|
7 |
-
{{ baz|split('')|join('-') }}
|
8 |
-
{{ baz|split('', 1)|join('-') }}
|
9 |
-
{{ baz|split('', 2)|join('-') }}
|
10 |
-
{{ foo|split(',', -2)|join('-') }}
|
11 |
-
{{ "hello0world"|split('0')|join('-') }}
|
12 |
-
--DATA--
|
13 |
-
return ['foo' => "one,two,three,four,five", 'baz' => '12345',]
|
14 |
-
--EXPECT--
|
15 |
-
one-two-three-four-five
|
16 |
-
one-two-three-four-five
|
17 |
-
one-two-three,four,five
|
18 |
-
1-2-3-4-5
|
19 |
-
1-2-3-4-5
|
20 |
-
12-34-5
|
21 |
-
one-two-three
|
22 |
-
hello-world
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/split_utf8.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"split" filter
|
3 |
-
--CONDITION--
|
4 |
-
function_exists('mb_get_info')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ "é"|split('', 10)|join('-') }}
|
7 |
-
{{ foo|split(',')|join('-') }}
|
8 |
-
{{ foo|split(',', 1)|join('-') }}
|
9 |
-
{{ foo|split(',', 2)|join('-') }}
|
10 |
-
{{ foo|split(',', 3)|join('-') }}
|
11 |
-
{{ baz|split('')|join('-') }}
|
12 |
-
{{ baz|split('', 1)|join('-') }}
|
13 |
-
{{ baz|split('', 2)|join('-') }}
|
14 |
-
--DATA--
|
15 |
-
return ['foo' => 'Ä,é,Äほ', 'baz' => 'éÄßごa',]
|
16 |
-
--EXPECT--
|
17 |
-
é
|
18 |
-
Ä-é-Äほ
|
19 |
-
Ä,é,Äほ
|
20 |
-
Ä-é,Äほ
|
21 |
-
Ä-é-Äほ
|
22 |
-
é-Ä-ß-ご-a
|
23 |
-
é-Ä-ß-ご-a
|
24 |
-
éÄ-ßご-a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/static_calls.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Filters as static method calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo'|static_call_string }}
|
5 |
-
{{ 'foo'|static_call_array }}
|
6 |
-
--DATA--
|
7 |
-
return ['foo' => 'foo']
|
8 |
-
--EXPECT--
|
9 |
-
*foo*
|
10 |
-
*foo*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/trim.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"trim" filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ " I like Twig. "|trim }}
|
5 |
-
{{ text|trim }}
|
6 |
-
{{ " foo/"|trim("/") }}
|
7 |
-
{{ "xxxI like Twig.xxx"|trim(character_mask="x", side="left") }}
|
8 |
-
{{ "xxxI like Twig.xxx"|trim(side="right", character_mask="x") }}
|
9 |
-
{{ "xxxI like Twig.xxx"|trim("x", "right") }}
|
10 |
-
{{ "/ foo/"|trim("/", "left") }}
|
11 |
-
{{ "/ foo/"|trim(character_mask="/", side="left") }}
|
12 |
-
{{ " do nothing. "|trim("", "right") }}
|
13 |
-
--DATA--
|
14 |
-
return ['text' => " If you have some <strong>HTML</strong> it will be escaped. "]
|
15 |
-
--EXPECT--
|
16 |
-
I like Twig.
|
17 |
-
If you have some <strong>HTML</strong> it will be escaped.
|
18 |
-
foo
|
19 |
-
I like Twig.xxx
|
20 |
-
xxxI like Twig.
|
21 |
-
xxxI like Twig.
|
22 |
-
foo/
|
23 |
-
foo/
|
24 |
-
do nothing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/urlencode.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"url_encode" filter
|
3 |
-
--CONDITION--
|
4 |
-
defined('PHP_QUERY_RFC3986')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
|
7 |
-
{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
|
8 |
-
{{ {}|url_encode|default("default") }}
|
9 |
-
{{ 'spéßi%le%c0d@dspa ce'|url_encode }}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
|
14 |
-
foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
|
15 |
-
default
|
16 |
-
sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/filters/urlencode_deprecated.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"url_encode" filter for PHP < 5.4
|
3 |
-
--CONDITION--
|
4 |
-
defined('PHP_QUERY_RFC3986')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode }}
|
7 |
-
{{ {foo: "bar", number: 3, "spéßi%l": "e%c0d@d", "spa ce": ""}|url_encode|raw }}
|
8 |
-
{{ {}|url_encode|default("default") }}
|
9 |
-
{{ 'spéßi%le%c0d@dspa ce'|url_encode }}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
|
14 |
-
foo=bar&number=3&sp%C3%A9%C3%9Fi%25l=e%25c0d%40d&spa%20ce=
|
15 |
-
default
|
16 |
-
sp%C3%A9%C3%9Fi%25le%25c0d%40dspa%20ce
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/attribute.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"attribute" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ attribute(obj, method) }}
|
5 |
-
{{ attribute(array, item) }}
|
6 |
-
{{ attribute(obj, "bar", ["a", "b"]) }}
|
7 |
-
{{ attribute(obj, "bar", arguments) }}
|
8 |
-
{{ attribute(obj, method) is defined ? 'ok' : 'ko' }}
|
9 |
-
{{ attribute(obj, nonmethod) is defined ? 'ok' : 'ko' }}
|
10 |
-
--DATA--
|
11 |
-
return ['obj' => new Twig\Tests\TwigTestFoo(), 'method' => 'foo', 'array' => ['foo' => 'bar'], 'item' => 'foo', 'nonmethod' => 'xxx', 'arguments' => ['a', 'b']]
|
12 |
-
--EXPECT--
|
13 |
-
foo
|
14 |
-
bar
|
15 |
-
bar_a-b
|
16 |
-
bar_a-b
|
17 |
-
ok
|
18 |
-
ko
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/block.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'base.twig' %}
|
5 |
-
{% block bar %}BAR{% endblock %}
|
6 |
-
--TEMPLATE(base.twig)--
|
7 |
-
{% block foo %}{{ block('bar') }}{% endblock %}
|
8 |
-
{% block bar %}BAR_BASE{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
BARBAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/block_with_template.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" function with a template argument
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ block('foo', 'included.twig') }}
|
5 |
-
{{ block('foo', included_loaded) }}
|
6 |
-
{{ block('foo', included_loaded_internal) }}
|
7 |
-
{% set output = block('foo', 'included.twig') %}
|
8 |
-
{{ output }}
|
9 |
-
{% block foo %}NOT FOO{% endblock %}
|
10 |
-
--TEMPLATE(included.twig)--
|
11 |
-
{% block foo %}FOO{% endblock %}
|
12 |
-
--DATA--
|
13 |
-
return [
|
14 |
-
'included_loaded' => $twig->load('included.twig'),
|
15 |
-
'included_loaded_internal' => $twig->load('included.twig'),
|
16 |
-
]
|
17 |
-
--EXPECT--
|
18 |
-
FOO
|
19 |
-
FOO
|
20 |
-
FOO
|
21 |
-
FOO
|
22 |
-
NOT FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/block_without_name.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" function without arguments
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'base.twig' %}
|
5 |
-
{% block bar %}BAR{% endblock %}
|
6 |
-
--TEMPLATE(base.twig)--
|
7 |
-
{% block foo %}{{ block() }}{% endblock %}
|
8 |
-
{% block bar %}BAR_BASE{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXCEPTION--
|
12 |
-
Twig\Error\SyntaxError: The "block" function takes one argument (the block name) in "base.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/constant.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"constant" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ constant('DATE_W3C') == expect ? 'true' : 'false' }}
|
5 |
-
{{ constant('ARRAY_AS_PROPS', object) }}
|
6 |
-
--DATA--
|
7 |
-
return ['expect' => DATE_W3C, 'object' => new \ArrayObject(['hi'])]
|
8 |
-
--EXPECT--
|
9 |
-
true
|
10 |
-
2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/cycle.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"cycle" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i in 0..6 %}
|
5 |
-
{{ cycle(array1, i) }}-{{ cycle(array2, i) }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['array1' => ['odd', 'even'], 'array2' => ['apple', 'orange', 'citrus']]
|
9 |
-
--EXPECT--
|
10 |
-
odd-apple
|
11 |
-
even-orange
|
12 |
-
odd-citrus
|
13 |
-
even-apple
|
14 |
-
odd-orange
|
15 |
-
even-citrus
|
16 |
-
odd-apple
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/date.test
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date().format('r') == date('now').format('r') ? 'OK' : 'KO' }}
|
5 |
-
{{ date(date1) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
|
6 |
-
{{ date(date2) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
|
7 |
-
{{ date(date3) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
|
8 |
-
{{ date(date4) == date('2010-10-04 13:45') ? 'OK' : 'KO' }}
|
9 |
-
{{ date(date5) == date('1964-01-02 03:04') ? 'OK' : 'KO' }}
|
10 |
-
{{ date() > date('-1day') ? 'OK' : 'KO' }}
|
11 |
-
--DATA--
|
12 |
-
date_default_timezone_set('UTC');
|
13 |
-
return [
|
14 |
-
'date1' => mktime(13, 45, 0, 10, 4, 2010),
|
15 |
-
'date2' => new \DateTime('2010-10-04 13:45'),
|
16 |
-
'date3' => '2010-10-04 13:45',
|
17 |
-
'date4' => 1286199900, // \DateTime::createFromFormat('Y-m-d H:i', '2010-10-04 13:45', new \DateTimeZone('UTC'))->getTimestamp() -- A unixtimestamp is always GMT
|
18 |
-
'date5' => -189291360, // \DateTime::createFromFormat('Y-m-d H:i', '1964-01-02 03:04', new \DateTimeZone('UTC'))->getTimestamp(),
|
19 |
-
]
|
20 |
-
--EXPECT--
|
21 |
-
OK
|
22 |
-
OK
|
23 |
-
OK
|
24 |
-
OK
|
25 |
-
OK
|
26 |
-
OK
|
27 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/date_namedargs.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"date" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ date(date, "America/New_York")|date('d/m/Y H:i:s P', false) }}
|
5 |
-
{{ date(timezone="America/New_York", date=date)|date('d/m/Y H:i:s P', false) }}
|
6 |
-
--DATA--
|
7 |
-
date_default_timezone_set('UTC');
|
8 |
-
return ['date' => mktime(13, 45, 0, 10, 4, 2010)]
|
9 |
-
--EXPECT--
|
10 |
-
04/10/2010 09:45:00 -04:00
|
11 |
-
04/10/2010 09:45:00 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/dump.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"dump" function
|
3 |
-
--CONDITION--
|
4 |
-
!extension_loaded('xdebug')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ dump('foo') }}
|
7 |
-
{{ dump('foo', 'bar') }}
|
8 |
-
--DATA--
|
9 |
-
return ['foo' => 'foo', 'bar' => 'bar']
|
10 |
-
--CONFIG--
|
11 |
-
return ['debug' => true, 'autoescape' => false]
|
12 |
-
--EXPECT--
|
13 |
-
string(3) "foo"
|
14 |
-
|
15 |
-
string(3) "foo"
|
16 |
-
string(3) "bar"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/dump_array.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"dump" function, xdebug is not loaded or xdebug <2.2-dev is loaded
|
3 |
-
--CONDITION--
|
4 |
-
!extension_loaded('xdebug') || (($r = new \ReflectionExtension('xdebug')) && version_compare($r->getVersion(), '2.2-dev', '<'))
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ dump() }}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => 'foo', 'bar' => 'bar']
|
9 |
-
--CONFIG--
|
10 |
-
return ['debug' => true, 'autoescape' => false]
|
11 |
-
--EXPECT--
|
12 |
-
array(3) {
|
13 |
-
["foo"]=>
|
14 |
-
string(3) "foo"
|
15 |
-
["bar"]=>
|
16 |
-
string(3) "bar"
|
17 |
-
["global"]=>
|
18 |
-
string(6) "global"
|
19 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/dynamic_function.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
dynamic function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ foo_path('bar') }}
|
5 |
-
{{ a_foo_b_bar('bar') }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
foo/bar
|
10 |
-
a/b/bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/assignment.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set tmp = include("foo.twig") %}
|
5 |
-
|
6 |
-
FOO{{ tmp }}BAR
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
FOOBAR
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
FOO
|
13 |
-
FOOBARBAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/autoescaping.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function is safe for auto-escaping
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig") }}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
<p>Test</p>
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
<p>Test</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/basic.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{{ include("foo.twig") }}
|
6 |
-
|
7 |
-
BAR
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
FOOBAR
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
FOO
|
14 |
-
|
15 |
-
FOOBAR
|
16 |
-
|
17 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/expression.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function allows expressions for the template to include
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{{ include(foo) }}
|
6 |
-
|
7 |
-
BAR
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
FOOBAR
|
10 |
-
--DATA--
|
11 |
-
return ['foo' => 'foo.twig']
|
12 |
-
--EXPECT--
|
13 |
-
FOO
|
14 |
-
|
15 |
-
FOOBAR
|
16 |
-
|
17 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/ignore_missing.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include(["foo.twig", "bar.twig"], ignore_missing = true) }}
|
5 |
-
{{ include("foo.twig", ignore_missing = true) }}
|
6 |
-
{{ include("foo.twig", ignore_missing = true, variables = {}) }}
|
7 |
-
{{ include("foo.twig", ignore_missing = true, variables = {}, with_context = true) }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/ignore_missing_exists.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("included.twig", ignore_missing = true) }}
|
5 |
-
NOT DISPLAYED
|
6 |
-
--TEMPLATE(included.twig)--
|
7 |
-
{{ include("DOES NOT EXIST") }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXCEPTION--
|
11 |
-
Twig\Error\LoaderError: Template "DOES NOT EXIST" is not defined in "included.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/include_missing_extends.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include(['bad.twig', 'good.twig'], ignore_missing = true) }}
|
5 |
-
NOT DISPLAYED
|
6 |
-
--TEMPLATE(bad.twig)--
|
7 |
-
{% extends 'DOES NOT EXIST' %}
|
8 |
-
--TEMPLATE(good.twig)--
|
9 |
-
NOT DISPLAYED
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXCEPTION--
|
13 |
-
Twig\Error\LoaderError: Template "DOES NOT EXIST" is not defined in "bad.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/missing.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig") }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\LoaderError: Template "foo.twig" is not defined in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/missing_nested.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{{ parent() }}
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(base.twig)--
|
10 |
-
{% block content %}
|
11 |
-
{{ include("foo.twig") }}
|
12 |
-
{% endblock %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXCEPTION--
|
16 |
-
Twig\Error\LoaderError: Template "foo.twig" is not defined in "base.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/sandbox.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag sandboxed
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig", sandboxed = true) }}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
|
7 |
-
|
8 |
-
{{ foo|e }}
|
9 |
-
{{ foo|e }}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXCEPTION--
|
13 |
-
Twig\Sandbox\SecurityNotAllowedFilterError: Filter "e" is not allowed in "foo.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/sandbox_disabling.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag sandboxed
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig", sandboxed = true) }}
|
5 |
-
{{ include("bar.twig") }}
|
6 |
-
--TEMPLATE(foo.twig)--
|
7 |
-
foo
|
8 |
-
--TEMPLATE(bar.twig)--
|
9 |
-
{{ foo|e }}
|
10 |
-
--DATA--
|
11 |
-
return ['foo' => 'bar<br />']
|
12 |
-
--EXPECT--
|
13 |
-
foo
|
14 |
-
|
15 |
-
|
16 |
-
bar<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag sandboxed
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("unknown.twig", sandboxed = true, ignore_missing = true) }}
|
5 |
-
{{ include("bar.twig") }}
|
6 |
-
--TEMPLATE(bar.twig)--
|
7 |
-
{{ foo|e }}
|
8 |
-
--DATA--
|
9 |
-
return ['foo' => 'bar<br />']
|
10 |
-
--EXPECT--
|
11 |
-
|
12 |
-
|
13 |
-
bar<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/template_instance.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function accepts Twig_Template instance
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include(foo) }} FOO
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
BAR
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => $twig->load('foo.twig')]
|
9 |
-
--EXPECT--
|
10 |
-
BAR FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/templates_as_array.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include(["foo.twig", "bar.twig"]) }}
|
5 |
-
{{- include(["bar.twig", "foo.twig"]) }}
|
6 |
-
--TEMPLATE(foo.twig)--
|
7 |
-
foo
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
foo
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/with_context.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function accept variables and with_context
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig") }}
|
5 |
-
{{- include("foo.twig", with_context = false) }}
|
6 |
-
{{- include("foo.twig", {'foo1': 'bar'}) }}
|
7 |
-
{{- include("foo.twig", {'foo1': 'bar'}, with_context = false) }}
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
{% for k, v in _context %}{{ k }},{% endfor %}
|
10 |
-
--DATA--
|
11 |
-
return ['foo' => 'bar']
|
12 |
-
--EXPECT--
|
13 |
-
foo,global,_parent,
|
14 |
-
global,_parent,
|
15 |
-
foo,global,foo1,_parent,
|
16 |
-
foo1,global,_parent,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include/with_variables.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" function accept variables
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ include("foo.twig", {'foo': 'bar'}) }}
|
5 |
-
{{- include("foo.twig", vars) }}
|
6 |
-
--TEMPLATE(foo.twig)--
|
7 |
-
{{ foo }}
|
8 |
-
--DATA--
|
9 |
-
return ['vars' => ['foo' => 'bar']]
|
10 |
-
--EXPECT--
|
11 |
-
bar
|
12 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/include_template_from_string.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"template_from_string" function works in an "include"
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set embed = '{% embed "embed.twig" %}{% endembed %}' %}
|
5 |
-
{{ include(template_from_string(embed)) }}
|
6 |
-
--TEMPLATE(embed.twig)--
|
7 |
-
Cool
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
Cool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/magic_call.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
__call calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo'|magic_call }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
magic_foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/magic_call53.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
__staticCall calls
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.3.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
{{ 'foo'|magic_call_string }}
|
7 |
-
{{ 'foo'|magic_call_array }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
static_magic_foo
|
12 |
-
static_magic_foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/max.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"max" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ max([2, 1, 3, 5, 4]) }}
|
5 |
-
{{ max(2, 1, 3, 5, 4) }}
|
6 |
-
{{ max({2:"two", 1:"one", 3:"three", 5:"five", 4:"for"}) }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
5
|
11 |
-
5
|
12 |
-
two
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/min.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"min" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ min(2, 1, 3, 5, 4) }}
|
5 |
-
{{ min([2, 1, 3, 5, 4]) }}
|
6 |
-
{{ min({2:"two", 1:"one", 3:"three", 5:"five", 4:"for"}) }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
1
|
11 |
-
1
|
12 |
-
five
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/range.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"range" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ range(low=0+1, high=10+0, step=2)|join(',') }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
1,3,5,7,9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/recursive_block_with_inheritance.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" function recursively called in a parent template
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "ordered_menu.twig" %}
|
5 |
-
{% block label %}"{{ parent() }}"{% endblock %}
|
6 |
-
{% block list %}{% set class = 'b' %}{{ parent() }}{% endblock %}
|
7 |
-
--TEMPLATE(ordered_menu.twig)--
|
8 |
-
{% extends "menu.twig" %}
|
9 |
-
{% block list %}{% set class = class|default('a') %}<ol class="{{ class }}">{{ block('children') }}</ol>{% endblock %}
|
10 |
-
--TEMPLATE(menu.twig)--
|
11 |
-
{% extends "base.twig" %}
|
12 |
-
{% block list %}<ul>{{ block('children') }}</ul>{% endblock %}
|
13 |
-
{% block children %}{% set currentItem = item %}{% for item in currentItem %}{{ block('item') }}{% endfor %}{% set item = currentItem %}{% endblock %}
|
14 |
-
{% block item %}<li>{% if item is not iterable %}{{ block('label') }}{% else %}{{ block('list') }}{% endif %}</li>{% endblock %}
|
15 |
-
{% block label %}{{ item }}{% endblock %}
|
16 |
-
--TEMPLATE(base.twig)--
|
17 |
-
{{ block('list') }}
|
18 |
-
--DATA--
|
19 |
-
return ['item' => ['1', '2', ['3.1', ['3.2.1', '3.2.2'], '3.4']]]
|
20 |
-
--EXPECT--
|
21 |
-
<ol class="b"><li>"1"</li><li>"2"</li><li><ol class="b"><li>"3.1"</li><li><ol class="b"><li>"3.2.1"</li><li>"3.2.2"</li></ol></li><li>"3.4"</li></ol></li></ol>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/source.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"source" function
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{{ source("foo.twig") }}
|
6 |
-
|
7 |
-
BAR
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
{{ foo }}<br />
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
FOO
|
14 |
-
|
15 |
-
{{ foo }}<br />
|
16 |
-
|
17 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/special_chars.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"§" custom function
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ §('foo') }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
§foo§
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/static_calls.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Functions as static method calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ static_call_string('foo') }}
|
5 |
-
{{ static_call_array('foo') }}
|
6 |
-
--DATA--
|
7 |
-
return ['foo' => 'foo']
|
8 |
-
--EXPECT--
|
9 |
-
*foo*
|
10 |
-
*foo*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/template_from_string.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"template_from_string" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include template_from_string(template) %}
|
5 |
-
|
6 |
-
{% include template_from_string("Hello {{ name }}") %}
|
7 |
-
{% include template_from_string('{% extends "parent.twig" %}{% block content %}Hello {{ name }}{% endblock %}') %}
|
8 |
-
--TEMPLATE(parent.twig)--
|
9 |
-
{% block content %}{% endblock %}
|
10 |
-
--DATA--
|
11 |
-
return ['name' => 'Fabien', 'template' => "Hello {{ name }}"]
|
12 |
-
--EXPECT--
|
13 |
-
Hello Fabien
|
14 |
-
Hello Fabien
|
15 |
-
Hello Fabien
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/functions/template_from_string_error.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"template_from_string" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include template_from_string("{{ not a Twig template ", "foo.twig") %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Unclosed "variable" in "foo.twig (string template 4900163d56b1af4b704c6b0afee7f98ba53418ce7a93d37a3af1882735baf9cd)" at line 1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/default_values.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from _self import test %}
|
5 |
-
|
6 |
-
{% macro test(a, b = 'bar') -%}
|
7 |
-
{{ a }}{{ b }}
|
8 |
-
{%- endmacro %}
|
9 |
-
|
10 |
-
{{ test('foo') }}
|
11 |
-
{{ test('bar', 'foo') }}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
foobar
|
16 |
-
barfoo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/nested_calls.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{% macro foo(data) %}
|
7 |
-
{{ data }}
|
8 |
-
{% endmacro %}
|
9 |
-
|
10 |
-
{% macro bar() %}
|
11 |
-
<br />
|
12 |
-
{% endmacro %}
|
13 |
-
|
14 |
-
{{ macros.foo(macros.bar()) }}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/reserved_variables.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from _self import test %}
|
5 |
-
|
6 |
-
{% macro test(this) -%}
|
7 |
-
{{ this }}
|
8 |
-
{%- endmacro %}
|
9 |
-
|
10 |
-
{{ test(this) }}
|
11 |
-
--DATA--
|
12 |
-
return ['this' => 'foo']
|
13 |
-
--EXPECT--
|
14 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/simple.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as test %}
|
5 |
-
{% from _self import test %}
|
6 |
-
|
7 |
-
{% macro test(a, b) -%}
|
8 |
-
{{ a|default('a') }}<br />
|
9 |
-
{{- b|default('b') }}<br />
|
10 |
-
{%- endmacro %}
|
11 |
-
|
12 |
-
{{ test.test() }}
|
13 |
-
{{ test() }}
|
14 |
-
{{ test.test(1, "c") }}
|
15 |
-
{{ test(1, "c") }}
|
16 |
-
--DATA--
|
17 |
-
return []
|
18 |
-
--EXPECT--
|
19 |
-
a<br />b<br />
|
20 |
-
a<br />b<br />
|
21 |
-
1<br />c<br />
|
22 |
-
1<br />c<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/varargs.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro with arbitrary arguments
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from _self import test1, test2 %}
|
5 |
-
|
6 |
-
{% macro test1(var) %}
|
7 |
-
{{- var }}: {{ varargs|join(", ") }}
|
8 |
-
{% endmacro %}
|
9 |
-
|
10 |
-
{% macro test2() %}
|
11 |
-
{{- varargs|join(", ") }}
|
12 |
-
{% endmacro %}
|
13 |
-
|
14 |
-
{{ test1("foo", "bar", "foobar") }}
|
15 |
-
{{ test2("foo", "bar", "foobar") }}
|
16 |
-
--DATA--
|
17 |
-
return []
|
18 |
-
--EXPECT--
|
19 |
-
foo: bar, foobar
|
20 |
-
|
21 |
-
foo, bar, foobar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/varargs_argument.test
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro with varargs argument
|
3 |
-
--TEMPLATE--
|
4 |
-
{% macro test(varargs) %}
|
5 |
-
{% endmacro %}
|
6 |
-
--EXCEPTION--
|
7 |
-
Twig\Error\SyntaxError: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/macros/with_filters.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
macro with a filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as test %}
|
5 |
-
|
6 |
-
{% macro test() %}
|
7 |
-
{% filter escape %}foo<br />{% endfilter %}
|
8 |
-
{% endmacro %}
|
9 |
-
|
10 |
-
{{ test.test() }}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
foo<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/block_names_unicity.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Block names are unique per template
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'layout' %}
|
5 |
-
{% block content -%}
|
6 |
-
{% filter title -%}
|
7 |
-
second
|
8 |
-
{% endfilter %}
|
9 |
-
{% endblock %}
|
10 |
-
--TEMPLATE(layout)--
|
11 |
-
{% filter title -%}
|
12 |
-
first
|
13 |
-
{% endfilter %}
|
14 |
-
{% block content %}{% endblock %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
First
|
19 |
-
Second
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/combined_debug_info.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Exception with bad line number
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block content %}
|
5 |
-
{{ foo }}
|
6 |
-
{{ include("foo") }}
|
7 |
-
{% endblock %}
|
8 |
-
index
|
9 |
-
--TEMPLATE(foo)--
|
10 |
-
foo
|
11 |
-
{{ foo.bar }}
|
12 |
-
--DATA--
|
13 |
-
return ['foo' => 'foo']
|
14 |
-
--EXCEPTION--
|
15 |
-
Twig\Error\RuntimeError: Impossible to access an attribute ("bar") on a string variable ("foo") in "foo" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/empty_token.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig outputs 0 nodes correctly
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ foo }}0{{ foo }}
|
5 |
-
--DATA--
|
6 |
-
return ['foo' => 'foo']
|
7 |
-
--EXPECT--
|
8 |
-
foo0foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/issue_1143.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
error in twig extension
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ object.region is not null ? object.regionChoices[object.region] }}
|
5 |
-
--DATA--
|
6 |
-
class House
|
7 |
-
{
|
8 |
-
const REGION_S = 1;
|
9 |
-
const REGION_P = 2;
|
10 |
-
|
11 |
-
public static $regionChoices = [self::REGION_S => 'house.region.s', self::REGION_P => 'house.region.p'];
|
12 |
-
|
13 |
-
public function getRegionChoices()
|
14 |
-
{
|
15 |
-
return self::$regionChoices;
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
$object = new House();
|
20 |
-
$object->region = 1;
|
21 |
-
return ['object' => $object]
|
22 |
-
--EXPECT--
|
23 |
-
house.region.s
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/multi_word_tests.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig allows multi-word tests without a custom node class
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo' is multi word ? 'yes' : 'no' }}
|
5 |
-
{{ 'foo bar' is multi word ? 'yes' : 'no' }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
no
|
10 |
-
yes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/simple_xml_element.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig is able to deal with SimpleXMLElement instances as variables
|
3 |
-
--CONDITION--
|
4 |
-
version_compare(phpversion(), '5.3.0', '>=')
|
5 |
-
--TEMPLATE--
|
6 |
-
Hello '{{ images.image.0.group }}'!
|
7 |
-
{{ images.image.0.group.attributes.myattr }}
|
8 |
-
{{ images.children().image.count() }}
|
9 |
-
{% for image in images %}
|
10 |
-
- {{ image.group }}
|
11 |
-
{% endfor %}
|
12 |
-
--DATA--
|
13 |
-
return ['images' => new \SimpleXMLElement('<images><image><group myattr="example">foo</group></image><image><group>bar</group></image></images>')]
|
14 |
-
--EXPECT--
|
15 |
-
Hello 'foo'!
|
16 |
-
example
|
17 |
-
2
|
18 |
-
- foo
|
19 |
-
- bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/regression/strings_like_numbers.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig does not confuse strings with integers in getAttribute()
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ hash['2e2'] }}
|
5 |
-
--DATA--
|
6 |
-
return ['hash' => ['2e2' => 'works']]
|
7 |
-
--EXPECT--
|
8 |
-
works
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/basic.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tag applies a filter on its children
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply upper %}
|
5 |
-
Some text with a {{ var }}
|
6 |
-
{% endapply %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => 'var']
|
9 |
-
--EXPECT--
|
10 |
-
SOME TEXT WITH A VAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/json_encode.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tag applies a filter on its children
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply json_encode|raw %}test{% endapply %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
"test"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/multiple.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tags accept multiple chained filters
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply lower|title %}
|
5 |
-
{{ var }}
|
6 |
-
{% endapply %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => 'VAR']
|
9 |
-
--EXPECT--
|
10 |
-
Var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/nested.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tags can be nested at will
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply lower|title %}
|
5 |
-
{{ var }}
|
6 |
-
{% apply upper %}
|
7 |
-
{{ var }}
|
8 |
-
{% endapply %}
|
9 |
-
{{ var }}
|
10 |
-
{% endapply %}
|
11 |
-
--DATA--
|
12 |
-
return ['var' => 'var']
|
13 |
-
--EXPECT--
|
14 |
-
Var
|
15 |
-
Var
|
16 |
-
Var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/scope.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tag does not create a new scope
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = 'baz' %}
|
5 |
-
{% apply spaceless %}
|
6 |
-
{% set foo = 'foo' %}
|
7 |
-
{% set bar = 'bar' %}
|
8 |
-
{% endapply %}
|
9 |
-
{{ 'foo' == foo ? 'OK ' ~ foo : 'KO' }}
|
10 |
-
{{ 'bar' == bar ? 'OK ' ~ bar : 'KO' }}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
OK foo
|
15 |
-
OK bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/with_for_tag.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tag applies the filter on "for" tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply upper %}
|
5 |
-
{% for item in items %}
|
6 |
-
{{ item }}
|
7 |
-
{% endfor %}
|
8 |
-
{% endapply %}
|
9 |
-
--DATA--
|
10 |
-
return ['items' => ['a', 'b']]
|
11 |
-
--EXPECT--
|
12 |
-
A
|
13 |
-
B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/apply/with_if_tag.test
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"apply" tag applies the filter on "if" tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% apply upper %}
|
5 |
-
{% if items %}
|
6 |
-
{{ items|join(', ') }}
|
7 |
-
{% endif %}
|
8 |
-
|
9 |
-
{% if items.3 is defined %}
|
10 |
-
FOO
|
11 |
-
{% else %}
|
12 |
-
{{ items.1 }}
|
13 |
-
{% endif %}
|
14 |
-
|
15 |
-
{% if items.3 is defined %}
|
16 |
-
FOO
|
17 |
-
{% elseif items.1 %}
|
18 |
-
{{ items.0 }}
|
19 |
-
{% endif %}
|
20 |
-
|
21 |
-
{% endapply %}
|
22 |
-
--DATA--
|
23 |
-
return ['items' => ['a', 'b']]
|
24 |
-
--EXPECT--
|
25 |
-
A, B
|
26 |
-
|
27 |
-
B
|
28 |
-
|
29 |
-
A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/basic.test
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping on its children
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape %}
|
5 |
-
{{ var }}<br />
|
6 |
-
{% endautoescape %}
|
7 |
-
{% autoescape 'html' %}
|
8 |
-
{{ var }}<br />
|
9 |
-
{% endautoescape %}
|
10 |
-
{% autoescape false %}
|
11 |
-
{{ var }}<br />
|
12 |
-
{% endautoescape %}
|
13 |
-
{% autoescape true %}
|
14 |
-
{{ var }}<br />
|
15 |
-
{% endautoescape %}
|
16 |
-
{% autoescape false %}
|
17 |
-
{{ var }}<br />
|
18 |
-
{% endautoescape %}
|
19 |
-
--DATA--
|
20 |
-
return ['var' => '<br />']
|
21 |
-
--EXPECT--
|
22 |
-
<br /><br />
|
23 |
-
<br /><br />
|
24 |
-
<br /><br />
|
25 |
-
<br /><br />
|
26 |
-
<br /><br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/blocks.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping on embedded blocks
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
{% block foo %}
|
6 |
-
{{ var }}
|
7 |
-
{% endblock %}
|
8 |
-
{% endautoescape %}
|
9 |
-
--DATA--
|
10 |
-
return ['var' => '<br />']
|
11 |
-
--EXPECT--
|
12 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/double_escaping.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag does not double-escape
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
{{ var|escape }}
|
6 |
-
{% endautoescape %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => '<br />']
|
9 |
-
--EXPECT--
|
10 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/functions.test
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping after calling functions
|
3 |
-
--TEMPLATE--
|
4 |
-
|
5 |
-
autoescape false
|
6 |
-
{% autoescape false %}
|
7 |
-
|
8 |
-
safe_br
|
9 |
-
{{ safe_br() }}
|
10 |
-
|
11 |
-
unsafe_br
|
12 |
-
{{ unsafe_br() }}
|
13 |
-
|
14 |
-
{% endautoescape %}
|
15 |
-
|
16 |
-
autoescape 'html'
|
17 |
-
{% autoescape 'html' %}
|
18 |
-
|
19 |
-
safe_br
|
20 |
-
{{ safe_br() }}
|
21 |
-
|
22 |
-
unsafe_br
|
23 |
-
{{ unsafe_br() }}
|
24 |
-
|
25 |
-
unsafe_br()|raw
|
26 |
-
{{ (unsafe_br())|raw }}
|
27 |
-
|
28 |
-
safe_br()|escape
|
29 |
-
{{ (safe_br())|escape }}
|
30 |
-
|
31 |
-
safe_br()|raw
|
32 |
-
{{ (safe_br())|raw }}
|
33 |
-
|
34 |
-
unsafe_br()|escape
|
35 |
-
{{ (unsafe_br())|escape }}
|
36 |
-
|
37 |
-
{% endautoescape %}
|
38 |
-
|
39 |
-
autoescape js
|
40 |
-
{% autoescape 'js' %}
|
41 |
-
|
42 |
-
safe_br
|
43 |
-
{{ safe_br() }}
|
44 |
-
|
45 |
-
{% endautoescape %}
|
46 |
-
--DATA--
|
47 |
-
return []
|
48 |
-
--EXPECT--
|
49 |
-
|
50 |
-
autoescape false
|
51 |
-
|
52 |
-
safe_br
|
53 |
-
<br />
|
54 |
-
|
55 |
-
unsafe_br
|
56 |
-
<br />
|
57 |
-
|
58 |
-
|
59 |
-
autoescape 'html'
|
60 |
-
|
61 |
-
safe_br
|
62 |
-
<br />
|
63 |
-
|
64 |
-
unsafe_br
|
65 |
-
<br />
|
66 |
-
|
67 |
-
unsafe_br()|raw
|
68 |
-
<br />
|
69 |
-
|
70 |
-
safe_br()|escape
|
71 |
-
<br />
|
72 |
-
|
73 |
-
safe_br()|raw
|
74 |
-
<br />
|
75 |
-
|
76 |
-
unsafe_br()|escape
|
77 |
-
<br />
|
78 |
-
|
79 |
-
|
80 |
-
autoescape js
|
81 |
-
|
82 |
-
safe_br
|
83 |
-
\u003Cbr\u0020\/\u003E
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/literal.test
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag does not apply escaping on literals
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
|
6 |
-
1. Simple literal
|
7 |
-
{{ "<br />" }}
|
8 |
-
|
9 |
-
2. Conditional expression with only literals
|
10 |
-
{{ true ? "<br />" : "<br>" }}
|
11 |
-
|
12 |
-
3. Conditional expression with a variable
|
13 |
-
{{ true ? "<br />" : someVar }}
|
14 |
-
{{ false ? "<br />" : someVar }}
|
15 |
-
{{ true ? someVar : "<br />" }}
|
16 |
-
{{ false ? someVar : "<br />" }}
|
17 |
-
|
18 |
-
4. Nested conditionals with only literals
|
19 |
-
{{ true ? (true ? "<br />" : "<br>") : "\n" }}
|
20 |
-
|
21 |
-
5. Nested conditionals with a variable
|
22 |
-
{{ true ? (true ? "<br />" : someVar) : "\n" }}
|
23 |
-
{{ true ? (false ? "<br />" : someVar) : "\n" }}
|
24 |
-
{{ true ? (true ? someVar : "<br />") : "\n" }}
|
25 |
-
{{ true ? (false ? someVar : "<br />") : "\n" }}
|
26 |
-
{{ false ? "\n" : (true ? someVar : "<br />") }}
|
27 |
-
{{ false ? "\n" : (false ? someVar : "<br />") }}
|
28 |
-
|
29 |
-
6. Nested conditionals with a variable marked safe
|
30 |
-
{{ true ? (true ? "<br />" : someVar|raw) : "\n" }}
|
31 |
-
{{ true ? (false ? "<br />" : someVar|raw) : "\n" }}
|
32 |
-
{{ true ? (true ? someVar|raw : "<br />") : "\n" }}
|
33 |
-
{{ true ? (false ? someVar|raw : "<br />") : "\n" }}
|
34 |
-
{{ false ? "\n" : (true ? someVar|raw : "<br />") }}
|
35 |
-
{{ false ? "\n" : (false ? someVar|raw : "<br />") }}
|
36 |
-
|
37 |
-
7. Without then clause
|
38 |
-
{{ "<br />" ?: someVar }}
|
39 |
-
{{ someFalseVar ?: "<br />" }}
|
40 |
-
|
41 |
-
8. NullCoalesce
|
42 |
-
{{ aaaa ?? "<br />" }}
|
43 |
-
{{ "<br />" ?? someVar }}
|
44 |
-
|
45 |
-
{% endautoescape %}
|
46 |
-
--DATA--
|
47 |
-
return ['someVar' => '<br />', 'someFalseVar' => false]
|
48 |
-
--EXPECT--
|
49 |
-
|
50 |
-
1. Simple literal
|
51 |
-
<br />
|
52 |
-
|
53 |
-
2. Conditional expression with only literals
|
54 |
-
<br />
|
55 |
-
|
56 |
-
3. Conditional expression with a variable
|
57 |
-
<br />
|
58 |
-
<br />
|
59 |
-
<br />
|
60 |
-
<br />
|
61 |
-
|
62 |
-
4. Nested conditionals with only literals
|
63 |
-
<br />
|
64 |
-
|
65 |
-
5. Nested conditionals with a variable
|
66 |
-
<br />
|
67 |
-
<br />
|
68 |
-
<br />
|
69 |
-
<br />
|
70 |
-
<br />
|
71 |
-
<br />
|
72 |
-
|
73 |
-
6. Nested conditionals with a variable marked safe
|
74 |
-
<br />
|
75 |
-
<br />
|
76 |
-
<br />
|
77 |
-
<br />
|
78 |
-
<br />
|
79 |
-
<br />
|
80 |
-
|
81 |
-
7. Without then clause
|
82 |
-
<br />
|
83 |
-
<br />
|
84 |
-
|
85 |
-
8. NullCoalesce
|
86 |
-
<br />
|
87 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/nested.test
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tags can be nested at will
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ var }}
|
5 |
-
{% autoescape 'html' %}
|
6 |
-
{{ var }}
|
7 |
-
{% autoescape false %}
|
8 |
-
{{ var }}
|
9 |
-
{% autoescape 'html' %}
|
10 |
-
{{ var }}
|
11 |
-
{% endautoescape %}
|
12 |
-
{{ var }}
|
13 |
-
{% endautoescape %}
|
14 |
-
{{ var }}
|
15 |
-
{% endautoescape %}
|
16 |
-
{{ var }}
|
17 |
-
--DATA--
|
18 |
-
return ['var' => '<br />']
|
19 |
-
--EXPECT--
|
20 |
-
<br />
|
21 |
-
<br />
|
22 |
-
<br />
|
23 |
-
<br />
|
24 |
-
<br />
|
25 |
-
<br />
|
26 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/objects.test
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping to object method calls
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
{{ user.name }}
|
6 |
-
{{ user.name|lower }}
|
7 |
-
{{ user }}
|
8 |
-
{% endautoescape %}
|
9 |
-
--DATA--
|
10 |
-
class UserForAutoEscapeTest
|
11 |
-
{
|
12 |
-
public function getName()
|
13 |
-
{
|
14 |
-
return 'Fabien<br />';
|
15 |
-
}
|
16 |
-
|
17 |
-
public function __toString()
|
18 |
-
{
|
19 |
-
return 'Fabien<br />';
|
20 |
-
}
|
21 |
-
}
|
22 |
-
return ['user' => new UserForAutoEscapeTest()]
|
23 |
-
--EXPECT--
|
24 |
-
Fabien<br />
|
25 |
-
fabien<br />
|
26 |
-
Fabien<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/raw.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag does not escape when raw is used as a filter
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
{{ var|raw }}
|
6 |
-
{% endautoescape %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => '<br />']
|
9 |
-
--EXPECT--
|
10 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/strategy.legacy.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag accepts an escaping strategy
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape true js %}{{ var }}{% endautoescape %}
|
5 |
-
|
6 |
-
{% autoescape true html %}{{ var }}{% endautoescape %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => '<br />"']
|
9 |
-
--EXPECT--
|
10 |
-
\u003Cbr\u0020\/\u003E\u0022
|
11 |
-
<br />"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/strategy.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag accepts an escaping strategy
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'js' %}{{ var }}{% endautoescape %}
|
5 |
-
|
6 |
-
{% autoescape 'html' %}{{ var }}{% endautoescape %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => '<br />"']
|
9 |
-
--EXPECT--
|
10 |
-
\u003Cbr\u0020\/\u003E\u0022
|
11 |
-
<br />"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/type.test
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
escape types
|
3 |
-
--TEMPLATE--
|
4 |
-
|
5 |
-
1. autoescape 'html' |escape('js')
|
6 |
-
|
7 |
-
{% autoescape 'html' %}
|
8 |
-
<a onclick="alert("{{ msg|escape('js') }}")"></a>
|
9 |
-
{% endautoescape %}
|
10 |
-
|
11 |
-
2. autoescape 'html' |escape('js')
|
12 |
-
|
13 |
-
{% autoescape 'html' %}
|
14 |
-
<a onclick="alert("{{ msg|escape('js') }}")"></a>
|
15 |
-
{% endautoescape %}
|
16 |
-
|
17 |
-
3. autoescape 'js' |escape('js')
|
18 |
-
|
19 |
-
{% autoescape 'js' %}
|
20 |
-
<a onclick="alert("{{ msg|escape('js') }}")"></a>
|
21 |
-
{% endautoescape %}
|
22 |
-
|
23 |
-
4. no escape
|
24 |
-
|
25 |
-
{% autoescape false %}
|
26 |
-
<a onclick="alert("{{ msg }}")"></a>
|
27 |
-
{% endautoescape %}
|
28 |
-
|
29 |
-
5. |escape('js')|escape('html')
|
30 |
-
|
31 |
-
{% autoescape false %}
|
32 |
-
<a onclick="alert("{{ msg|escape('js')|escape('html') }}")"></a>
|
33 |
-
{% endautoescape %}
|
34 |
-
|
35 |
-
6. autoescape 'html' |escape('js')|escape('html')
|
36 |
-
|
37 |
-
{% autoescape 'html' %}
|
38 |
-
<a onclick="alert("{{ msg|escape('js')|escape('html') }}")"></a>
|
39 |
-
{% endautoescape %}
|
40 |
-
|
41 |
-
--DATA--
|
42 |
-
return ['msg' => "<>\n'\""]
|
43 |
-
--EXPECT--
|
44 |
-
|
45 |
-
1. autoescape 'html' |escape('js')
|
46 |
-
|
47 |
-
<a onclick="alert("\u003C\u003E\n\u0027\u0022")"></a>
|
48 |
-
|
49 |
-
2. autoescape 'html' |escape('js')
|
50 |
-
|
51 |
-
<a onclick="alert("\u003C\u003E\n\u0027\u0022")"></a>
|
52 |
-
|
53 |
-
3. autoescape 'js' |escape('js')
|
54 |
-
|
55 |
-
<a onclick="alert("\u003C\u003E\n\u0027\u0022")"></a>
|
56 |
-
|
57 |
-
4. no escape
|
58 |
-
|
59 |
-
<a onclick="alert("<>
|
60 |
-
'"")"></a>
|
61 |
-
|
62 |
-
5. |escape('js')|escape('html')
|
63 |
-
|
64 |
-
<a onclick="alert("\u003C\u003E\n\u0027\u0022")"></a>
|
65 |
-
|
66 |
-
6. autoescape 'html' |escape('js')|escape('html')
|
67 |
-
|
68 |
-
<a onclick="alert("\u003C\u003E\n\u0027\u0022")"></a>
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/with_filters.test
DELETED
@@ -1,131 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping after calling filters
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
|
6 |
-
(escape_and_nl2br is an escaper filter)
|
7 |
-
|
8 |
-
1. Don't escape escaper filter output
|
9 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
10 |
-
the output is not escaped )
|
11 |
-
{{ var|escape_and_nl2br }}
|
12 |
-
|
13 |
-
2. Don't escape escaper filter output
|
14 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
15 |
-
the output is not escaped, |raw is redundant )
|
16 |
-
{{ var|escape_and_nl2br|raw }}
|
17 |
-
|
18 |
-
3. Explicit escape
|
19 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
20 |
-
the output is explicitly escaped by |escape )
|
21 |
-
{{ var|escape_and_nl2br|escape }}
|
22 |
-
|
23 |
-
4. Escape non-escaper filter output
|
24 |
-
( var is upper-cased by |upper,
|
25 |
-
the output is auto-escaped )
|
26 |
-
{{ var|upper }}
|
27 |
-
|
28 |
-
5. Escape if last filter is not an escaper
|
29 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
30 |
-
the output is upper-cased by |upper,
|
31 |
-
the output is auto-escaped as |upper is not an escaper )
|
32 |
-
{{ var|escape_and_nl2br|upper }}
|
33 |
-
|
34 |
-
6. Don't escape escaper filter output
|
35 |
-
( var is upper cased by upper,
|
36 |
-
the output is escaped by |escape_and_nl2br, line-breaks are added,
|
37 |
-
the output is not escaped as |escape_and_nl2br is an escaper )
|
38 |
-
{{ var|upper|escape_and_nl2br }}
|
39 |
-
|
40 |
-
7. Escape if last filter is not an escaper
|
41 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
42 |
-
the output is auto-escaped )
|
43 |
-
{{ "<b>%s</b>"|format(var) }}
|
44 |
-
|
45 |
-
8. Escape if last filter is not an escaper
|
46 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
47 |
-
|raw is redundant,
|
48 |
-
the output is auto-escaped )
|
49 |
-
{{ "<b>%s</b>"|raw|format(var) }}
|
50 |
-
|
51 |
-
9. Don't escape escaper filter output
|
52 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
53 |
-
the output is not escaped due to |raw filter at the end )
|
54 |
-
{{ "<b>%s</b>"|format(var)|raw }}
|
55 |
-
|
56 |
-
10. Don't escape escaper filter output
|
57 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
58 |
-
the output is not escaped due to |raw filter at the end,
|
59 |
-
the |raw filter on var is redundant )
|
60 |
-
{{ "<b>%s</b>"|format(var|raw)|raw }}
|
61 |
-
|
62 |
-
{% endautoescape %}
|
63 |
-
--DATA--
|
64 |
-
return ['var' => "<Fabien>\nTwig"]
|
65 |
-
--EXPECT--
|
66 |
-
|
67 |
-
(escape_and_nl2br is an escaper filter)
|
68 |
-
|
69 |
-
1. Don't escape escaper filter output
|
70 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
71 |
-
the output is not escaped )
|
72 |
-
<Fabien><br />
|
73 |
-
Twig
|
74 |
-
|
75 |
-
2. Don't escape escaper filter output
|
76 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
77 |
-
the output is not escaped, |raw is redundant )
|
78 |
-
<Fabien><br />
|
79 |
-
Twig
|
80 |
-
|
81 |
-
3. Explicit escape
|
82 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
83 |
-
the output is explicitly escaped by |escape )
|
84 |
-
&lt;Fabien&gt;<br />
|
85 |
-
Twig
|
86 |
-
|
87 |
-
4. Escape non-escaper filter output
|
88 |
-
( var is upper-cased by |upper,
|
89 |
-
the output is auto-escaped )
|
90 |
-
<FABIEN>
|
91 |
-
TWIG
|
92 |
-
|
93 |
-
5. Escape if last filter is not an escaper
|
94 |
-
( var is escaped by |escape_and_nl2br, line-breaks are added,
|
95 |
-
the output is upper-cased by |upper,
|
96 |
-
the output is auto-escaped as |upper is not an escaper )
|
97 |
-
&LT;FABIEN&GT;<BR />
|
98 |
-
TWIG
|
99 |
-
|
100 |
-
6. Don't escape escaper filter output
|
101 |
-
( var is upper cased by upper,
|
102 |
-
the output is escaped by |escape_and_nl2br, line-breaks are added,
|
103 |
-
the output is not escaped as |escape_and_nl2br is an escaper )
|
104 |
-
<FABIEN><br />
|
105 |
-
TWIG
|
106 |
-
|
107 |
-
7. Escape if last filter is not an escaper
|
108 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
109 |
-
the output is auto-escaped )
|
110 |
-
<b><Fabien>
|
111 |
-
Twig</b>
|
112 |
-
|
113 |
-
8. Escape if last filter is not an escaper
|
114 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
115 |
-
|raw is redundant,
|
116 |
-
the output is auto-escaped )
|
117 |
-
<b><Fabien>
|
118 |
-
Twig</b>
|
119 |
-
|
120 |
-
9. Don't escape escaper filter output
|
121 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
122 |
-
the output is not escaped due to |raw filter at the end )
|
123 |
-
<b><Fabien>
|
124 |
-
Twig</b>
|
125 |
-
|
126 |
-
10. Don't escape escaper filter output
|
127 |
-
( the output of |format is "<b>" ~ var ~ "</b>",
|
128 |
-
the output is not escaped due to |raw filter at the end,
|
129 |
-
the |raw filter on var is redundant )
|
130 |
-
<b><Fabien>
|
131 |
-
Twig</b>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/with_filters_arguments.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag do not applies escaping on filter arguments
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
{{ var|nl2br("<br />") }}
|
6 |
-
{{ var|nl2br("<br />"|escape) }}
|
7 |
-
{{ var|nl2br(sep) }}
|
8 |
-
{{ var|nl2br(sep|raw) }}
|
9 |
-
{{ var|nl2br(sep|escape) }}
|
10 |
-
{% endautoescape %}
|
11 |
-
--DATA--
|
12 |
-
return ['var' => "<Fabien>\nTwig", 'sep' => '<br />']
|
13 |
-
--EXPECT--
|
14 |
-
<Fabien><br />
|
15 |
-
Twig
|
16 |
-
<Fabien><br />
|
17 |
-
Twig
|
18 |
-
<Fabien><br />
|
19 |
-
Twig
|
20 |
-
<Fabien><br />
|
21 |
-
Twig
|
22 |
-
<Fabien><br />
|
23 |
-
Twig
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/with_pre_escape_filters.test
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag applies escaping after calling filters, and before calling pre_escape filters
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
|
6 |
-
(nl2br is pre_escaped for "html" and declared safe for "html")
|
7 |
-
|
8 |
-
1. Pre-escape and don't post-escape
|
9 |
-
( var|escape|nl2br )
|
10 |
-
{{ var|nl2br }}
|
11 |
-
|
12 |
-
2. Don't double-pre-escape
|
13 |
-
( var|escape|nl2br )
|
14 |
-
{{ var|escape|nl2br }}
|
15 |
-
|
16 |
-
3. Don't escape safe values
|
17 |
-
( var|raw|nl2br )
|
18 |
-
{{ var|raw|nl2br }}
|
19 |
-
|
20 |
-
4. Don't escape safe values
|
21 |
-
( var|escape|nl2br|nl2br )
|
22 |
-
{{ var|nl2br|nl2br }}
|
23 |
-
|
24 |
-
5. Re-escape values that are escaped for an other contexts
|
25 |
-
( var|escape_something|escape|nl2br )
|
26 |
-
{{ var|escape_something|nl2br }}
|
27 |
-
|
28 |
-
6. Still escape when using filters not declared safe
|
29 |
-
( var|escape|nl2br|upper|escape )
|
30 |
-
{{ var|nl2br|upper }}
|
31 |
-
|
32 |
-
{% endautoescape %}
|
33 |
-
--DATA--
|
34 |
-
return ['var' => "<Fabien>\nTwig"]
|
35 |
-
--EXPECT--
|
36 |
-
|
37 |
-
(nl2br is pre_escaped for "html" and declared safe for "html")
|
38 |
-
|
39 |
-
1. Pre-escape and don't post-escape
|
40 |
-
( var|escape|nl2br )
|
41 |
-
<Fabien><br />
|
42 |
-
Twig
|
43 |
-
|
44 |
-
2. Don't double-pre-escape
|
45 |
-
( var|escape|nl2br )
|
46 |
-
<Fabien><br />
|
47 |
-
Twig
|
48 |
-
|
49 |
-
3. Don't escape safe values
|
50 |
-
( var|raw|nl2br )
|
51 |
-
<Fabien><br />
|
52 |
-
Twig
|
53 |
-
|
54 |
-
4. Don't escape safe values
|
55 |
-
( var|escape|nl2br|nl2br )
|
56 |
-
<Fabien><br /><br />
|
57 |
-
Twig
|
58 |
-
|
59 |
-
5. Re-escape values that are escaped for an other contexts
|
60 |
-
( var|escape_something|escape|nl2br )
|
61 |
-
<FABIEN><br />
|
62 |
-
TWIG
|
63 |
-
|
64 |
-
6. Still escape when using filters not declared safe
|
65 |
-
( var|escape|nl2br|upper|escape )
|
66 |
-
&LT;FABIEN&GT;<BR />
|
67 |
-
TWIG
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/autoescape/with_preserves_safety_filters.test
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"autoescape" tag handles filters preserving the safety
|
3 |
-
--TEMPLATE--
|
4 |
-
{% autoescape 'html' %}
|
5 |
-
|
6 |
-
(preserves_safety is preserving safety for "html")
|
7 |
-
|
8 |
-
1. Unsafe values are still unsafe
|
9 |
-
( var|preserves_safety|escape )
|
10 |
-
{{ var|preserves_safety }}
|
11 |
-
|
12 |
-
2. Safe values are still safe
|
13 |
-
( var|escape|preserves_safety )
|
14 |
-
{{ var|escape|preserves_safety }}
|
15 |
-
|
16 |
-
3. Re-escape values that are escaped for an other contexts
|
17 |
-
( var|escape_something|preserves_safety|escape )
|
18 |
-
{{ var|escape_something|preserves_safety }}
|
19 |
-
|
20 |
-
4. Still escape when using filters not declared safe
|
21 |
-
( var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'})|escape )
|
22 |
-
{{ var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'}) }}
|
23 |
-
|
24 |
-
{% endautoescape %}
|
25 |
-
--DATA--
|
26 |
-
return ['var' => "<Fabien>\nTwig"]
|
27 |
-
--EXPECT--
|
28 |
-
|
29 |
-
(preserves_safety is preserving safety for "html")
|
30 |
-
|
31 |
-
1. Unsafe values are still unsafe
|
32 |
-
( var|preserves_safety|escape )
|
33 |
-
<FABIEN>
|
34 |
-
TWIG
|
35 |
-
|
36 |
-
2. Safe values are still safe
|
37 |
-
( var|escape|preserves_safety )
|
38 |
-
<FABIEN>
|
39 |
-
TWIG
|
40 |
-
|
41 |
-
3. Re-escape values that are escaped for an other contexts
|
42 |
-
( var|escape_something|preserves_safety|escape )
|
43 |
-
<FABIEN>
|
44 |
-
TWIG
|
45 |
-
|
46 |
-
4. Still escape when using filters not declared safe
|
47 |
-
( var|escape|preserves_safety|replace({'FABIEN': 'FABPOT'})|escape )
|
48 |
-
&LT;FABPOT&GT;
|
49 |
-
TWIG
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/block/basic.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block title1 %}FOO{% endblock %}
|
5 |
-
{% block title2 foo|lower %}
|
6 |
-
--TEMPLATE(foo.twig)--
|
7 |
-
{% block content %}{% endblock %}
|
8 |
-
--DATA--
|
9 |
-
return ['foo' => 'bar']
|
10 |
-
--EXPECT--
|
11 |
-
FOObar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/block/block_unique_name.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block content %}
|
5 |
-
{% block content %}
|
6 |
-
{% endblock %}
|
7 |
-
{% endblock %}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXCEPTION--
|
11 |
-
Twig\Error\SyntaxError: The block 'content' has already been defined line 2 in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/block/special_chars.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"§" special chars in a block name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block § %}
|
5 |
-
§
|
6 |
-
{% endblock § %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
§
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/deprecated/block.legacy.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Deprecating a block with "deprecated" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'greeting.twig' %}
|
5 |
-
|
6 |
-
{{ block('welcome') }}
|
7 |
-
|
8 |
-
--TEMPLATE(greeting.twig)--
|
9 |
-
{% block welcome %}
|
10 |
-
{% deprecated 'The "welcome" block is deprecated, use "hello" instead.' %}
|
11 |
-
{{ block('hello') }}
|
12 |
-
{% endblock %}
|
13 |
-
|
14 |
-
{% block hello %}
|
15 |
-
Hello Fabien
|
16 |
-
{% endblock %}
|
17 |
-
--DATA--
|
18 |
-
return []
|
19 |
-
--EXPECT--
|
20 |
-
Hello Fabien
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/deprecated/macro.legacy.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Deprecating a macro with "deprecated" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import 'greeting.twig' as greeting %}
|
5 |
-
|
6 |
-
{{ greeting.welcome('Fabien') }}
|
7 |
-
|
8 |
-
--TEMPLATE(greeting.twig)--
|
9 |
-
{% macro welcome(name) %}
|
10 |
-
{% deprecated 'The "welcome" macro is deprecated, use "hello" instead.' %}
|
11 |
-
{% import _self as self %}
|
12 |
-
{{ self.hello(name) }}
|
13 |
-
{% endmacro %}
|
14 |
-
|
15 |
-
{% macro hello(name) %}
|
16 |
-
Hello {{ name }}
|
17 |
-
{% endmacro %}
|
18 |
-
--DATA--
|
19 |
-
return []
|
20 |
-
--EXPECT--
|
21 |
-
Hello Fabien
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/deprecated/template.legacy.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Deprecating a template with "deprecated" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'greeting.twig' %}
|
5 |
-
|
6 |
-
{% deprecated 'The "index.twig" template is deprecated, use "greeting.twig" instead.' %}
|
7 |
-
--TEMPLATE(greeting.twig)--
|
8 |
-
Hello Fabien
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
Hello Fabien
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/basic.test
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% embed "foo.twig" %}
|
6 |
-
{% block c1 %}
|
7 |
-
{{ parent() }}
|
8 |
-
block1extended
|
9 |
-
{% endblock %}
|
10 |
-
{% endembed %}
|
11 |
-
|
12 |
-
BAR
|
13 |
-
--TEMPLATE(foo.twig)--
|
14 |
-
A
|
15 |
-
{% block c1 %}
|
16 |
-
block1
|
17 |
-
{% endblock %}
|
18 |
-
B
|
19 |
-
{% block c2 %}
|
20 |
-
block2
|
21 |
-
{% endblock %}
|
22 |
-
C
|
23 |
-
--DATA--
|
24 |
-
return []
|
25 |
-
--EXPECT--
|
26 |
-
FOO
|
27 |
-
|
28 |
-
A
|
29 |
-
block1
|
30 |
-
|
31 |
-
block1extended
|
32 |
-
B
|
33 |
-
block2
|
34 |
-
C
|
35 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/complex_dynamic_parent.test
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% embed foo ~ ".twig" %}
|
6 |
-
{% block c1 %}
|
7 |
-
{{ parent() }}
|
8 |
-
block1extended
|
9 |
-
{% endblock %}
|
10 |
-
{% endembed %}
|
11 |
-
|
12 |
-
BAR
|
13 |
-
--TEMPLATE(foo.twig)--
|
14 |
-
A
|
15 |
-
{% block c1 %}
|
16 |
-
block1
|
17 |
-
{% endblock %}
|
18 |
-
B
|
19 |
-
{% block c2 %}
|
20 |
-
block2
|
21 |
-
{% endblock %}
|
22 |
-
C
|
23 |
-
--DATA--
|
24 |
-
return ['foo' => 'foo']
|
25 |
-
--EXPECT--
|
26 |
-
FOO
|
27 |
-
|
28 |
-
A
|
29 |
-
block1
|
30 |
-
|
31 |
-
block1extended
|
32 |
-
B
|
33 |
-
block2
|
34 |
-
C
|
35 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/dynamic_parent.test
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% embed foo %}
|
6 |
-
{% block c1 %}
|
7 |
-
{{ parent() }}
|
8 |
-
block1extended
|
9 |
-
{% endblock %}
|
10 |
-
{% endembed %}
|
11 |
-
|
12 |
-
BAR
|
13 |
-
--TEMPLATE(foo.twig)--
|
14 |
-
A
|
15 |
-
{% block c1 %}
|
16 |
-
block1
|
17 |
-
{% endblock %}
|
18 |
-
B
|
19 |
-
{% block c2 %}
|
20 |
-
block2
|
21 |
-
{% endblock %}
|
22 |
-
C
|
23 |
-
--DATA--
|
24 |
-
return ['foo' => 'foo.twig']
|
25 |
-
--EXPECT--
|
26 |
-
FOO
|
27 |
-
|
28 |
-
A
|
29 |
-
block1
|
30 |
-
|
31 |
-
block1extended
|
32 |
-
B
|
33 |
-
block2
|
34 |
-
C
|
35 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/error_line.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE(index.twig)--
|
4 |
-
FOO
|
5 |
-
{% embed "foo.twig" %}
|
6 |
-
{% block c1 %}
|
7 |
-
{{ nothing }}
|
8 |
-
{% endblock %}
|
9 |
-
{% endembed %}
|
10 |
-
BAR
|
11 |
-
--TEMPLATE(foo.twig)--
|
12 |
-
{% block c1 %}{% endblock %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXCEPTION--
|
16 |
-
Twig\Error\RuntimeError: Variable "nothing" does not exist in "index.twig" at line 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/multiple.test
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% embed "foo.twig" %}
|
6 |
-
{% block c1 %}
|
7 |
-
{{ parent() }}
|
8 |
-
block1extended
|
9 |
-
{% endblock %}
|
10 |
-
{% endembed %}
|
11 |
-
|
12 |
-
{% embed "foo.twig" %}
|
13 |
-
{% block c1 %}
|
14 |
-
{{ parent() }}
|
15 |
-
block1extended
|
16 |
-
{% endblock %}
|
17 |
-
{% endembed %}
|
18 |
-
|
19 |
-
BAR
|
20 |
-
--TEMPLATE(foo.twig)--
|
21 |
-
A
|
22 |
-
{% block c1 %}
|
23 |
-
block1
|
24 |
-
{% endblock %}
|
25 |
-
B
|
26 |
-
{% block c2 %}
|
27 |
-
block2
|
28 |
-
{% endblock %}
|
29 |
-
C
|
30 |
-
--DATA--
|
31 |
-
return []
|
32 |
-
--EXPECT--
|
33 |
-
FOO
|
34 |
-
|
35 |
-
A
|
36 |
-
block1
|
37 |
-
|
38 |
-
block1extended
|
39 |
-
B
|
40 |
-
block2
|
41 |
-
C
|
42 |
-
|
43 |
-
A
|
44 |
-
block1
|
45 |
-
|
46 |
-
block1extended
|
47 |
-
B
|
48 |
-
block2
|
49 |
-
C
|
50 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/nested.test
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% embed "foo.twig" %}
|
5 |
-
{% block c1 %}
|
6 |
-
{{ parent() }}
|
7 |
-
{% embed "foo.twig" %}
|
8 |
-
{% block c1 %}
|
9 |
-
{{ parent() }}
|
10 |
-
block1extended
|
11 |
-
{% endblock %}
|
12 |
-
{% endembed %}
|
13 |
-
|
14 |
-
{% endblock %}
|
15 |
-
{% endembed %}
|
16 |
-
--TEMPLATE(foo.twig)--
|
17 |
-
A
|
18 |
-
{% block c1 %}
|
19 |
-
block1
|
20 |
-
{% endblock %}
|
21 |
-
B
|
22 |
-
{% block c2 %}
|
23 |
-
block2
|
24 |
-
{% endblock %}
|
25 |
-
C
|
26 |
-
--DATA--
|
27 |
-
return []
|
28 |
-
--EXPECT--
|
29 |
-
A
|
30 |
-
block1
|
31 |
-
|
32 |
-
|
33 |
-
A
|
34 |
-
block1
|
35 |
-
|
36 |
-
block1extended
|
37 |
-
B
|
38 |
-
block2
|
39 |
-
C
|
40 |
-
B
|
41 |
-
block2
|
42 |
-
C
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/embed/with_extends.test
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"embed" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
|
6 |
-
{% block c1 %}
|
7 |
-
{{ parent() }}
|
8 |
-
blockc1baseextended
|
9 |
-
{% endblock %}
|
10 |
-
|
11 |
-
{% block c2 %}
|
12 |
-
{{ parent() }}
|
13 |
-
|
14 |
-
{% embed "foo.twig" %}
|
15 |
-
{% block c1 %}
|
16 |
-
{{ parent() }}
|
17 |
-
block1extended
|
18 |
-
{% endblock %}
|
19 |
-
{% endembed %}
|
20 |
-
{{ parent() }}
|
21 |
-
{% endblock %}
|
22 |
-
--TEMPLATE(base.twig)--
|
23 |
-
A
|
24 |
-
{% block c1 %}
|
25 |
-
blockc1base
|
26 |
-
{% endblock %}
|
27 |
-
{% block c2 %}
|
28 |
-
blockc2base
|
29 |
-
{% endblock %}
|
30 |
-
B
|
31 |
-
--TEMPLATE(foo.twig)--
|
32 |
-
A
|
33 |
-
{% block c1 %}
|
34 |
-
block1
|
35 |
-
{% endblock %}
|
36 |
-
B
|
37 |
-
{% block c2 %}
|
38 |
-
block2
|
39 |
-
{% endblock %}
|
40 |
-
C
|
41 |
-
--DATA--
|
42 |
-
return []
|
43 |
-
--EXPECT--
|
44 |
-
A
|
45 |
-
blockc1base
|
46 |
-
|
47 |
-
blockc1baseextended
|
48 |
-
blockc2base
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
A
|
53 |
-
block1
|
54 |
-
|
55 |
-
block1extended
|
56 |
-
B
|
57 |
-
block2
|
58 |
-
C blockc2base
|
59 |
-
|
60 |
-
B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/basic.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tag applies a filter on its children
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter upper %}
|
5 |
-
Some text with a {{ var }}
|
6 |
-
{% endfilter %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => 'var']
|
9 |
-
--EXPECT--
|
10 |
-
SOME TEXT WITH A VAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/json_encode.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tag applies a filter on its children
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter json_encode|raw %}test{% endfilter %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
"test"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/multiple.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tags accept multiple chained filters
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter lower|title %}
|
5 |
-
{{ var }}
|
6 |
-
{% endfilter %}
|
7 |
-
--DATA--
|
8 |
-
return ['var' => 'VAR']
|
9 |
-
--EXPECT--
|
10 |
-
Var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/nested.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tags can be nested at will
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter lower|title %}
|
5 |
-
{{ var }}
|
6 |
-
{% filter upper %}
|
7 |
-
{{ var }}
|
8 |
-
{% endfilter %}
|
9 |
-
{{ var }}
|
10 |
-
{% endfilter %}
|
11 |
-
--DATA--
|
12 |
-
return ['var' => 'var']
|
13 |
-
--EXPECT--
|
14 |
-
Var
|
15 |
-
Var
|
16 |
-
Var
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/scope.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"scope" tag creates a new scope
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter spaceless %}
|
5 |
-
{% set item = 'foo' %}
|
6 |
-
{% endfilter %}
|
7 |
-
{{ item }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXCEPTION--
|
11 |
-
Twig\Error\RuntimeError: Variable "item" does not exist in "index.twig" at line 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/with_for_tag.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tag applies the filter on "for" tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter upper %}
|
5 |
-
{% for item in items %}
|
6 |
-
{{ item }}
|
7 |
-
{% endfor %}
|
8 |
-
{% endfilter %}
|
9 |
-
--DATA--
|
10 |
-
return ['items' => ['a', 'b']]
|
11 |
-
--EXPECT--
|
12 |
-
A
|
13 |
-
B
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/filter/with_if_tag.test
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filter" tag applies the filter on "if" tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% filter upper %}
|
5 |
-
{% if items %}
|
6 |
-
{{ items|join(', ') }}
|
7 |
-
{% endif %}
|
8 |
-
|
9 |
-
{% if items.3 is defined %}
|
10 |
-
FOO
|
11 |
-
{% else %}
|
12 |
-
{{ items.1 }}
|
13 |
-
{% endif %}
|
14 |
-
|
15 |
-
{% if items.3 is defined %}
|
16 |
-
FOO
|
17 |
-
{% elseif items.1 %}
|
18 |
-
{{ items.0 }}
|
19 |
-
{% endif %}
|
20 |
-
|
21 |
-
{% endfilter %}
|
22 |
-
--DATA--
|
23 |
-
return ['items' => ['a', 'b']]
|
24 |
-
--EXPECT--
|
25 |
-
A, B
|
26 |
-
|
27 |
-
B
|
28 |
-
|
29 |
-
A
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/condition.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag takes a condition
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i in 1..5 if i is odd -%}
|
5 |
-
{{ loop.index }}.{{ i }}{{ foo.bar }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => ['bar' => 'X']]
|
9 |
-
--CONFIG--
|
10 |
-
return ['strict_variables' => false]
|
11 |
-
--EXPECT--
|
12 |
-
1.1X
|
13 |
-
2.3X
|
14 |
-
3.5X
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/context.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag keeps the context safe
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
{% for item in items %}
|
6 |
-
* {{ item }}
|
7 |
-
{% endfor %}
|
8 |
-
* {{ item }}
|
9 |
-
{% endfor %}
|
10 |
-
--DATA--
|
11 |
-
return ['items' => ['a', 'b']]
|
12 |
-
--EXPECT--
|
13 |
-
* a
|
14 |
-
* b
|
15 |
-
* a
|
16 |
-
* a
|
17 |
-
* b
|
18 |
-
* b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/else.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag can use an "else" clause
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
* {{ item }}
|
6 |
-
{% else %}
|
7 |
-
no item
|
8 |
-
{% endfor %}
|
9 |
-
--DATA--
|
10 |
-
return ['items' => ['a', 'b']]
|
11 |
-
--EXPECT--
|
12 |
-
* a
|
13 |
-
* b
|
14 |
-
--DATA--
|
15 |
-
return ['items' => []]
|
16 |
-
--EXPECT--
|
17 |
-
no item
|
18 |
-
--DATA--
|
19 |
-
return []
|
20 |
-
--CONFIG--
|
21 |
-
return ['strict_variables' => false]
|
22 |
-
--EXPECT--
|
23 |
-
no item
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/inner_variables.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag does not reset inner variables
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i in 1..2 %}
|
5 |
-
{% for j in 0..2 %}
|
6 |
-
{{k}}{% set k = k+1 %} {{ loop.parent.loop.index }}
|
7 |
-
{% endfor %}
|
8 |
-
{% endfor %}
|
9 |
-
--DATA--
|
10 |
-
return ['k' => 0]
|
11 |
-
--EXPECT--
|
12 |
-
0 1
|
13 |
-
1 1
|
14 |
-
2 1
|
15 |
-
3 2
|
16 |
-
4 2
|
17 |
-
5 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/keys.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag can iterate over keys
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for key in items|keys %}
|
5 |
-
* {{ key }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['items' => ['a', 'b']]
|
9 |
-
--EXPECT--
|
10 |
-
* 0
|
11 |
-
* 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/keys_and_values.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag can iterate over keys and values
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for key, item in items %}
|
5 |
-
* {{ key }}/{{ item }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['items' => ['a', 'b']]
|
9 |
-
--EXPECT--
|
10 |
-
* 0/a
|
11 |
-
* 1/b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/loop_context.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag adds a loop variable to the context
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
* {{ loop.index }}/{{ loop.index0 }}
|
6 |
-
* {{ loop.revindex }}/{{ loop.revindex0 }}
|
7 |
-
* {{ loop.first }}/{{ loop.last }}/{{ loop.length }}
|
8 |
-
|
9 |
-
{% endfor %}
|
10 |
-
--DATA--
|
11 |
-
return ['items' => ['a', 'b']]
|
12 |
-
--EXPECT--
|
13 |
-
* 1/0
|
14 |
-
* 2/1
|
15 |
-
* 1//2
|
16 |
-
|
17 |
-
* 2/1
|
18 |
-
* 1/0
|
19 |
-
* /1/2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/loop_context_local.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag adds a loop variable to the context locally
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
{% endfor %}
|
6 |
-
{% if loop is not defined %}WORKS{% endif %}
|
7 |
-
--DATA--
|
8 |
-
return ['items' => []]
|
9 |
-
--EXPECT--
|
10 |
-
WORKS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/loop_not_defined.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i, item in items if i > 0 %}
|
5 |
-
{{ loop.last }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['items' => ['a', 'b']]
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: The "loop.last" variable is not defined when looping with a condition in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/loop_not_defined_cond.test
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for i, item in items if loop.last > 0 %}
|
5 |
-
{% endfor %}
|
6 |
-
--DATA--
|
7 |
-
return ['items' => ['a', 'b']]
|
8 |
-
--EXCEPTION--
|
9 |
-
Twig\Error\SyntaxError: The "loop" variable cannot be used in a looping condition in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/nested_else.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag can use an "else" clause
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
{% for item in items1 %}
|
6 |
-
* {{ item }}
|
7 |
-
{% else %}
|
8 |
-
no {{ item }}
|
9 |
-
{% endfor %}
|
10 |
-
{% else %}
|
11 |
-
no item1
|
12 |
-
{% endfor %}
|
13 |
-
--DATA--
|
14 |
-
return ['items' => ['a', 'b'], 'items1' => []]
|
15 |
-
--EXPECT--
|
16 |
-
no a
|
17 |
-
no b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/objects.test
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag iterates over iterable objects
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
* {{ item }}
|
6 |
-
* {{ loop.index }}/{{ loop.index0 }}
|
7 |
-
* {{ loop.first }}
|
8 |
-
|
9 |
-
{% endfor %}
|
10 |
-
|
11 |
-
{% for key, value in items %}
|
12 |
-
* {{ key }}/{{ value }}
|
13 |
-
{% endfor %}
|
14 |
-
|
15 |
-
{% for key in items|keys %}
|
16 |
-
* {{ key }}
|
17 |
-
{% endfor %}
|
18 |
-
--DATA--
|
19 |
-
class ItemsIterator implements Iterator
|
20 |
-
{
|
21 |
-
protected $values = ['foo' => 'bar', 'bar' => 'foo'];
|
22 |
-
public function current() { return current($this->values); }
|
23 |
-
public function key() { return key($this->values); }
|
24 |
-
public function next() { return next($this->values); }
|
25 |
-
public function rewind() { return reset($this->values); }
|
26 |
-
public function valid() { return false !== current($this->values); }
|
27 |
-
}
|
28 |
-
return ['items' => new ItemsIterator()]
|
29 |
-
--EXPECT--
|
30 |
-
* bar
|
31 |
-
* 1/0
|
32 |
-
* 1
|
33 |
-
|
34 |
-
* foo
|
35 |
-
* 2/1
|
36 |
-
*
|
37 |
-
|
38 |
-
|
39 |
-
* foo/bar
|
40 |
-
* bar/foo
|
41 |
-
|
42 |
-
* foo
|
43 |
-
* bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/objects_countable.test
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag iterates over iterable and countable objects
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
* {{ item }}
|
6 |
-
* {{ loop.index }}/{{ loop.index0 }}
|
7 |
-
* {{ loop.revindex }}/{{ loop.revindex0 }}
|
8 |
-
* {{ loop.first }}/{{ loop.last }}/{{ loop.length }}
|
9 |
-
|
10 |
-
{% endfor %}
|
11 |
-
|
12 |
-
{% for key, value in items %}
|
13 |
-
* {{ key }}/{{ value }}
|
14 |
-
{% endfor %}
|
15 |
-
|
16 |
-
{% for key in items|keys %}
|
17 |
-
* {{ key }}
|
18 |
-
{% endfor %}
|
19 |
-
--DATA--
|
20 |
-
class ItemsIteratorCountable implements Iterator, \Countable
|
21 |
-
{
|
22 |
-
protected $values = ['foo' => 'bar', 'bar' => 'foo'];
|
23 |
-
public function current() { return current($this->values); }
|
24 |
-
public function key() { return key($this->values); }
|
25 |
-
public function next() { return next($this->values); }
|
26 |
-
public function rewind() { return reset($this->values); }
|
27 |
-
public function valid() { return false !== current($this->values); }
|
28 |
-
public function count() { return count($this->values); }
|
29 |
-
}
|
30 |
-
return ['items' => new ItemsIteratorCountable()]
|
31 |
-
--EXPECT--
|
32 |
-
* bar
|
33 |
-
* 1/0
|
34 |
-
* 2/1
|
35 |
-
* 1//2
|
36 |
-
|
37 |
-
* foo
|
38 |
-
* 2/1
|
39 |
-
* 1/0
|
40 |
-
* /1/2
|
41 |
-
|
42 |
-
|
43 |
-
* foo/bar
|
44 |
-
* bar/foo
|
45 |
-
|
46 |
-
* foo
|
47 |
-
* bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/recursive.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tags can be nested
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for key, item in items %}
|
5 |
-
* {{ key }} ({{ loop.length }}):
|
6 |
-
{% for value in item %}
|
7 |
-
* {{ value }} ({{ loop.length }})
|
8 |
-
{% endfor %}
|
9 |
-
{% endfor %}
|
10 |
-
--DATA--
|
11 |
-
return ['items' => ['a' => ['a1', 'a2', 'a3'], 'b' => ['b1']]]
|
12 |
-
--EXPECT--
|
13 |
-
* a (2):
|
14 |
-
* a1 (3)
|
15 |
-
* a2 (3)
|
16 |
-
* a3 (3)
|
17 |
-
* b (2):
|
18 |
-
* b1 (1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/for/values.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"for" tag iterates over item values
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for item in items %}
|
5 |
-
* {{ item }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['items' => ['a', 'b']]
|
9 |
-
--EXPECT--
|
10 |
-
* a
|
11 |
-
* b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/from.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
global variables
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include "included.twig" %}
|
5 |
-
{% from "included.twig" import foobar %}
|
6 |
-
{{ foobar() }}
|
7 |
-
--TEMPLATE(included.twig)--
|
8 |
-
{% macro foobar() %}
|
9 |
-
called foobar
|
10 |
-
{% endmacro %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
called foobar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/if/basic.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"if" creates a condition
|
3 |
-
--TEMPLATE--
|
4 |
-
{% if a is defined %}
|
5 |
-
{{ a }}
|
6 |
-
{% elseif b is defined %}
|
7 |
-
{{ b }}
|
8 |
-
{% else %}
|
9 |
-
NOTHING
|
10 |
-
{% endif %}
|
11 |
-
--DATA--
|
12 |
-
return ['a' => 'a']
|
13 |
-
--EXPECT--
|
14 |
-
a
|
15 |
-
--DATA--
|
16 |
-
return ['b' => 'b']
|
17 |
-
--EXPECT--
|
18 |
-
b
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
NOTHING
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/if/expression.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"if" takes an expression as a test
|
3 |
-
--TEMPLATE--
|
4 |
-
{% if a < 2 %}
|
5 |
-
A1
|
6 |
-
{% elseif a > 10 %}
|
7 |
-
A2
|
8 |
-
{% else %}
|
9 |
-
A3
|
10 |
-
{% endif %}
|
11 |
-
--DATA--
|
12 |
-
return ['a' => 1]
|
13 |
-
--EXPECT--
|
14 |
-
A1
|
15 |
-
--DATA--
|
16 |
-
return ['a' => 12]
|
17 |
-
--EXPECT--
|
18 |
-
A2
|
19 |
-
--DATA--
|
20 |
-
return ['a' => 7]
|
21 |
-
--EXPECT--
|
22 |
-
A3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/basic.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% include "foo.twig" %}
|
6 |
-
|
7 |
-
BAR
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
FOOBAR
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
FOO
|
14 |
-
|
15 |
-
FOOBAR
|
16 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/expression.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag allows expressions for the template to include
|
3 |
-
--TEMPLATE--
|
4 |
-
FOO
|
5 |
-
{% include foo %}
|
6 |
-
|
7 |
-
BAR
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
FOOBAR
|
10 |
-
--DATA--
|
11 |
-
return ['foo' => 'foo.twig']
|
12 |
-
--EXPECT--
|
13 |
-
FOO
|
14 |
-
|
15 |
-
FOOBAR
|
16 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/ignore_missing.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include ["foo.twig", "bar.twig"] ignore missing %}
|
5 |
-
{% include "foo.twig" ignore missing %}
|
6 |
-
{% include "foo.twig" ignore missing with {} %}
|
7 |
-
{% include "foo.twig" ignore missing with {} only %}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/ignore_missing_exists.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include "included.twig" ignore missing %}
|
5 |
-
NOT DISPLAYED
|
6 |
-
--TEMPLATE(included.twig)--
|
7 |
-
{% include "DOES NOT EXIST" %}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXCEPTION--
|
11 |
-
Twig\Error\LoaderError: Template "DOES NOT EXIST" is not defined in "included.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/include_missing_extends.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include ['bad.twig', 'good.twig'] ignore missing %}
|
5 |
-
NOT DISPLAYED
|
6 |
-
--TEMPLATE(bad.twig)--
|
7 |
-
{% extends 'DOES NOT EXIST' %}
|
8 |
-
--TEMPLATE(good.twig)--
|
9 |
-
NOT DISPLAYED
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXCEPTION--
|
13 |
-
Twig\Error\LoaderError: Template "DOES NOT EXIST" is not defined in "bad.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/missing.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include "foo.twig" %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\LoaderError: Template "foo.twig" is not defined in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/missing_nested.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{{ parent() }}
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(base.twig)--
|
10 |
-
{% block content %}
|
11 |
-
{% include "foo.twig" %}
|
12 |
-
{% endblock %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXCEPTION--
|
16 |
-
Twig\Error\LoaderError: Template "foo.twig" is not defined in "base.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/only.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag accept variables and only
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include "foo.twig" %}
|
5 |
-
{% include "foo.twig" only %}
|
6 |
-
{% include "foo.twig" with vars1 %}
|
7 |
-
{% include "foo.twig" with vars1 only %}
|
8 |
-
{% include "foo.twig" with vars2 %}
|
9 |
-
{% include "foo.twig" with vars2 only %}
|
10 |
-
--TEMPLATE(foo.twig)--
|
11 |
-
{% for k, v in _context %}{{ k }},{% endfor %}
|
12 |
-
--DATA--
|
13 |
-
return ['vars1' => ['foo1' => 'bar'], 'vars2' => new ArrayObject(['foo2' => 'bar'])]
|
14 |
-
--EXPECT--
|
15 |
-
vars1,vars2,global,_parent,
|
16 |
-
global,_parent,
|
17 |
-
vars1,vars2,global,foo1,_parent,
|
18 |
-
foo1,global,_parent,
|
19 |
-
vars1,vars2,global,foo2,_parent,
|
20 |
-
foo2,global,_parent,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/template_instance.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag accepts \Twig\TemplateWrapper instance
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include foo %} FOO
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
BAR
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => $twig->load('foo.twig')]
|
9 |
-
--EXPECT--
|
10 |
-
BAR FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/templates_as_array.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include ["foo.twig", "bar.twig"] %}
|
5 |
-
{% include ["bar.twig", "foo.twig"] %}
|
6 |
-
--TEMPLATE(foo.twig)--
|
7 |
-
foo
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
foo
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/include/with_variables.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"include" tag accept variables
|
3 |
-
--TEMPLATE--
|
4 |
-
{% include "foo.twig" with {'foo': 'bar'} %}
|
5 |
-
{% include "foo.twig" with vars1 %}
|
6 |
-
{% include "foo.twig" with vars2 %}
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
{{ foo }}
|
9 |
-
--DATA--
|
10 |
-
return ['vars1' => ['foo' => 'bar'], 'vars2' => new ArrayObject(['foo' => 'bar'])]
|
11 |
-
--EXPECT--
|
12 |
-
bar
|
13 |
-
bar
|
14 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/basic.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "foo.twig" %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
FOO
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(foo.twig)--
|
10 |
-
{% block content %}{% endblock %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/block_expr.test
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
block_expr
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
|
6 |
-
{% block element -%}
|
7 |
-
Element:
|
8 |
-
{{- parent() -}}
|
9 |
-
{% endblock %}
|
10 |
-
--TEMPLATE(base.twig)--
|
11 |
-
{% block element -%}
|
12 |
-
<div>
|
13 |
-
{%- if item.children is defined %}
|
14 |
-
{%- for item in item.children %}
|
15 |
-
{{- block('element') -}}
|
16 |
-
{% endfor %}
|
17 |
-
{%- endif -%}
|
18 |
-
</div>
|
19 |
-
{%- endblock %}
|
20 |
-
--DATA--
|
21 |
-
return [
|
22 |
-
'item' => [
|
23 |
-
'children' => [
|
24 |
-
null,
|
25 |
-
null,
|
26 |
-
]
|
27 |
-
]
|
28 |
-
]
|
29 |
-
--EXPECT--
|
30 |
-
Element:<div>Element:<div></div>Element:<div></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/block_expr2.test
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
block_expr2
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base2.twig" %}
|
5 |
-
|
6 |
-
{% block element -%}
|
7 |
-
Element:
|
8 |
-
{{- parent() -}}
|
9 |
-
{% endblock %}
|
10 |
-
--TEMPLATE(base2.twig)--
|
11 |
-
{% extends "base.twig" %}
|
12 |
-
--TEMPLATE(base.twig)--
|
13 |
-
{% block element -%}
|
14 |
-
<div>
|
15 |
-
{%- if item.children is defined %}
|
16 |
-
{%- for item in item.children %}
|
17 |
-
{{- block('element') -}}
|
18 |
-
{% endfor %}
|
19 |
-
{%- endif -%}
|
20 |
-
</div>
|
21 |
-
{%- endblock %}
|
22 |
-
--DATA--
|
23 |
-
return [
|
24 |
-
'item' => [
|
25 |
-
'children' => [
|
26 |
-
null,
|
27 |
-
null,
|
28 |
-
]
|
29 |
-
]
|
30 |
-
]
|
31 |
-
--EXPECT--
|
32 |
-
Element:<div>Element:<div></div>Element:<div></div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/conditional.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends standalone ? foo : 'bar.twig' %}
|
5 |
-
|
6 |
-
{% block content %}{{ parent() }}FOO{% endblock %}
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
{% block content %}FOO{% endblock %}
|
9 |
-
--TEMPLATE(bar.twig)--
|
10 |
-
{% block content %}BAR{% endblock %}
|
11 |
-
--DATA--
|
12 |
-
return ['foo' => 'foo.twig', 'standalone' => true]
|
13 |
-
--EXPECT--
|
14 |
-
FOOFOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/dynamic.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends foo %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
FOO
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(foo.twig)--
|
10 |
-
{% block content %}{% endblock %}
|
11 |
-
--DATA--
|
12 |
-
return ['foo' => 'foo.twig']
|
13 |
-
--EXPECT--
|
14 |
-
FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/empty.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "foo.twig" %}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
{% block content %}FOO{% endblock %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
FOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends ["foo.twig", "bar.twig"] %}
|
5 |
-
--TEMPLATE(bar.twig)--
|
6 |
-
{% block content %}
|
7 |
-
foo
|
8 |
-
{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array_with_empty_name.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends ["", "bar.twig"] %}
|
5 |
-
--TEMPLATE(bar.twig)--
|
6 |
-
{% block content %}
|
7 |
-
foo
|
8 |
-
{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_as_array_with_null_name.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends [null, "bar.twig"] %}
|
5 |
-
--TEMPLATE(bar.twig)--
|
6 |
-
{% block content %}
|
7 |
-
foo
|
8 |
-
{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_in_block.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag in a block
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{% extends "foo.twig" %}
|
6 |
-
{% endblock %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Cannot use "extend" in a block in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/extends_in_macro.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag in a macro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% macro foo() %}
|
5 |
-
{% extends "foo.twig" %}
|
6 |
-
{% endmacro %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Cannot use "extend" in a macro in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/multiple.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "layout.twig" %}{% block content %}{{ parent() }}index {% endblock %}
|
5 |
-
--TEMPLATE(layout.twig)--
|
6 |
-
{% extends "base.twig" %}{% block content %}{{ parent() }}layout {% endblock %}
|
7 |
-
--TEMPLATE(base.twig)--
|
8 |
-
{% block content %}base {% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
base layout index
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/multiple_dynamic.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = 1 %}
|
5 |
-
{{ include('parent.twig') }}
|
6 |
-
{{ include('parent.twig') }}
|
7 |
-
{% set foo = 2 %}
|
8 |
-
{{ include('parent.twig') }}
|
9 |
-
--TEMPLATE(parent.twig)--
|
10 |
-
{% extends foo~'_parent.twig' %}{% block content %}{{ parent() }} parent{% endblock %}
|
11 |
-
--TEMPLATE(1_parent.twig)--
|
12 |
-
{% block content %}1{% endblock %}
|
13 |
-
--TEMPLATE(2_parent.twig)--
|
14 |
-
{% block content %}2{% endblock %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
1 parent
|
19 |
-
|
20 |
-
1 parent
|
21 |
-
|
22 |
-
2 parent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_blocks.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "foo.twig" %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{% block subcontent %}
|
8 |
-
{% block subsubcontent %}
|
9 |
-
SUBSUBCONTENT
|
10 |
-
{% endblock %}
|
11 |
-
{% endblock %}
|
12 |
-
{% endblock %}
|
13 |
-
--TEMPLATE(foo.twig)--
|
14 |
-
{% block content %}
|
15 |
-
{% block subcontent %}
|
16 |
-
SUBCONTENT
|
17 |
-
{% endblock %}
|
18 |
-
{% endblock %}
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
SUBSUBCONTENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_blocks_parent_only.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block content %}
|
5 |
-
CONTENT
|
6 |
-
{%- block subcontent -%}
|
7 |
-
SUBCONTENT
|
8 |
-
{%- endblock -%}
|
9 |
-
ENDCONTENT
|
10 |
-
{% endblock %}
|
11 |
-
--TEMPLATE(foo.twig)--
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
CONTENTSUBCONTENTENDCONTENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/nested_inheritance.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "layout.twig" %}
|
5 |
-
{% block inside %}INSIDE{% endblock inside %}
|
6 |
-
--TEMPLATE(layout.twig)--
|
7 |
-
{% extends "base.twig" %}
|
8 |
-
{% block body %}
|
9 |
-
{% block inside '' %}
|
10 |
-
{% endblock body %}
|
11 |
-
--TEMPLATE(base.twig)--
|
12 |
-
{% block body '' %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
INSIDE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "foo.twig" %}
|
5 |
-
|
6 |
-
{% block content %}{{ parent() }}FOO{{ parent() }}{% endblock %}
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
{% block content %}BAR{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
BARFOOBAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_as_template_wrapper.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag with a parent as a Twig_TemplateWrapper instance
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends foo %}
|
5 |
-
|
6 |
-
{% block content %}New{% endblock %}
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
{% block content %}Default{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return ['foo' => $twig->load('foo.twig')]
|
11 |
-
--EXPECT--
|
12 |
-
New
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_change.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends foo ? 'foo.twig' : 'bar.twig' %}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
FOO
|
7 |
-
--TEMPLATE(bar.twig)--
|
8 |
-
BAR
|
9 |
-
--DATA--
|
10 |
-
return ['foo' => true]
|
11 |
-
--EXPECT--
|
12 |
-
FOO
|
13 |
-
--DATA--
|
14 |
-
return ['foo' => false]
|
15 |
-
--EXPECT--
|
16 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_isolation.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
{% block content %}{% include "included.twig" %}{% endblock %}
|
6 |
-
|
7 |
-
{% block footer %}Footer{% endblock %}
|
8 |
-
--TEMPLATE(included.twig)--
|
9 |
-
{% extends "base.twig" %}
|
10 |
-
{% block content %}Included Content{% endblock %}
|
11 |
-
--TEMPLATE(base.twig)--
|
12 |
-
{% block content %}Default Content{% endblock %}
|
13 |
-
|
14 |
-
{% block footer %}Default Footer{% endblock %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
Included Content
|
19 |
-
Default Footer
|
20 |
-
Footer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_nested.test
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "foo.twig" %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{% block inside %}
|
8 |
-
INSIDE OVERRIDDEN
|
9 |
-
{% endblock %}
|
10 |
-
|
11 |
-
BEFORE
|
12 |
-
{{ parent() }}
|
13 |
-
AFTER
|
14 |
-
{% endblock %}
|
15 |
-
--TEMPLATE(foo.twig)--
|
16 |
-
{% block content %}
|
17 |
-
BAR
|
18 |
-
{% endblock %}
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
|
23 |
-
INSIDE OVERRIDDEN
|
24 |
-
|
25 |
-
BEFORE
|
26 |
-
BAR
|
27 |
-
|
28 |
-
AFTER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_without_extends.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"parent" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block content %}
|
5 |
-
{{ parent() }}
|
6 |
-
{% endblock %}
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Calling "parent" on a template that does not extend nor "use" another template is forbidden in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/parent_without_extends_but_traits.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"parent" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'foo.twig' %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{{ parent() }}
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(foo.twig)--
|
10 |
-
{% block content %}BAR{% endblock %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
BAR
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/template_instance.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"extends" tag accepts Twig_Template instance
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends foo %}
|
5 |
-
|
6 |
-
{% block content %}
|
7 |
-
{{ parent() }}FOO
|
8 |
-
{% endblock %}
|
9 |
-
--TEMPLATE(foo.twig)--
|
10 |
-
{% block content %}BAR{% endblock %}
|
11 |
-
--DATA--
|
12 |
-
return ['foo' => $twig->load('foo.twig')]
|
13 |
-
--EXPECT--
|
14 |
-
BARFOO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/inheritance/use.test
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"parent" function
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "parent.twig" %}
|
5 |
-
|
6 |
-
{% use "use1.twig" %}
|
7 |
-
{% use "use2.twig" %}
|
8 |
-
|
9 |
-
{% block content_parent %}
|
10 |
-
{{ parent() }}
|
11 |
-
{% endblock %}
|
12 |
-
|
13 |
-
{% block content_use1 %}
|
14 |
-
{{ parent() }}
|
15 |
-
{% endblock %}
|
16 |
-
|
17 |
-
{% block content_use2 %}
|
18 |
-
{{ parent() }}
|
19 |
-
{% endblock %}
|
20 |
-
|
21 |
-
{% block content %}
|
22 |
-
{{ block('content_use1_only') }}
|
23 |
-
{{ block('content_use2_only') }}
|
24 |
-
{% endblock %}
|
25 |
-
--TEMPLATE(parent.twig)--
|
26 |
-
{% block content_parent 'content_parent' %}
|
27 |
-
{% block content_use1 'content_parent' %}
|
28 |
-
{% block content_use2 'content_parent' %}
|
29 |
-
{% block content '' %}
|
30 |
-
--TEMPLATE(use1.twig)--
|
31 |
-
{% block content_use1 'content_use1' %}
|
32 |
-
{% block content_use2 'content_use1' %}
|
33 |
-
{% block content_use1_only 'content_use1_only' %}
|
34 |
-
--TEMPLATE(use2.twig)--
|
35 |
-
{% block content_use2 'content_use2' %}
|
36 |
-
{% block content_use2_only 'content_use2_only' %}
|
37 |
-
--DATA--
|
38 |
-
return []
|
39 |
-
--EXPECT--
|
40 |
-
content_parent
|
41 |
-
content_use1
|
42 |
-
content_use2
|
43 |
-
content_use1_only
|
44 |
-
content_use2_only
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/basic.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{{ macros.input('username') }}
|
7 |
-
{{ macros.input('password', null, 'password', 1) }}
|
8 |
-
|
9 |
-
{% macro input(name, value, type, size) %}
|
10 |
-
<input type="{{ type|default("text") }}" name="{{ name }}" value="{{ value|e|default('') }}" size="{{ size|default(20) }}">
|
11 |
-
{% endmacro %}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
<input type="text" name="username" value="" size="20">
|
16 |
-
|
17 |
-
<input type="password" name="password" value="" size="1">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/endmacro_name.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag supports name for endmacro
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{{ macros.foo() }}
|
7 |
-
{{ macros.bar() }}
|
8 |
-
|
9 |
-
{% macro foo() %}foo{% endmacro %}
|
10 |
-
{% macro bar() %}bar{% endmacro bar %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
foo
|
15 |
-
bar
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/external.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import 'forms.twig' as forms %}
|
5 |
-
|
6 |
-
{{ forms.input('username') }}
|
7 |
-
{{ forms.input('password', null, 'password', 1) }}
|
8 |
-
--TEMPLATE(forms.twig)--
|
9 |
-
{% macro input(name, value, type, size) %}
|
10 |
-
<input type="{{ type|default("text") }}" name="{{ name }}" value="{{ value|e|default('') }}" size="{{ size|default(20) }}">
|
11 |
-
{% endmacro %}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
<input type="text" name="username" value="" size="20">
|
16 |
-
|
17 |
-
<input type="password" name="password" value="" size="1">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from 'forms.twig' import foo %}
|
5 |
-
{% from 'forms.twig' import foo as foobar, bar %}
|
6 |
-
|
7 |
-
{{ foo('foo') }}
|
8 |
-
{{ foobar('foo') }}
|
9 |
-
{{ bar('foo') }}
|
10 |
-
--TEMPLATE(forms.twig)--
|
11 |
-
{% macro foo(name) %}foo{{ name }}{% endmacro %}
|
12 |
-
{% macro bar(name) %}bar{{ name }}{% endmacro %}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
foofoo
|
17 |
-
foofoo
|
18 |
-
barfoo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_in_block_is_local.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{%- from _self import input as linput %}
|
6 |
-
{% endblock %}
|
7 |
-
|
8 |
-
{% block bar %}
|
9 |
-
{{- linput('username') }}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\SyntaxError: Unknown "linput" function in "index.twig" at line 7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_local_override.test
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- from _self import input %}
|
5 |
-
|
6 |
-
{% block foo %}
|
7 |
-
{%- from "macros" import input %}
|
8 |
-
{{- input('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
|
11 |
-
{% block bar %}
|
12 |
-
{{- input('username') }}
|
13 |
-
{% endblock %}
|
14 |
-
|
15 |
-
{% macro input(name) -%}
|
16 |
-
<input name="{{ name }}">
|
17 |
-
{% endmacro %}
|
18 |
-
--TEMPLATE(macros)--
|
19 |
-
{% macro input(name) %}
|
20 |
-
<input name="{{ name }}" value="local">
|
21 |
-
{% endmacro %}
|
22 |
-
--DATA--
|
23 |
-
return []
|
24 |
-
--EXPECT--
|
25 |
-
<input name="username" value="local">
|
26 |
-
|
27 |
-
|
28 |
-
<input name="username">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_macro_in_a_macro.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"from" tag with syntax error
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from _self import another, foo %}
|
5 |
-
|
6 |
-
{{ foo() }}
|
7 |
-
|
8 |
-
{% macro foo() %}
|
9 |
-
{{ another() }}
|
10 |
-
{% endmacro %}
|
11 |
-
|
12 |
-
{% macro another() %}
|
13 |
-
OK
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\SyntaxError: Unknown "another" function in "index.twig" at line 7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_nested_blocks.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{%- from _self import input as linput %}
|
6 |
-
|
7 |
-
{% block bar %}
|
8 |
-
{{- linput('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\SyntaxError: Unknown "linput" function in "index.twig" at line 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_nested_blocks_with_global_macro.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- from _self import input %}
|
5 |
-
|
6 |
-
{% block foo %}
|
7 |
-
{% block bar %}
|
8 |
-
{{- input('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\SyntaxError: Unknown "input" function in "index.twig" at line 6.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_syntax_error.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"from" tag with syntax error
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from 'forms.twig' %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: Unexpected token "end of statement block" ("name" expected with value "import") in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/from_with_reserved_name.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"from" tag with reserved name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from 'forms.twig' import templateName %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: "templateName" cannot be an imported macro as it is a reserved keyword in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/global.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% from 'forms.twig' import foo %}
|
5 |
-
|
6 |
-
{{ foo('foo') }}
|
7 |
-
{{ foo() }}
|
8 |
-
--TEMPLATE(forms.twig)--
|
9 |
-
{% macro foo(name) %}{{ name|default('foo') }}{{ global }}{% endmacro %}
|
10 |
-
--DATA--
|
11 |
-
return []
|
12 |
-
--EXPECT--
|
13 |
-
fooglobal
|
14 |
-
fooglobal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_and_blocks.test
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
{% from _self import input %}
|
6 |
-
|
7 |
-
{% block foo %}
|
8 |
-
{{- macros.input('username') }}
|
9 |
-
{{- input('username') }}
|
10 |
-
|
11 |
-
{%- import _self as lmacros %}
|
12 |
-
{%- from _self import input as linput %}
|
13 |
-
|
14 |
-
{{- lmacros.input('username') }}
|
15 |
-
{{- linput('username') }}
|
16 |
-
{% endblock %}
|
17 |
-
|
18 |
-
{% block bar %}
|
19 |
-
{{- macros.input('username') }}
|
20 |
-
{{- input('username') }}
|
21 |
-
{% endblock %}
|
22 |
-
|
23 |
-
{% macro input(name) -%}
|
24 |
-
<input name="{{ name }}">
|
25 |
-
{% endmacro %}
|
26 |
-
--DATA--
|
27 |
-
return []
|
28 |
-
--EXPECT--
|
29 |
-
<input name="username">
|
30 |
-
<input name="username">
|
31 |
-
<input name="username">
|
32 |
-
<input name="username">
|
33 |
-
|
34 |
-
|
35 |
-
<input name="username">
|
36 |
-
<input name="username">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_from_string_template.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"import" tag with a template as string
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import template_from_string("{% macro test() %}ok{% endmacro %}") as m %}
|
5 |
-
{{ m.test() }}
|
6 |
-
--TEMPLATE(forms.twig)--
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_in_block_is_local.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{%- import _self as lmacros %}
|
6 |
-
{% endblock %}
|
7 |
-
|
8 |
-
{% block bar %}
|
9 |
-
{{- lmacros.input('username') }}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\RuntimeError: Variable "lmacros" does not exist in "index.twig" at line 7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_local_override.test
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- import _self as macros %}
|
5 |
-
|
6 |
-
{% block foo %}
|
7 |
-
{%- import "macros" as macros %}
|
8 |
-
{{- macros.input('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
|
11 |
-
{% block bar %}
|
12 |
-
{{- macros.input('username') }}
|
13 |
-
{% endblock %}
|
14 |
-
|
15 |
-
{% macro input(name) -%}
|
16 |
-
<input name="{{ name }}">
|
17 |
-
{% endmacro %}
|
18 |
-
--TEMPLATE(macros)--
|
19 |
-
{% macro input(name) %}
|
20 |
-
<input name="{{ name }}" value="local">
|
21 |
-
{% endmacro %}
|
22 |
-
--DATA--
|
23 |
-
return []
|
24 |
-
--EXPECT--
|
25 |
-
<input name="username" value="local">
|
26 |
-
|
27 |
-
|
28 |
-
<input name="username">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_macro_in_a_macro.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"import" tag with syntax error
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as foo %}
|
5 |
-
|
6 |
-
{{ foo.foo() }}
|
7 |
-
|
8 |
-
{% macro foo() %}
|
9 |
-
{{ foo.another() }}
|
10 |
-
{% endmacro %}
|
11 |
-
|
12 |
-
{% macro another() %}
|
13 |
-
OK
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXCEPTION--
|
18 |
-
Twig\Error\RuntimeError: Variable "foo" does not exist in "index.twig" at line 7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_nested_blocks.legacy.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% block foo %}
|
5 |
-
{%- import _self as lmacros %}
|
6 |
-
|
7 |
-
{% block bar %}
|
8 |
-
{{- lmacros.input('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
<input name="username">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_nested_blocks_with_global_macro.legacy.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- import _self as macros %}
|
5 |
-
|
6 |
-
{% block foo %}
|
7 |
-
{% block bar %}
|
8 |
-
{{- macros.input('username') }}
|
9 |
-
{% endblock %}
|
10 |
-
{% endblock %}
|
11 |
-
|
12 |
-
{% macro input(name) -%}
|
13 |
-
<input name="{{ name }}">
|
14 |
-
{% endmacro %}
|
15 |
-
--DATA--
|
16 |
-
return []
|
17 |
-
--EXPECT--
|
18 |
-
<input name="username">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_self_parent.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "parent" %}
|
5 |
-
{% import _self as me %}
|
6 |
-
|
7 |
-
{% block test %}
|
8 |
-
{{ me.hello() }}
|
9 |
-
{% endblock test %}
|
10 |
-
--TEMPLATE(parent)--
|
11 |
-
{% import _self as me %}
|
12 |
-
|
13 |
-
{% block test %}
|
14 |
-
Hello
|
15 |
-
{% endblock test %}
|
16 |
-
|
17 |
-
{% macro hello() %}
|
18 |
-
Test
|
19 |
-
{% endmacro %}
|
20 |
-
--DATA--
|
21 |
-
return []
|
22 |
-
--EXPECT--
|
23 |
-
Test
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_syntax_error.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"import" tag with reserved name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import 'forms.twig' %}
|
5 |
-
|
6 |
-
{{ macros.parent() }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Unexpected token "end of statement block" ("name" expected with value "as") in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/import_with_reserved_name.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"from" tag with reserved name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import 'forms.twig' as macros %}
|
5 |
-
|
6 |
-
{{ macros.parent() }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: "parent" cannot be called as macro as it is a reserved keyword in "index.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/reserved_name.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag with reserved name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% macro parent(arg1, arg2) %}
|
5 |
-
parent
|
6 |
-
{% endmacro %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: "parent" cannot be used as a macro name as it is a reserved keyword in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/self_import.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"macro" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as forms %}
|
5 |
-
|
6 |
-
{{ forms.input('username') }}
|
7 |
-
{{ forms.input('password', null, 'password', 1) }}
|
8 |
-
|
9 |
-
{% macro input(name, value, type, size) %}
|
10 |
-
<input type="{{ type|default("text") }}" name="{{ name }}" value="{{ value|e|default('') }}" size="{{ size|default(20) }}">
|
11 |
-
{% endmacro %}
|
12 |
-
--DATA--
|
13 |
-
return []
|
14 |
-
--EXPECT--
|
15 |
-
<input type="text" name="username" value="" size="20">
|
16 |
-
|
17 |
-
<input type="password" name="password" value="" size="1">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/special_chars.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"§" as a macro name
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{{ macros.§('foo') }}
|
7 |
-
|
8 |
-
{% macro §(foo) %}
|
9 |
-
§{{ foo }}§
|
10 |
-
{% endmacro %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
§foo§
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/macro/super_globals.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Super globals as macro arguments
|
3 |
-
--TEMPLATE--
|
4 |
-
{% import _self as macros %}
|
5 |
-
|
6 |
-
{{ macros.foo('foo') }}
|
7 |
-
|
8 |
-
{% macro foo(GET) %}
|
9 |
-
{{ GET }}
|
10 |
-
{% endmacro %}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/raw/basic.legacy.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"raw" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% raw %}
|
5 |
-
{{ foo }}
|
6 |
-
{% endraw %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
{{ foo }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"raw" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% raw %}
|
5 |
-
{{ foo }}
|
6 |
-
{% endverbatim %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Unexpected end of file: Unclosed "raw" block in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/raw/whitespace_control.legacy.test
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"raw" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
1***
|
5 |
-
|
6 |
-
{%- raw %}
|
7 |
-
{{ 'bla' }}
|
8 |
-
{% endraw %}
|
9 |
-
|
10 |
-
1***
|
11 |
-
2***
|
12 |
-
|
13 |
-
{%- raw -%}
|
14 |
-
{{ 'bla' }}
|
15 |
-
{% endraw %}
|
16 |
-
|
17 |
-
2***
|
18 |
-
3***
|
19 |
-
|
20 |
-
{%- raw -%}
|
21 |
-
{{ 'bla' }}
|
22 |
-
{% endraw -%}
|
23 |
-
|
24 |
-
3***
|
25 |
-
4***
|
26 |
-
|
27 |
-
{%- raw -%}
|
28 |
-
{{ 'bla' }}
|
29 |
-
{%- endraw %}
|
30 |
-
|
31 |
-
4***
|
32 |
-
5***
|
33 |
-
|
34 |
-
{%- raw -%}
|
35 |
-
{{ 'bla' }}
|
36 |
-
{%- endraw -%}
|
37 |
-
|
38 |
-
5***
|
39 |
-
--DATA--
|
40 |
-
return []
|
41 |
-
--EXPECT--
|
42 |
-
1***
|
43 |
-
{{ 'bla' }}
|
44 |
-
|
45 |
-
|
46 |
-
1***
|
47 |
-
2***{{ 'bla' }}
|
48 |
-
|
49 |
-
|
50 |
-
2***
|
51 |
-
3***{{ 'bla' }}
|
52 |
-
3***
|
53 |
-
4***{{ 'bla' }}
|
54 |
-
|
55 |
-
4***
|
56 |
-
5***{{ 'bla' }}5***
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/sandbox/array.test
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
sandbox tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- sandbox %}
|
5 |
-
{%- include "foo.twig" %}
|
6 |
-
{%- endsandbox %}
|
7 |
-
--TEMPLATE(foo.twig)--
|
8 |
-
{{ [a][0] }}
|
9 |
-
{{ dump([a][0]) }}
|
10 |
-
--DATA--
|
11 |
-
return ['a' => 'b']
|
12 |
-
--CONFIG--
|
13 |
-
return ['autoescape' => false, 'debug' => true]
|
14 |
-
--EXPECT--
|
15 |
-
b
|
16 |
-
string(1) "b"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/sandbox/not_valid1.test
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
sandbox tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- sandbox %}
|
5 |
-
{%- include "foo.twig" %}
|
6 |
-
a
|
7 |
-
{%- endsandbox %}
|
8 |
-
--TEMPLATE(foo.twig)--
|
9 |
-
foo
|
10 |
-
--EXCEPTION--
|
11 |
-
Twig\Error\SyntaxError: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 4.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/sandbox/not_valid2.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
sandbox tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- sandbox %}
|
5 |
-
{%- include "foo.twig" %}
|
6 |
-
|
7 |
-
{% if 1 %}
|
8 |
-
{%- include "foo.twig" %}
|
9 |
-
{% endif %}
|
10 |
-
{%- endsandbox %}
|
11 |
-
--TEMPLATE(foo.twig)--
|
12 |
-
foo
|
13 |
-
--EXCEPTION--
|
14 |
-
Twig\Error\SyntaxError: Only "include" tags are allowed within a "sandbox" section in "index.twig" at line 5.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/sandbox/simple.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
sandbox tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{%- sandbox %}
|
5 |
-
{%- include "foo.twig" %}
|
6 |
-
{%- endsandbox %}
|
7 |
-
|
8 |
-
{%- sandbox %}
|
9 |
-
{%- include "foo.twig" %}
|
10 |
-
{%- include "foo.twig" %}
|
11 |
-
{%- endsandbox %}
|
12 |
-
|
13 |
-
{%- sandbox %}{% include "foo.twig" %}{% endsandbox %}
|
14 |
-
--TEMPLATE(foo.twig)--
|
15 |
-
foo
|
16 |
-
--DATA--
|
17 |
-
return []
|
18 |
-
--EXPECT--
|
19 |
-
foo
|
20 |
-
foo
|
21 |
-
foo
|
22 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/basic.test
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = 'foo' %}
|
5 |
-
{% set bar = 'foo<br />' %}
|
6 |
-
|
7 |
-
{{ foo }}
|
8 |
-
{{ bar }}
|
9 |
-
|
10 |
-
{% set foo, bar = 'foo', 'bar' %}
|
11 |
-
|
12 |
-
{{ foo }}{{ bar }}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
foo
|
17 |
-
foo<br />
|
18 |
-
|
19 |
-
|
20 |
-
foobar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/capture-empty.test
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag block empty capture
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo %}{% endset %}
|
5 |
-
|
6 |
-
{% if foo %}FAIL{% endif %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/capture.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag block capture
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo %}f<br />o<br />o{% endset %}
|
5 |
-
|
6 |
-
{{ foo }}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
f<br />o<br />o
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/capture_scope.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag block capture
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo %}{{ foo }}{% endset %}
|
5 |
-
|
6 |
-
{{ foo }}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => 'foo']
|
9 |
-
--EXPECT--
|
10 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/expression.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo, bar = 'foo' ~ 'bar', 'bar' ~ 'foo' %}
|
5 |
-
|
6 |
-
{{ foo }}
|
7 |
-
{{ bar }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
foobar
|
12 |
-
barfoo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/inheritance.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag with inheritance
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "layout.twig" %}
|
5 |
-
|
6 |
-
{% set bar %}bar{% endset %}
|
7 |
-
|
8 |
-
{% block var_from_child %}
|
9 |
-
{{- bar -}}
|
10 |
-
{% endblock %}
|
11 |
-
--TEMPLATE(layout.twig)--
|
12 |
-
{% set foo %}foo{% endset %}
|
13 |
-
|
14 |
-
{% block var_from_layout %}
|
15 |
-
{{- foo -}}
|
16 |
-
{% endblock %}
|
17 |
-
|
18 |
-
{% block var_from_child %}
|
19 |
-
{% endblock %}
|
20 |
-
--DATA--
|
21 |
-
return []
|
22 |
-
--EXPECT--
|
23 |
-
foo
|
24 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/inheritance_overriding.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag with inheritance
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "layout.twig" %}
|
5 |
-
|
6 |
-
{% set foo %}bar{% endset %}
|
7 |
-
|
8 |
-
{% block var_from_child %}
|
9 |
-
{{- foo -}}
|
10 |
-
{% endblock %}
|
11 |
-
--TEMPLATE(layout.twig)--
|
12 |
-
{% set foo %}foo{% endset %}
|
13 |
-
|
14 |
-
{% block var_from_layout %}
|
15 |
-
{{- foo -}}
|
16 |
-
{% endblock %}
|
17 |
-
|
18 |
-
{% block var_from_child %}
|
19 |
-
{% endblock %}
|
20 |
-
--DATA--
|
21 |
-
return []
|
22 |
-
--EXPECT--
|
23 |
-
foo
|
24 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/set/mutating.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"set" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo = "foo" %}
|
5 |
-
|
6 |
-
{% set bar %}
|
7 |
-
{%- set foo = "bar" -%}
|
8 |
-
bar
|
9 |
-
{% endset %}
|
10 |
-
|
11 |
-
{{ foo }}
|
12 |
-
{{ bar }}
|
13 |
-
--DATA--
|
14 |
-
return []
|
15 |
-
--EXPECT--
|
16 |
-
bar
|
17 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/spaceless/simple.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"spaceless" tag removes whites between HTML tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% spaceless %}
|
5 |
-
|
6 |
-
<div> <div> foo </div> </div>
|
7 |
-
|
8 |
-
{% endspaceless %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
<div><div> foo </div></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/special_chars.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"§" custom tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% § %}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
§
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/aliases.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "blocks.twig" with content as foo %}
|
5 |
-
|
6 |
-
{{ block('foo') }}
|
7 |
-
--TEMPLATE(blocks.twig)--
|
8 |
-
{% block content 'foo' %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/basic.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "blocks.twig" %}
|
5 |
-
|
6 |
-
{{ block('content') }}
|
7 |
-
--TEMPLATE(blocks.twig)--
|
8 |
-
{% block content 'foo' %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/deep.test
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "foo.twig" %}
|
5 |
-
|
6 |
-
{{ block('content') }}
|
7 |
-
{{ block('foo') }}
|
8 |
-
{{ block('bar') }}
|
9 |
-
--TEMPLATE(foo.twig)--
|
10 |
-
{% use "bar.twig" %}
|
11 |
-
|
12 |
-
{% block content 'foo' %}
|
13 |
-
{% block foo 'foo' %}
|
14 |
-
--TEMPLATE(bar.twig)--
|
15 |
-
{% block content 'bar' %}
|
16 |
-
{% block bar 'bar' %}
|
17 |
-
--DATA--
|
18 |
-
return []
|
19 |
-
--EXPECT--
|
20 |
-
foo
|
21 |
-
foo
|
22 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/deep_empty.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "foo.twig" %}
|
5 |
-
--TEMPLATE(foo.twig)--
|
6 |
-
{% use "bar.twig" %}
|
7 |
-
--TEMPLATE(bar.twig)--
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/inheritance.test
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "parent.twig" %}
|
5 |
-
|
6 |
-
{{ block('container') }}
|
7 |
-
--TEMPLATE(parent.twig)--
|
8 |
-
{% use "ancestor.twig" %}
|
9 |
-
|
10 |
-
{% block sub_container %}
|
11 |
-
<div class="overridden_sub_container">overridden sub_container</div>
|
12 |
-
{% endblock %}
|
13 |
-
--TEMPLATE(ancestor.twig)--
|
14 |
-
{% block container %}
|
15 |
-
<div class="container">{{ block('sub_container') }}</div>
|
16 |
-
{% endblock %}
|
17 |
-
|
18 |
-
{% block sub_container %}
|
19 |
-
<div class="sub_container">sub_container</div>
|
20 |
-
{% endblock %}
|
21 |
-
--DATA--
|
22 |
-
return []
|
23 |
-
--EXPECT--
|
24 |
-
<div class="container"> <div class="overridden_sub_container">overridden sub_container</div>
|
25 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/inheritance2.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "ancestor.twig" %}
|
5 |
-
{% use "parent.twig" %}
|
6 |
-
|
7 |
-
{{ block('container') }}
|
8 |
-
--TEMPLATE(parent.twig)--
|
9 |
-
{% block sub_container %}
|
10 |
-
<div class="overridden_sub_container">overridden sub_container</div>
|
11 |
-
{% endblock %}
|
12 |
-
--TEMPLATE(ancestor.twig)--
|
13 |
-
{% block container %}
|
14 |
-
<div class="container">{{ block('sub_container') }}</div>
|
15 |
-
{% endblock %}
|
16 |
-
|
17 |
-
{% block sub_container %}
|
18 |
-
<div class="sub_container">sub_container</div>
|
19 |
-
{% endblock %}
|
20 |
-
--DATA--
|
21 |
-
return []
|
22 |
-
--EXPECT--
|
23 |
-
<div class="container"> <div class="overridden_sub_container">overridden sub_container</div>
|
24 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/multiple.test
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "foo.twig" %}
|
5 |
-
{% use "bar.twig" %}
|
6 |
-
|
7 |
-
{{ block('content') }}
|
8 |
-
{{ block('foo') }}
|
9 |
-
{{ block('bar') }}
|
10 |
-
--TEMPLATE(foo.twig)--
|
11 |
-
{% block content 'foo' %}
|
12 |
-
{% block foo 'foo' %}
|
13 |
-
--TEMPLATE(bar.twig)--
|
14 |
-
{% block content 'bar' %}
|
15 |
-
{% block bar 'bar' %}
|
16 |
-
--DATA--
|
17 |
-
return []
|
18 |
-
--EXPECT--
|
19 |
-
bar
|
20 |
-
foo
|
21 |
-
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/multiple_aliases.test
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use "foo.twig" with content as foo_content %}
|
5 |
-
{% use "bar.twig" %}
|
6 |
-
|
7 |
-
{{ block('content') }}
|
8 |
-
{{ block('foo') }}
|
9 |
-
{{ block('bar') }}
|
10 |
-
{{ block('foo_content') }}
|
11 |
-
--TEMPLATE(foo.twig)--
|
12 |
-
{% block content 'foo' %}
|
13 |
-
{% block foo 'foo' %}
|
14 |
-
--TEMPLATE(bar.twig)--
|
15 |
-
{% block content 'bar' %}
|
16 |
-
{% block bar 'bar' %}
|
17 |
-
--DATA--
|
18 |
-
return []
|
19 |
-
--EXPECT--
|
20 |
-
bar
|
21 |
-
foo
|
22 |
-
bar
|
23 |
-
foo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/parent_block.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'file2.html.twig' with foobar as base_base_foobar %}
|
5 |
-
{% block foobar %}
|
6 |
-
{{- block('base_base_foobar') -}}
|
7 |
-
Content of block (second override)
|
8 |
-
{% endblock foobar %}
|
9 |
-
--TEMPLATE(file2.html.twig)--
|
10 |
-
{% use 'file1.html.twig' with foobar as base_foobar %}
|
11 |
-
{% block foobar %}
|
12 |
-
{{- block('base_foobar') -}}
|
13 |
-
Content of block (first override)
|
14 |
-
{% endblock foobar %}
|
15 |
-
--TEMPLATE(file1.html.twig)--
|
16 |
-
{% block foobar -%}
|
17 |
-
Content of block
|
18 |
-
{% endblock foobar %}
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
Content of block
|
23 |
-
Content of block (first override)
|
24 |
-
Content of block (second override)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/parent_block2.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'file2.html.twig'%}
|
5 |
-
{% block foobar %}
|
6 |
-
{{- parent() -}}
|
7 |
-
Content of block (second override)
|
8 |
-
{% endblock foobar %}
|
9 |
-
--TEMPLATE(file2.html.twig)--
|
10 |
-
{% use 'file1.html.twig' %}
|
11 |
-
{% block foobar %}
|
12 |
-
{{- parent() -}}
|
13 |
-
Content of block (first override)
|
14 |
-
{% endblock foobar %}
|
15 |
-
--TEMPLATE(file1.html.twig)--
|
16 |
-
{% block foobar -%}
|
17 |
-
Content of block
|
18 |
-
{% endblock foobar %}
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
Content of block
|
23 |
-
Content of block (first override)
|
24 |
-
Content of block (second override)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/parent_block3.test
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% use 'file2.html.twig' %}
|
5 |
-
{% use 'file1.html.twig' with foo %}
|
6 |
-
{% block foo %}
|
7 |
-
{{- parent() -}}
|
8 |
-
Content of foo (second override)
|
9 |
-
{% endblock foo %}
|
10 |
-
{% block bar %}
|
11 |
-
{{- parent() -}}
|
12 |
-
Content of bar (second override)
|
13 |
-
{% endblock bar %}
|
14 |
-
--TEMPLATE(file2.html.twig)--
|
15 |
-
{% use 'file1.html.twig' %}
|
16 |
-
{% block foo %}
|
17 |
-
{{- parent() -}}
|
18 |
-
Content of foo (first override)
|
19 |
-
{% endblock foo %}
|
20 |
-
{% block bar %}
|
21 |
-
{{- parent() -}}
|
22 |
-
Content of bar (first override)
|
23 |
-
{% endblock bar %}
|
24 |
-
--TEMPLATE(file1.html.twig)--
|
25 |
-
{% block foo -%}
|
26 |
-
Content of foo
|
27 |
-
{% endblock foo %}
|
28 |
-
{% block bar -%}
|
29 |
-
Content of bar
|
30 |
-
{% endblock bar %}
|
31 |
-
--DATA--
|
32 |
-
return []
|
33 |
-
--EXPECT--
|
34 |
-
Content of foo
|
35 |
-
Content of foo (first override)
|
36 |
-
Content of foo (second override)
|
37 |
-
Content of bar
|
38 |
-
Content of bar (second override)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/use/use_with_parent.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"use" tag with a parent block
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "parent.twig" %}
|
5 |
-
|
6 |
-
{% use 'blocks.twig' %}
|
7 |
-
|
8 |
-
{% block body %}
|
9 |
-
{{ parent() -}}
|
10 |
-
CHILD
|
11 |
-
{{ block('content') }}
|
12 |
-
{% endblock %}
|
13 |
-
--TEMPLATE(parent.twig)--
|
14 |
-
{% block body %}
|
15 |
-
PARENT
|
16 |
-
{% endblock %}
|
17 |
-
--TEMPLATE(blocks.twig)--
|
18 |
-
{% block content 'BLOCK' %}
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
PARENT
|
23 |
-
CHILD
|
24 |
-
BLOCK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/verbatim/basic.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"verbatim" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% verbatim %}
|
5 |
-
{{ foo }}
|
6 |
-
{% endverbatim %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
{{ foo }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/verbatim/mixed_usage_with_raw.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"verbatim" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% verbatim %}
|
5 |
-
{{ foo }}
|
6 |
-
{% endraw %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\SyntaxError: Unexpected end of file: Unclosed "verbatim" block in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/verbatim/whitespace_control.test
DELETED
@@ -1,56 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"verbatim" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
1***
|
5 |
-
|
6 |
-
{%- verbatim %}
|
7 |
-
{{ 'bla' }}
|
8 |
-
{% endverbatim %}
|
9 |
-
|
10 |
-
1***
|
11 |
-
2***
|
12 |
-
|
13 |
-
{%- verbatim -%}
|
14 |
-
{{ 'bla' }}
|
15 |
-
{% endverbatim %}
|
16 |
-
|
17 |
-
2***
|
18 |
-
3***
|
19 |
-
|
20 |
-
{%- verbatim -%}
|
21 |
-
{{ 'bla' }}
|
22 |
-
{% endverbatim -%}
|
23 |
-
|
24 |
-
3***
|
25 |
-
4***
|
26 |
-
|
27 |
-
{%- verbatim -%}
|
28 |
-
{{ 'bla' }}
|
29 |
-
{%- endverbatim %}
|
30 |
-
|
31 |
-
4***
|
32 |
-
5***
|
33 |
-
|
34 |
-
{%- verbatim -%}
|
35 |
-
{{ 'bla' }}
|
36 |
-
{%- endverbatim -%}
|
37 |
-
|
38 |
-
5***
|
39 |
-
--DATA--
|
40 |
-
return []
|
41 |
-
--EXPECT--
|
42 |
-
1***
|
43 |
-
{{ 'bla' }}
|
44 |
-
|
45 |
-
|
46 |
-
1***
|
47 |
-
2***{{ 'bla' }}
|
48 |
-
|
49 |
-
|
50 |
-
2***
|
51 |
-
3***{{ 'bla' }}
|
52 |
-
3***
|
53 |
-
4***{{ 'bla' }}
|
54 |
-
|
55 |
-
4***
|
56 |
-
5***{{ 'bla' }}5***
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/basic.test
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with %}
|
5 |
-
{% set bar = 'BAZ' %}
|
6 |
-
{{ foo }}{{ bar }}
|
7 |
-
{% endwith %}
|
8 |
-
{{ foo }}{{ bar }}
|
9 |
-
--DATA--
|
10 |
-
return ['foo' => 'foo', 'bar' => 'bar']
|
11 |
-
--EXPECT--
|
12 |
-
fooBAZ
|
13 |
-
foobar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/expression.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag with expression
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with {foo: 'foo', bar: 'BAZ'} %}
|
5 |
-
{{ foo }}{{ bar }}
|
6 |
-
{% endwith %}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => 'baz']
|
9 |
-
--EXPECT--
|
10 |
-
fooBAZ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/globals.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with [] only %}
|
5 |
-
{{ global }}
|
6 |
-
{% endwith %}
|
7 |
-
--DATA--
|
8 |
-
return []
|
9 |
-
--EXPECT--
|
10 |
-
global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/iterable.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag with an iterable expression
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with vars %}
|
5 |
-
{{ foo }}{{ bar }}
|
6 |
-
{% endwith %}
|
7 |
-
--DATA--
|
8 |
-
return ['vars' => new ArrayObject(['foo' => 'baz', 'bar' => 'qux'])]
|
9 |
-
--EXPECT--
|
10 |
-
bazqux
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/nested.test
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
nested "with" tags
|
3 |
-
--TEMPLATE--
|
4 |
-
{% set foo, bar = 'foo', 'bar' %}
|
5 |
-
{% with {bar: 'BAZ'} %}
|
6 |
-
{% with {foo: 'FOO'} %}
|
7 |
-
{{ foo }}{{ bar }}
|
8 |
-
{% endwith %}
|
9 |
-
{% endwith %}
|
10 |
-
{{ foo }}{{ bar }}
|
11 |
-
--DATA--
|
12 |
-
return []
|
13 |
-
--EXPECT--
|
14 |
-
FOOBAZ
|
15 |
-
foobar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/with_no_hash.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag with an expression that is not a hash
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with vars %}
|
5 |
-
{{ foo }}{{ bar }}
|
6 |
-
{% endwith %}
|
7 |
-
--DATA--
|
8 |
-
return ['vars' => 'no-hash']
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\RuntimeError: Variables passed to the "with" tag must be a hash in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tags/with/with_only.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"with" tag with expression and only
|
3 |
-
--TEMPLATE--
|
4 |
-
{% with {foo: 'foo', bar: 'BAZ'} only %}
|
5 |
-
{{ foo }}{{ bar }}{{ baz }}
|
6 |
-
{% endwith %}
|
7 |
-
--DATA--
|
8 |
-
return ['foo' => 'baz', 'baz' => 'baz']
|
9 |
-
--EXCEPTION--
|
10 |
-
Twig\Error\RuntimeError: Variable "baz" does not exist in "index.twig" at line 3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/array.test
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
array index test
|
3 |
-
--TEMPLATE--
|
4 |
-
{% for key, value in days %}
|
5 |
-
{{ key }}
|
6 |
-
{% endfor %}
|
7 |
-
--DATA--
|
8 |
-
return ['days' => [
|
9 |
-
1 => ['money' => 9],
|
10 |
-
2 => ['money' => 21],
|
11 |
-
3 => ['money' => 38],
|
12 |
-
4 => ['money' => 6],
|
13 |
-
18 => ['money' => 6],
|
14 |
-
19 => ['money' => 3],
|
15 |
-
31 => ['money' => 11],
|
16 |
-
]]
|
17 |
-
--EXPECT--
|
18 |
-
1
|
19 |
-
2
|
20 |
-
3
|
21 |
-
4
|
22 |
-
18
|
23 |
-
19
|
24 |
-
31
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/constant.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"const" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 8 is constant('E_NOTICE') ? 'ok' : 'no' }}
|
5 |
-
{{ 'bar' is constant('Twig\\Tests\\TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }}
|
6 |
-
{{ value is constant('Twig\\Tests\\TwigTestFoo::BAR_NAME') ? 'ok' : 'no' }}
|
7 |
-
{{ 2 is constant('ARRAY_AS_PROPS', object) ? 'ok' : 'no' }}
|
8 |
-
--DATA--
|
9 |
-
return ['value' => 'bar', 'object' => new \ArrayObject(['hi'])]
|
10 |
-
--EXPECT--
|
11 |
-
ok
|
12 |
-
ok
|
13 |
-
ok
|
14 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined.test
DELETED
@@ -1,129 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ definedVar is defined ? 'ok' : 'ko' }}
|
5 |
-
{{ definedVar is not defined ? 'ko' : 'ok' }}
|
6 |
-
{{ undefinedVar is defined ? 'ko' : 'ok' }}
|
7 |
-
{{ undefinedVar is not defined ? 'ok' : 'ko' }}
|
8 |
-
{{ zeroVar is defined ? 'ok' : 'ko' }}
|
9 |
-
{{ nullVar is defined ? 'ok' : 'ko' }}
|
10 |
-
{{ nested.definedVar is defined ? 'ok' : 'ko' }}
|
11 |
-
{{ nested['definedVar'] is defined ? 'ok' : 'ko' }}
|
12 |
-
{{ nested.definedVar is not defined ? 'ko' : 'ok' }}
|
13 |
-
{{ nested.undefinedVar is defined ? 'ko' : 'ok' }}
|
14 |
-
{{ nested['undefinedVar'] is defined ? 'ko' : 'ok' }}
|
15 |
-
{{ nested.undefinedVar is not defined ? 'ok' : 'ko' }}
|
16 |
-
{{ nested.zeroVar is defined ? 'ok' : 'ko' }}
|
17 |
-
{{ nested.nullVar is defined ? 'ok' : 'ko' }}
|
18 |
-
{{ nested.definedArray.0 is defined ? 'ok' : 'ko' }}
|
19 |
-
{{ nested['definedArray'][0] is defined ? 'ok' : 'ko' }}
|
20 |
-
{{ object.foo is defined ? 'ok' : 'ko' }}
|
21 |
-
{{ object.undefinedMethod is defined ? 'ko' : 'ok' }}
|
22 |
-
{{ object.getFoo() is defined ? 'ok' : 'ko' }}
|
23 |
-
{{ object.getFoo('a') is defined ? 'ok' : 'ko' }}
|
24 |
-
{{ object.undefinedMethod() is defined ? 'ko' : 'ok' }}
|
25 |
-
{{ object.undefinedMethod('a') is defined ? 'ko' : 'ok' }}
|
26 |
-
{{ object.self.foo is defined ? 'ok' : 'ko' }}
|
27 |
-
{{ object.self.undefinedMethod is defined ? 'ko' : 'ok' }}
|
28 |
-
{{ object.undefinedMethod.self is defined ? 'ko' : 'ok' }}
|
29 |
-
{{ 0 is defined ? 'ok' : 'ko' }}
|
30 |
-
{{ "foo" is defined ? 'ok' : 'ko' }}
|
31 |
-
{{ true is defined ? 'ok' : 'ko' }}
|
32 |
-
{{ false is defined ? 'ok' : 'ko' }}
|
33 |
-
{{ null is defined ? 'ok' : 'ko' }}
|
34 |
-
{{ [1, 2] is defined ? 'ok' : 'ko' }}
|
35 |
-
{{ { foo: "bar" } is defined ? 'ok' : 'ko' }}
|
36 |
-
--DATA--
|
37 |
-
return [
|
38 |
-
'definedVar' => 'defined',
|
39 |
-
'zeroVar' => 0,
|
40 |
-
'nullVar' => null,
|
41 |
-
'nested' => [
|
42 |
-
'definedVar' => 'defined',
|
43 |
-
'zeroVar' => 0,
|
44 |
-
'nullVar' => null,
|
45 |
-
'definedArray' => [0],
|
46 |
-
],
|
47 |
-
'object' => new Twig\Tests\TwigTestFoo(),
|
48 |
-
]
|
49 |
-
--EXPECT--
|
50 |
-
ok
|
51 |
-
ok
|
52 |
-
ok
|
53 |
-
ok
|
54 |
-
ok
|
55 |
-
ok
|
56 |
-
ok
|
57 |
-
ok
|
58 |
-
ok
|
59 |
-
ok
|
60 |
-
ok
|
61 |
-
ok
|
62 |
-
ok
|
63 |
-
ok
|
64 |
-
ok
|
65 |
-
ok
|
66 |
-
ok
|
67 |
-
ok
|
68 |
-
ok
|
69 |
-
ok
|
70 |
-
ok
|
71 |
-
ok
|
72 |
-
ok
|
73 |
-
ok
|
74 |
-
ok
|
75 |
-
ok
|
76 |
-
ok
|
77 |
-
ok
|
78 |
-
ok
|
79 |
-
ok
|
80 |
-
ok
|
81 |
-
ok
|
82 |
-
--DATA--
|
83 |
-
return [
|
84 |
-
'definedVar' => 'defined',
|
85 |
-
'zeroVar' => 0,
|
86 |
-
'nullVar' => null,
|
87 |
-
'nested' => [
|
88 |
-
'definedVar' => 'defined',
|
89 |
-
'zeroVar' => 0,
|
90 |
-
'nullVar' => null,
|
91 |
-
'definedArray' => [0],
|
92 |
-
],
|
93 |
-
'object' => new Twig\Tests\TwigTestFoo(),
|
94 |
-
]
|
95 |
-
--CONFIG--
|
96 |
-
return ['strict_variables' => false]
|
97 |
-
--EXPECT--
|
98 |
-
ok
|
99 |
-
ok
|
100 |
-
ok
|
101 |
-
ok
|
102 |
-
ok
|
103 |
-
ok
|
104 |
-
ok
|
105 |
-
ok
|
106 |
-
ok
|
107 |
-
ok
|
108 |
-
ok
|
109 |
-
ok
|
110 |
-
ok
|
111 |
-
ok
|
112 |
-
ok
|
113 |
-
ok
|
114 |
-
ok
|
115 |
-
ok
|
116 |
-
ok
|
117 |
-
ok
|
118 |
-
ok
|
119 |
-
ok
|
120 |
-
ok
|
121 |
-
ok
|
122 |
-
ok
|
123 |
-
ok
|
124 |
-
ok
|
125 |
-
ok
|
126 |
-
ok
|
127 |
-
ok
|
128 |
-
ok
|
129 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined_for_attribute.test
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" support for attribute
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ attribute(nested, "definedVar") is defined ? 'ok' : 'ko' }}
|
5 |
-
{{ attribute(nested, "undefinedVar") is not defined ? 'ok' : 'ko' }}
|
6 |
-
{{ attribute(nested, definedVarName) is defined ? 'ok' : 'ko' }}
|
7 |
-
{{ attribute(nested, undefinedVarName) is not defined ? 'ok' : 'ko' }}
|
8 |
-
--DATA--
|
9 |
-
return [
|
10 |
-
'nested' => [
|
11 |
-
'definedVar' => 'defined',
|
12 |
-
],
|
13 |
-
'definedVarName' => 'definedVar',
|
14 |
-
'undefinedVarName' => 'undefinedVar',
|
15 |
-
]
|
16 |
-
--EXPECT--
|
17 |
-
ok
|
18 |
-
ok
|
19 |
-
ok
|
20 |
-
ok
|
21 |
-
--DATA--
|
22 |
-
return [
|
23 |
-
'nested' => [
|
24 |
-
'definedVar' => 'defined',
|
25 |
-
],
|
26 |
-
'definedVarName' => 'definedVar',
|
27 |
-
'undefinedVarName' => 'undefinedVar',
|
28 |
-
]
|
29 |
-
--CONFIG--
|
30 |
-
return ['strict_variables' => false]
|
31 |
-
--EXPECT--
|
32 |
-
ok
|
33 |
-
ok
|
34 |
-
ok
|
35 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined_for_blocks.test
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" support for blocks
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends 'parent' %}
|
5 |
-
{% block icon %}icon{% endblock %}
|
6 |
-
{% block body %}
|
7 |
-
{{ parent() }}
|
8 |
-
{{ block('foo') is defined ? 'ok' : 'ko' }}
|
9 |
-
{{ block('footer') is defined ? 'ok' : 'ko' }}
|
10 |
-
{{ block('icon') is defined ? 'ok' : 'ko' }}
|
11 |
-
{{ block('block1') is defined ? 'ok' : 'ko' }}
|
12 |
-
{%- embed 'embed' %}
|
13 |
-
{% block content %}content{% endblock %}
|
14 |
-
{% endembed %}
|
15 |
-
{% endblock %}
|
16 |
-
{% use 'blocks' %}
|
17 |
-
--TEMPLATE(parent)--
|
18 |
-
{% block body %}
|
19 |
-
{{ block('icon') is defined ? 'ok' : 'ko' -}}
|
20 |
-
{% endblock %}
|
21 |
-
{% block footer %}{% endblock %}
|
22 |
-
--TEMPLATE(embed)--
|
23 |
-
{{ block('icon') is defined ? 'ok' : 'ko' }}
|
24 |
-
{{ block('content') is defined ? 'ok' : 'ko' }}
|
25 |
-
{{ block('block1') is defined ? 'ok' : 'ko' }}
|
26 |
-
--TEMPLATE(blocks)--
|
27 |
-
{% block block1 %}{%endblock %}
|
28 |
-
--DATA--
|
29 |
-
return []
|
30 |
-
--EXPECT--
|
31 |
-
ok
|
32 |
-
ko
|
33 |
-
ok
|
34 |
-
ok
|
35 |
-
ok
|
36 |
-
ko
|
37 |
-
ok
|
38 |
-
ko
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined_for_blocks_with_template.test
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" support for blocks with a template argument
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ block('foo', 'included.twig') is defined ? 'ok' : 'ko' }}
|
5 |
-
{{ block('foo', included_loaded) is defined ? 'ok' : 'ko' }}
|
6 |
-
{{ block('foo', included_loaded_internal) is defined ? 'ok' : 'ko' }}
|
7 |
-
--TEMPLATE(included.twig)--
|
8 |
-
{% block foo %}FOO{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return [
|
11 |
-
'included_loaded' => $twig->load('included.twig'),
|
12 |
-
'included_loaded_internal' => $twig->load('included.twig'),
|
13 |
-
]
|
14 |
-
--EXPECT--
|
15 |
-
ok
|
16 |
-
ok
|
17 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined_for_constants.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" support for constants
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ constant('DATE_W3C') is defined ? 'ok' : 'ko' }}
|
5 |
-
{{ constant('ARRAY_AS_PROPS', object) is defined ? 'ok' : 'ko' }}
|
6 |
-
{{ constant('FOOBAR') is not defined ? 'ok' : 'ko' }}
|
7 |
-
{{ constant('FOOBAR', object) is not defined ? 'ok' : 'ko' }}
|
8 |
-
--DATA--
|
9 |
-
return ['expect' => DATE_W3C, 'object' => new \ArrayObject(['hi'])]
|
10 |
-
--EXPECT--
|
11 |
-
ok
|
12 |
-
ok
|
13 |
-
ok
|
14 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/defined_on_complex_expr.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"defined" support for "complex" expressions
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ (1 + 2) is defined ? 'ok' : 'ko' }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXCEPTION--
|
8 |
-
Twig\Error\SyntaxError: The "defined" test only works with simple variables in "index.twig" at line 2.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/dynamic_test.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
dynamic test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'bar' is test_bar ? '1' :'0' }}
|
5 |
-
{{ 'foo' is test_foo ? '1' :'0' }}
|
6 |
-
{{ 'bar' is test_foo ? '1' :'0' }}
|
7 |
-
{{ 'foo' is test_bar ? '1' :'0' }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
1
|
12 |
-
1
|
13 |
-
0
|
14 |
-
0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/empty.test
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"empty" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ string_empty is empty ? 'ok' : 'ko' }}
|
5 |
-
{{ string_zero is empty ? 'ko' : 'ok' }}
|
6 |
-
{{ value_null is empty ? 'ok' : 'ko' }}
|
7 |
-
{{ value_false is empty ? 'ok' : 'ko' }}
|
8 |
-
{{ value_int_zero is empty ? 'ko' : 'ok' }}
|
9 |
-
{{ array_empty is empty ? 'ok' : 'ko' }}
|
10 |
-
{{ array_not_empty is empty ? 'ko' : 'ok' }}
|
11 |
-
{{ magically_callable is empty ? 'ko' : 'ok' }}
|
12 |
-
{{ countable_empty is empty ? 'ok' : 'ko' }}
|
13 |
-
{{ countable_not_empty is empty ? 'ko' : 'ok' }}
|
14 |
-
{{ tostring_empty is empty ? 'ok' : 'ko' }}
|
15 |
-
{{ tostring_not_empty is empty ? 'ko' : 'ok' }}
|
16 |
-
{{ markup_empty is empty ? 'ok' : 'ko' }}
|
17 |
-
{{ markup_not_empty is empty ? 'ko' : 'ok' }}
|
18 |
-
{{ iterator is empty ? 'ko' : 'ok' }}
|
19 |
-
{{ empty_iterator is empty ? 'ok' : 'ko' }}
|
20 |
-
{{ callback_iterator is empty ? 'ko' : 'ok' }}
|
21 |
-
{{ empty_callback_iterator is empty ? 'ok' : 'ko' }}
|
22 |
-
--DATA--
|
23 |
-
return [
|
24 |
-
'string_empty' => '', 'string_zero' => '0',
|
25 |
-
'value_null' => null, 'value_false' => false, 'value_int_zero' => 0,
|
26 |
-
'array_empty' => [], 'array_not_empty' => [1, 2],
|
27 |
-
'magically_callable' => new \Twig\Tests\MagicCallStub(),
|
28 |
-
'countable_empty' => new \Twig\Tests\CountableStub([]), 'countable_not_empty' => new \Twig\Tests\CountableStub([1, 2]),
|
29 |
-
'tostring_empty' => new \Twig\Tests\ToStringStub(''), 'tostring_not_empty' => new \Twig\Tests\ToStringStub('0' /* edge case of using "0" as the string */),
|
30 |
-
'markup_empty' => new \Twig\Markup('', 'UTF-8'), 'markup_not_empty' => new \Twig\Markup('test', 'UTF-8'),
|
31 |
-
'iterator' => $iter = new \ArrayIterator(['bar', 'foo']),
|
32 |
-
'empty_iterator' => new \ArrayIterator(),
|
33 |
-
'callback_iterator' => new \CallbackFilterIterator($iter, function ($el) { return true; }),
|
34 |
-
'empty_callback_iterator' => new \CallbackFilterIterator($iter, function ($el) { return false; }),
|
35 |
-
]
|
36 |
-
--EXPECT--
|
37 |
-
ok
|
38 |
-
ok
|
39 |
-
ok
|
40 |
-
ok
|
41 |
-
ok
|
42 |
-
ok
|
43 |
-
ok
|
44 |
-
ok
|
45 |
-
ok
|
46 |
-
ok
|
47 |
-
ok
|
48 |
-
ok
|
49 |
-
ok
|
50 |
-
ok
|
51 |
-
ok
|
52 |
-
ok
|
53 |
-
ok
|
54 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/even.test
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"even" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 is even ? 'ko' : 'ok' }}
|
5 |
-
{{ 2 is even ? 'ok' : 'ko' }}
|
6 |
-
{{ 1 is not even ? 'ok' : 'ko' }}
|
7 |
-
{{ 2 is not even ? 'ko' : 'ok' }}
|
8 |
-
--DATA--
|
9 |
-
return []
|
10 |
-
--EXPECT--
|
11 |
-
ok
|
12 |
-
ok
|
13 |
-
ok
|
14 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/in.test
DELETED
@@ -1,118 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the in operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ bar in foo ? 'OK' : 'KO' }}
|
5 |
-
{{ not (bar in foo) ? 'KO' : 'OK' }}
|
6 |
-
{{ bar not in foo ? 'KO' : 'OK' }}
|
7 |
-
{{ 'a' in bar ? 'OK' : 'KO' }}
|
8 |
-
{{ 'c' not in bar ? 'OK' : 'KO' }}
|
9 |
-
{{ '' in bar ? 'OK' : 'KO' }}
|
10 |
-
{{ '' in '' ? 'OK' : 'KO' }}
|
11 |
-
{{ '0' not in '' ? 'OK' : 'KO' }}
|
12 |
-
{{ 'a' not in '0' ? 'OK' : 'KO' }}
|
13 |
-
{{ '0' in '0' ? 'OK' : 'KO' }}
|
14 |
-
|
15 |
-
{{ false in [0, 1] ? 'OK' : 'KO' }}
|
16 |
-
{{ true in [0, 1] ? 'OK' : 'KO' }}
|
17 |
-
{{ '0' in [0, 1] ? 'OK' : 'KO' }}
|
18 |
-
{{ '0' in [1, 0] ? 'OK' : 'KO' }}
|
19 |
-
{{ '' in [0, 1] ? 'OK' : 'KO' }}
|
20 |
-
{{ '' in [1, 0] ? 'OK' : 'KO' }}
|
21 |
-
{{ 0 in ['', 1] ? 'OK' : 'KO' }}
|
22 |
-
{{ 0 in [1, ''] ? 'OK' : 'KO' }}
|
23 |
-
|
24 |
-
{{ '' in 'foo' ? 'OK' : 'KO' }}
|
25 |
-
{{ 0 in 'foo' ? 'KO' : 'OK' }}
|
26 |
-
{{ false in 'foo' ? 'KO' : 'OK' }}
|
27 |
-
{{ false in '100' ? 'KO' : 'OK' }}
|
28 |
-
{{ true in '100' ? 'KO' : 'OK' }}
|
29 |
-
|
30 |
-
{{ [] in [true, false] ? 'OK' : 'KO' }}
|
31 |
-
{{ [] in [true, ''] ? 'KO' : 'OK' }}
|
32 |
-
{{ [] in [true, []] ? 'OK' : 'KO' }}
|
33 |
-
|
34 |
-
{{ resource ? 'OK' : 'KO' }}
|
35 |
-
{{ resource in 'foo'~resource ? 'KO' : 'OK' }}
|
36 |
-
{{ object in 'stdClass' ? 'KO' : 'OK' }}
|
37 |
-
{{ [] in 'Array' ? 'KO' : 'OK' }}
|
38 |
-
{{ dir_object in 'foo'~dir_object ? 'KO' : 'OK' }}
|
39 |
-
|
40 |
-
{{ ''~resource in resource ? 'KO' : 'OK' }}
|
41 |
-
{{ 'stdClass' in object ? 'KO' : 'OK' }}
|
42 |
-
{{ 'Array' in [] ? 'KO' : 'OK' }}
|
43 |
-
{{ ''~dir_object in dir_object ? 'KO' : 'OK' }}
|
44 |
-
|
45 |
-
{{ resource in [''~resource] ? 'KO' : 'OK' }}
|
46 |
-
{{ resource in [resource + 1 - 1] ? 'KO' : 'OK' }}
|
47 |
-
{{ dir_object in [''~dir_object] ? 'KO' : 'OK' }}
|
48 |
-
|
49 |
-
{{ 5 in 125 ? 'KO' : 'OK' }}
|
50 |
-
{{ 5 in '125' ? 'OK' : 'KO' }}
|
51 |
-
{{ '5' in 125 ? 'KO' : 'OK' }}
|
52 |
-
{{ '5' in '125' ? 'OK' : 'KO' }}
|
53 |
-
|
54 |
-
{{ 5.5 in 125.5 ? 'KO' : 'OK' }}
|
55 |
-
{{ 5.5 in '125.5' ? 'OK' : 'KO' }}
|
56 |
-
{{ '5.5' in 125.5 ? 'KO' : 'OK' }}
|
57 |
-
|
58 |
-
{{ safe in ['foo', 'bar'] ? 'OK' : 'KO' }}
|
59 |
-
{{ 'fo' in safe ? 'OK' : 'KO' }}
|
60 |
-
--DATA--
|
61 |
-
return ['bar' => 'bar', 'foo' => ['bar' => 'bar'], 'dir_object' => new \SplFileInfo(dirname(__FILE__)), 'object' => new \stdClass(), 'resource' => opendir(dirname(__FILE__)), 'safe' => new \Twig\Markup('foo', 'UTF-8')]
|
62 |
-
--EXPECT--
|
63 |
-
OK
|
64 |
-
OK
|
65 |
-
OK
|
66 |
-
OK
|
67 |
-
OK
|
68 |
-
OK
|
69 |
-
OK
|
70 |
-
OK
|
71 |
-
OK
|
72 |
-
OK
|
73 |
-
|
74 |
-
OK
|
75 |
-
OK
|
76 |
-
OK
|
77 |
-
OK
|
78 |
-
OK
|
79 |
-
OK
|
80 |
-
OK
|
81 |
-
OK
|
82 |
-
|
83 |
-
OK
|
84 |
-
OK
|
85 |
-
OK
|
86 |
-
OK
|
87 |
-
OK
|
88 |
-
|
89 |
-
OK
|
90 |
-
OK
|
91 |
-
OK
|
92 |
-
|
93 |
-
OK
|
94 |
-
OK
|
95 |
-
OK
|
96 |
-
OK
|
97 |
-
OK
|
98 |
-
|
99 |
-
OK
|
100 |
-
OK
|
101 |
-
OK
|
102 |
-
OK
|
103 |
-
|
104 |
-
OK
|
105 |
-
OK
|
106 |
-
OK
|
107 |
-
|
108 |
-
OK
|
109 |
-
OK
|
110 |
-
OK
|
111 |
-
OK
|
112 |
-
|
113 |
-
OK
|
114 |
-
OK
|
115 |
-
OK
|
116 |
-
|
117 |
-
OK
|
118 |
-
OK
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/in_with_objects.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the in operator when using objects
|
3 |
-
--TEMPLATE--
|
4 |
-
{% if object in object_list %}
|
5 |
-
TRUE
|
6 |
-
{% endif %}
|
7 |
-
--DATA--
|
8 |
-
$foo = new Twig\Tests\TwigTestFoo();
|
9 |
-
$foo1 = new Twig\Tests\TwigTestFoo();
|
10 |
-
|
11 |
-
$foo->position = $foo1;
|
12 |
-
$foo1->position = $foo;
|
13 |
-
|
14 |
-
return [
|
15 |
-
'object' => $foo,
|
16 |
-
'object_list' => [$foo1, $foo],
|
17 |
-
]
|
18 |
-
--EXPECT--
|
19 |
-
TRUE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/iterable.test
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"iterable" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ foo is iterable ? 'ok' : 'ko' }}
|
5 |
-
{{ traversable is iterable ? 'ok' : 'ko' }}
|
6 |
-
{{ obj is iterable ? 'ok' : 'ko' }}
|
7 |
-
{{ val is iterable ? 'ok' : 'ko' }}
|
8 |
-
--DATA--
|
9 |
-
return [
|
10 |
-
'foo' => [],
|
11 |
-
'traversable' => new \ArrayIterator([]),
|
12 |
-
'obj' => new \stdClass(),
|
13 |
-
'val' => 'test',
|
14 |
-
]
|
15 |
-
--EXPECT--
|
16 |
-
ok
|
17 |
-
ok
|
18 |
-
ko
|
19 |
-
ko
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/null_coalesce.test
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Twig supports the ?? operator
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'OK' ?? 'KO' }}
|
5 |
-
{{ null ?? 'OK' }}
|
6 |
-
{{ bar ?? 'KO' }}
|
7 |
-
{{ baz ?? 'OK' }}
|
8 |
-
{{ foo.bar ?? 'KO' }}
|
9 |
-
{{ foo.missing ?? 'OK' }}
|
10 |
-
{{ foo.bar.baz.missing ?? 'OK' }}
|
11 |
-
{{ foo['bar'] ?? 'KO' }}
|
12 |
-
{{ foo['missing'] ?? 'OK' }}
|
13 |
-
{{ nope ?? nada ?? 'OK' }}
|
14 |
-
{{ 1 + nope ?? nada ?? 2 }}
|
15 |
-
{{ 1 + nope ?? 3 + nada ?? 2 }}
|
16 |
-
--DATA--
|
17 |
-
return ['bar' => 'OK', 'foo' => ['bar' => 'OK']]
|
18 |
-
--EXPECT--
|
19 |
-
OK
|
20 |
-
OK
|
21 |
-
OK
|
22 |
-
OK
|
23 |
-
OK
|
24 |
-
OK
|
25 |
-
OK
|
26 |
-
OK
|
27 |
-
OK
|
28 |
-
OK
|
29 |
-
3
|
30 |
-
6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/tests/odd.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"odd" test
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 1 is odd ? 'ok' : 'ko' }}
|
5 |
-
{{ 2 is odd ? 'ko' : 'ok' }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
ok
|
10 |
-
ok
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_block.test
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Whitespace trimming on tags.
|
3 |
-
--TEMPLATE--
|
4 |
-
Trim on control tag:
|
5 |
-
{% for i in range(1, 9) -%}
|
6 |
-
{{ i }}
|
7 |
-
{%- endfor %}
|
8 |
-
|
9 |
-
|
10 |
-
Trim on output tag:
|
11 |
-
{% for i in range(1, 9) %}
|
12 |
-
{{- i -}}
|
13 |
-
{% endfor %}
|
14 |
-
|
15 |
-
|
16 |
-
Trim comments:
|
17 |
-
|
18 |
-
{#- Invisible -#}
|
19 |
-
|
20 |
-
After the comment.
|
21 |
-
|
22 |
-
Trim leading space:
|
23 |
-
{% if leading %}
|
24 |
-
|
25 |
-
{{- leading }}
|
26 |
-
{% endif %}
|
27 |
-
|
28 |
-
{%- if leading %}
|
29 |
-
{{- leading }}
|
30 |
-
|
31 |
-
{%- endif %}
|
32 |
-
|
33 |
-
|
34 |
-
Trim trailing space:
|
35 |
-
{% if trailing -%}
|
36 |
-
{{ trailing -}}
|
37 |
-
|
38 |
-
{% endif -%}
|
39 |
-
|
40 |
-
Combined:
|
41 |
-
|
42 |
-
{%- if both -%}
|
43 |
-
<ul>
|
44 |
-
<li> {{- both -}} </li>
|
45 |
-
</ul>
|
46 |
-
|
47 |
-
{%- endif -%}
|
48 |
-
|
49 |
-
end
|
50 |
-
--DATA--
|
51 |
-
return ['leading' => 'leading space', 'trailing' => 'trailing space', 'both' => 'both']
|
52 |
-
--EXPECT--
|
53 |
-
Trim on control tag:
|
54 |
-
123456789
|
55 |
-
|
56 |
-
Trim on output tag:
|
57 |
-
123456789
|
58 |
-
|
59 |
-
Trim comments:After the comment.
|
60 |
-
|
61 |
-
Trim leading space:
|
62 |
-
leading space
|
63 |
-
leading space
|
64 |
-
|
65 |
-
Trim trailing space:
|
66 |
-
trailing spaceCombined:<ul>
|
67 |
-
<li>both</li>
|
68 |
-
</ul>end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_delimiter_as_strings.test
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Whitespace trimming as strings.
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 5 * '{#-'|length }}
|
5 |
-
{{ '{{-'|length * 5 + '{%-'|length }}
|
6 |
-
--DATA--
|
7 |
-
return []
|
8 |
-
--EXPECT--
|
9 |
-
15
|
10 |
-
18
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_left.test
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Whitespace trimming on tags (left side).
|
3 |
-
--TEMPLATE--
|
4 |
-
**{% if true %}
|
5 |
-
foo
|
6 |
-
|
7 |
-
{%- endif %}**
|
8 |
-
|
9 |
-
**
|
10 |
-
|
11 |
-
{{- 'foo' }}**
|
12 |
-
|
13 |
-
**
|
14 |
-
|
15 |
-
|
16 |
-
{#- comment #}**
|
17 |
-
|
18 |
-
**{% verbatim %}
|
19 |
-
foo
|
20 |
-
|
21 |
-
{%- endverbatim %}**
|
22 |
-
--DATA--
|
23 |
-
return []
|
24 |
-
--EXPECT--
|
25 |
-
**foo**
|
26 |
-
|
27 |
-
**foo**
|
28 |
-
|
29 |
-
****
|
30 |
-
|
31 |
-
**
|
32 |
-
foo**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_line_left.test
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Line whitespace trimming on tags (left side).
|
3 |
-
--TEMPLATE--
|
4 |
-
**{% if true %}
|
5 |
-
foo
|
6 |
-
{%~ endif %}**
|
7 |
-
|
8 |
-
**
|
9 |
-
{{~ 'foo' }}**
|
10 |
-
|
11 |
-
**
|
12 |
-
{#~ comment #}**
|
13 |
-
|
14 |
-
**{% verbatim %}
|
15 |
-
foo
|
16 |
-
|
17 |
-
{%~ endverbatim %}**
|
18 |
-
--DATA--
|
19 |
-
return []
|
20 |
-
--EXPECT--
|
21 |
-
**foo
|
22 |
-
**
|
23 |
-
|
24 |
-
**
|
25 |
-
foo**
|
26 |
-
|
27 |
-
**
|
28 |
-
**
|
29 |
-
|
30 |
-
**
|
31 |
-
foo
|
32 |
-
|
33 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_line_right.test
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Line whitespace trimming on tags (right side).
|
3 |
-
--TEMPLATE--
|
4 |
-
**{% if true ~%}
|
5 |
-
foo{% endif %}**
|
6 |
-
|
7 |
-
**{{ 'foo' ~}}
|
8 |
-
foo
|
9 |
-
**
|
10 |
-
|
11 |
-
**{# comment ~#}
|
12 |
-
foo
|
13 |
-
**
|
14 |
-
|
15 |
-
**{% verbatim ~%}
|
16 |
-
foo{% endverbatim %}**
|
17 |
-
--DATA--
|
18 |
-
return []
|
19 |
-
--EXPECT--
|
20 |
-
**
|
21 |
-
foo**
|
22 |
-
|
23 |
-
**foo
|
24 |
-
foo
|
25 |
-
**
|
26 |
-
|
27 |
-
**
|
28 |
-
foo
|
29 |
-
**
|
30 |
-
|
31 |
-
**
|
32 |
-
foo**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Fixtures/whitespace/trim_right.test
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Whitespace trimming on tags (right side).
|
3 |
-
--TEMPLATE--
|
4 |
-
**{% if true -%}
|
5 |
-
|
6 |
-
foo{% endif %}**
|
7 |
-
|
8 |
-
**{{ 'foo' -}}
|
9 |
-
|
10 |
-
**
|
11 |
-
|
12 |
-
**{# comment -#}
|
13 |
-
|
14 |
-
**
|
15 |
-
|
16 |
-
**{% verbatim -%}
|
17 |
-
|
18 |
-
foo{% endverbatim %}**
|
19 |
-
--DATA--
|
20 |
-
return []
|
21 |
-
--EXPECT--
|
22 |
-
**foo**
|
23 |
-
|
24 |
-
**foo**
|
25 |
-
|
26 |
-
****
|
27 |
-
|
28 |
-
**foo**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/IntegrationTest.php
DELETED
@@ -1,386 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Extension\AbstractExtension;
|
15 |
-
use Twig\Extension\DebugExtension;
|
16 |
-
use Twig\Extension\SandboxExtension;
|
17 |
-
use Twig\Extension\StringLoaderExtension;
|
18 |
-
use Twig\Node\Expression\ConstantExpression;
|
19 |
-
use Twig\Node\PrintNode;
|
20 |
-
use Twig\Sandbox\SecurityPolicy;
|
21 |
-
use Twig\Test\IntegrationTestCase;
|
22 |
-
use Twig\Token;
|
23 |
-
use Twig\TokenParser\AbstractTokenParser;
|
24 |
-
use Twig\TwigFilter;
|
25 |
-
use Twig\TwigFunction;
|
26 |
-
use Twig\TwigTest;
|
27 |
-
|
28 |
-
// This function is defined to check that escaping strategies
|
29 |
-
// like html works even if a function with the same name is defined.
|
30 |
-
function html()
|
31 |
-
{
|
32 |
-
return 'foo';
|
33 |
-
}
|
34 |
-
|
35 |
-
class IntegrationTest extends IntegrationTestCase
|
36 |
-
{
|
37 |
-
public function getExtensions()
|
38 |
-
{
|
39 |
-
$policy = new SecurityPolicy([], [], [], [], ['dump']);
|
40 |
-
|
41 |
-
return [
|
42 |
-
new DebugExtension(),
|
43 |
-
new SandboxExtension($policy, false),
|
44 |
-
new StringLoaderExtension(),
|
45 |
-
new TwigTestExtension(),
|
46 |
-
];
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getFixturesDir()
|
50 |
-
{
|
51 |
-
return __DIR__.'/Fixtures/';
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
function test_foo($value = 'foo')
|
56 |
-
{
|
57 |
-
return $value;
|
58 |
-
}
|
59 |
-
|
60 |
-
class TwigTestFoo implements \Iterator
|
61 |
-
{
|
62 |
-
const BAR_NAME = 'bar';
|
63 |
-
|
64 |
-
public $position = 0;
|
65 |
-
public $array = [1, 2];
|
66 |
-
|
67 |
-
public function bar($param1 = null, $param2 = null)
|
68 |
-
{
|
69 |
-
return 'bar'.($param1 ? '_'.$param1 : '').($param2 ? '-'.$param2 : '');
|
70 |
-
}
|
71 |
-
|
72 |
-
public function getFoo()
|
73 |
-
{
|
74 |
-
return 'foo';
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getSelf()
|
78 |
-
{
|
79 |
-
return $this;
|
80 |
-
}
|
81 |
-
|
82 |
-
public function is()
|
83 |
-
{
|
84 |
-
return 'is';
|
85 |
-
}
|
86 |
-
|
87 |
-
public function in()
|
88 |
-
{
|
89 |
-
return 'in';
|
90 |
-
}
|
91 |
-
|
92 |
-
public function not()
|
93 |
-
{
|
94 |
-
return 'not';
|
95 |
-
}
|
96 |
-
|
97 |
-
public function strToLower($value)
|
98 |
-
{
|
99 |
-
return strtolower($value);
|
100 |
-
}
|
101 |
-
|
102 |
-
public function rewind()
|
103 |
-
{
|
104 |
-
$this->position = 0;
|
105 |
-
}
|
106 |
-
|
107 |
-
public function current()
|
108 |
-
{
|
109 |
-
return $this->array[$this->position];
|
110 |
-
}
|
111 |
-
|
112 |
-
public function key()
|
113 |
-
{
|
114 |
-
return 'a';
|
115 |
-
}
|
116 |
-
|
117 |
-
public function next()
|
118 |
-
{
|
119 |
-
++$this->position;
|
120 |
-
}
|
121 |
-
|
122 |
-
public function valid()
|
123 |
-
{
|
124 |
-
return isset($this->array[$this->position]);
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
class TwigTestTokenParser_§ extends AbstractTokenParser
|
129 |
-
{
|
130 |
-
public function parse(Token $token)
|
131 |
-
{
|
132 |
-
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
|
133 |
-
|
134 |
-
return new PrintNode(new ConstantExpression('§', -1), -1);
|
135 |
-
}
|
136 |
-
|
137 |
-
public function getTag()
|
138 |
-
{
|
139 |
-
return '§';
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
class TwigTestExtension extends AbstractExtension
|
144 |
-
{
|
145 |
-
public function getTokenParsers()
|
146 |
-
{
|
147 |
-
return [
|
148 |
-
new TwigTestTokenParser_§(),
|
149 |
-
];
|
150 |
-
}
|
151 |
-
|
152 |
-
public function getFilters()
|
153 |
-
{
|
154 |
-
return [
|
155 |
-
new TwigFilter('§', [$this, '§Filter']),
|
156 |
-
new TwigFilter('escape_and_nl2br', [$this, 'escape_and_nl2br'], ['needs_environment' => true, 'is_safe' => ['html']]),
|
157 |
-
new TwigFilter('nl2br', [$this, 'nl2br'], ['pre_escape' => 'html', 'is_safe' => ['html']]),
|
158 |
-
new TwigFilter('escape_something', [$this, 'escape_something'], ['is_safe' => ['something']]),
|
159 |
-
new TwigFilter('preserves_safety', [$this, 'preserves_safety'], ['preserves_safety' => ['html']]),
|
160 |
-
new TwigFilter('static_call_string', 'Twig\Tests\TwigTestExtension::staticCall'),
|
161 |
-
new TwigFilter('static_call_array', ['Twig\Tests\TwigTestExtension', 'staticCall']),
|
162 |
-
new TwigFilter('magic_call', [$this, 'magicCall']),
|
163 |
-
new TwigFilter('magic_call_string', 'Twig\Tests\TwigTestExtension::magicStaticCall'),
|
164 |
-
new TwigFilter('magic_call_array', ['Twig\Tests\TwigTestExtension', 'magicStaticCall']),
|
165 |
-
new TwigFilter('*_path', [$this, 'dynamic_path']),
|
166 |
-
new TwigFilter('*_foo_*_bar', [$this, 'dynamic_foo']),
|
167 |
-
];
|
168 |
-
}
|
169 |
-
|
170 |
-
public function getFunctions()
|
171 |
-
{
|
172 |
-
return [
|
173 |
-
new TwigFunction('§', [$this, '§Function']),
|
174 |
-
new TwigFunction('safe_br', [$this, 'br'], ['is_safe' => ['html']]),
|
175 |
-
new TwigFunction('unsafe_br', [$this, 'br']),
|
176 |
-
new TwigFunction('static_call_string', 'Twig\Tests\TwigTestExtension::staticCall'),
|
177 |
-
new TwigFunction('static_call_array', ['Twig\Tests\TwigTestExtension', 'staticCall']),
|
178 |
-
new TwigFunction('*_path', [$this, 'dynamic_path']),
|
179 |
-
new TwigFunction('*_foo_*_bar', [$this, 'dynamic_foo']),
|
180 |
-
];
|
181 |
-
}
|
182 |
-
|
183 |
-
public function getTests()
|
184 |
-
{
|
185 |
-
return [
|
186 |
-
new TwigTest('multi word', [$this, 'is_multi_word']),
|
187 |
-
new TwigTest('test_*', [$this, 'dynamic_test']),
|
188 |
-
];
|
189 |
-
}
|
190 |
-
|
191 |
-
public function §Filter($value)
|
192 |
-
{
|
193 |
-
return "§{$value}§";
|
194 |
-
}
|
195 |
-
|
196 |
-
public function §Function($value)
|
197 |
-
{
|
198 |
-
return "§{$value}§";
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* nl2br which also escapes, for testing escaper filters.
|
203 |
-
*/
|
204 |
-
public function escape_and_nl2br($env, $value, $sep = '<br />')
|
205 |
-
{
|
206 |
-
return $this->nl2br(twig_escape_filter($env, $value, 'html'), $sep);
|
207 |
-
}
|
208 |
-
|
209 |
-
/**
|
210 |
-
* nl2br only, for testing filters with pre_escape.
|
211 |
-
*/
|
212 |
-
public function nl2br($value, $sep = '<br />')
|
213 |
-
{
|
214 |
-
// not secure if $value contains html tags (not only entities)
|
215 |
-
// don't use
|
216 |
-
return str_replace("\n", "$sep\n", $value);
|
217 |
-
}
|
218 |
-
|
219 |
-
public function dynamic_path($element, $item)
|
220 |
-
{
|
221 |
-
return $element.'/'.$item;
|
222 |
-
}
|
223 |
-
|
224 |
-
public function dynamic_foo($foo, $bar, $item)
|
225 |
-
{
|
226 |
-
return $foo.'/'.$bar.'/'.$item;
|
227 |
-
}
|
228 |
-
|
229 |
-
public function dynamic_test($element, $item)
|
230 |
-
{
|
231 |
-
return $element === $item;
|
232 |
-
}
|
233 |
-
|
234 |
-
public function escape_something($value)
|
235 |
-
{
|
236 |
-
return strtoupper($value);
|
237 |
-
}
|
238 |
-
|
239 |
-
public function preserves_safety($value)
|
240 |
-
{
|
241 |
-
return strtoupper($value);
|
242 |
-
}
|
243 |
-
|
244 |
-
public static function staticCall($value)
|
245 |
-
{
|
246 |
-
return "*$value*";
|
247 |
-
}
|
248 |
-
|
249 |
-
public function br()
|
250 |
-
{
|
251 |
-
return '<br />';
|
252 |
-
}
|
253 |
-
|
254 |
-
public function is_multi_word($value)
|
255 |
-
{
|
256 |
-
return false !== strpos($value, ' ');
|
257 |
-
}
|
258 |
-
|
259 |
-
public function __call($method, $arguments)
|
260 |
-
{
|
261 |
-
if ('magicCall' !== $method) {
|
262 |
-
throw new \BadMethodCallException('Unexpected call to __call');
|
263 |
-
}
|
264 |
-
|
265 |
-
return 'magic_'.$arguments[0];
|
266 |
-
}
|
267 |
-
|
268 |
-
public static function __callStatic($method, $arguments)
|
269 |
-
{
|
270 |
-
if ('magicStaticCall' !== $method) {
|
271 |
-
throw new \BadMethodCallException('Unexpected call to __callStatic');
|
272 |
-
}
|
273 |
-
|
274 |
-
return 'static_magic_'.$arguments[0];
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* This class is used in tests for the "length" filter and "empty" test. It asserts that __call is not
|
280 |
-
* used to convert such objects to strings.
|
281 |
-
*/
|
282 |
-
class MagicCallStub
|
283 |
-
{
|
284 |
-
public function __call($name, $args)
|
285 |
-
{
|
286 |
-
throw new \Exception('__call shall not be called');
|
287 |
-
}
|
288 |
-
}
|
289 |
-
|
290 |
-
class ToStringStub
|
291 |
-
{
|
292 |
-
/**
|
293 |
-
* @var string
|
294 |
-
*/
|
295 |
-
private $string;
|
296 |
-
|
297 |
-
public function __construct($string)
|
298 |
-
{
|
299 |
-
$this->string = $string;
|
300 |
-
}
|
301 |
-
|
302 |
-
public function __toString()
|
303 |
-
{
|
304 |
-
return $this->string;
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* This class is used in tests for the length filter and empty test to show
|
310 |
-
* that when \Countable is implemented, it is preferred over the __toString()
|
311 |
-
* method.
|
312 |
-
*/
|
313 |
-
class CountableStub implements \Countable
|
314 |
-
{
|
315 |
-
private $count;
|
316 |
-
|
317 |
-
public function __construct($count)
|
318 |
-
{
|
319 |
-
$this->count = $count;
|
320 |
-
}
|
321 |
-
|
322 |
-
public function count()
|
323 |
-
{
|
324 |
-
return $this->count;
|
325 |
-
}
|
326 |
-
|
327 |
-
public function __toString()
|
328 |
-
{
|
329 |
-
throw new \Exception('__toString shall not be called on \Countables');
|
330 |
-
}
|
331 |
-
}
|
332 |
-
|
333 |
-
/**
|
334 |
-
* This class is used in tests for the length filter.
|
335 |
-
*/
|
336 |
-
class IteratorAggregateStub implements \IteratorAggregate
|
337 |
-
{
|
338 |
-
private $data;
|
339 |
-
|
340 |
-
public function __construct(array $data)
|
341 |
-
{
|
342 |
-
$this->data = $data;
|
343 |
-
}
|
344 |
-
|
345 |
-
public function getIterator()
|
346 |
-
{
|
347 |
-
return new \ArrayIterator($this->data);
|
348 |
-
}
|
349 |
-
}
|
350 |
-
|
351 |
-
class SimpleIteratorForTesting implements \Iterator
|
352 |
-
{
|
353 |
-
private $data = [1, 2, 3, 4, 5, 6, 7];
|
354 |
-
private $key = 0;
|
355 |
-
|
356 |
-
public function current()
|
357 |
-
{
|
358 |
-
return $this->key;
|
359 |
-
}
|
360 |
-
|
361 |
-
public function next()
|
362 |
-
{
|
363 |
-
++$this->key;
|
364 |
-
}
|
365 |
-
|
366 |
-
public function key()
|
367 |
-
{
|
368 |
-
return $this->key;
|
369 |
-
}
|
370 |
-
|
371 |
-
public function valid()
|
372 |
-
{
|
373 |
-
return isset($this->data[$this->key]);
|
374 |
-
}
|
375 |
-
|
376 |
-
public function rewind()
|
377 |
-
{
|
378 |
-
$this->key = 0;
|
379 |
-
}
|
380 |
-
|
381 |
-
public function __toString()
|
382 |
-
{
|
383 |
-
// for testing, make sure string length returned is not the same as the `iterator_count`
|
384 |
-
return str_repeat('X', iterator_count($this) + 10);
|
385 |
-
}
|
386 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/LegacyFixtures/autoescape/filename.legacy.test
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"filename" autoescape strategy
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ br -}}
|
5 |
-
{{ include('index.html.twig') -}}
|
6 |
-
{{ include('index.txt.twig') -}}
|
7 |
-
--TEMPLATE(index.html.twig)--
|
8 |
-
{{ br -}}
|
9 |
-
--TEMPLATE(index.txt.twig)--
|
10 |
-
{{ br -}}
|
11 |
-
--DATA--
|
12 |
-
return ['br' => '<br />']
|
13 |
-
--CONFIG--
|
14 |
-
return ['autoescape' => 'filename']
|
15 |
-
--EXPECT--
|
16 |
-
<br />
|
17 |
-
<br />
|
18 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/LegacyFixtures/functions/undefined_block.legacy.test
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
"block" function with undefined block
|
3 |
-
--TEMPLATE--
|
4 |
-
{% extends "base.twig" %}
|
5 |
-
{% block foo %}{{ parent() }}{{ block('unknown') }}{{ block('bar') }}{% endblock %}
|
6 |
-
--TEMPLATE(base.twig)--
|
7 |
-
{% block foo %}Foo{% endblock %}
|
8 |
-
{% block bar %}Bar{% endblock %}
|
9 |
-
--DATA--
|
10 |
-
return []
|
11 |
-
--EXPECT--
|
12 |
-
FooBarBar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/LegacyFixtures/test.legacy.test
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
--TEST--
|
2 |
-
Old test classes usage
|
3 |
-
--TEMPLATE--
|
4 |
-
{{ 'foo' is multi word ? 'yes' : 'no' }}
|
5 |
-
--DATA--
|
6 |
-
return []
|
7 |
-
--EXPECT--
|
8 |
-
no
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/LegacyIntegrationTest.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Extension\AbstractExtension;
|
15 |
-
use Twig\Test\IntegrationTestCase;
|
16 |
-
|
17 |
-
class LegacyIntegrationTest extends IntegrationTestCase
|
18 |
-
{
|
19 |
-
public function getExtensions()
|
20 |
-
{
|
21 |
-
return [
|
22 |
-
new LegacyTwigTestExtension(),
|
23 |
-
];
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getFixturesDir()
|
27 |
-
{
|
28 |
-
return __DIR__.'/LegacyFixtures/';
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getTests($name, $legacyTests = false)
|
32 |
-
{
|
33 |
-
if (!$legacyTests) {
|
34 |
-
return [['', '', '', [], '', []]];
|
35 |
-
}
|
36 |
-
|
37 |
-
return parent::getTests($name, true);
|
38 |
-
}
|
39 |
-
}
|
40 |
-
|
41 |
-
class LegacyTwigTestExtension extends AbstractExtension
|
42 |
-
{
|
43 |
-
public function getTests()
|
44 |
-
{
|
45 |
-
return [
|
46 |
-
'multi word' => new \Twig_Test_Method($this, 'is_multi_word'),
|
47 |
-
];
|
48 |
-
}
|
49 |
-
|
50 |
-
public function is_multi_word($value)
|
51 |
-
{
|
52 |
-
return false !== strpos($value, ' ');
|
53 |
-
}
|
54 |
-
|
55 |
-
public function getName()
|
56 |
-
{
|
57 |
-
return 'legacy_integration_test';
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/LexerTest.php
DELETED
@@ -1,378 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Lexer;
|
16 |
-
use Twig\Source;
|
17 |
-
use Twig\Token;
|
18 |
-
|
19 |
-
class LexerTest extends \PHPUnit\Framework\TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @group legacy
|
23 |
-
*/
|
24 |
-
public function testLegacyConstructorSignature()
|
25 |
-
{
|
26 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
27 |
-
$stream = $lexer->tokenize('{{ foo }}', 'foo');
|
28 |
-
$this->assertEquals('foo', $stream->getFilename());
|
29 |
-
$this->assertEquals('{{ foo }}', $stream->getSource());
|
30 |
-
}
|
31 |
-
|
32 |
-
public function testNameLabelForTag()
|
33 |
-
{
|
34 |
-
$template = '{% § %}';
|
35 |
-
|
36 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
37 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
38 |
-
|
39 |
-
$stream->expect(Token::BLOCK_START_TYPE);
|
40 |
-
$this->assertSame('§', $stream->expect(Token::NAME_TYPE)->getValue());
|
41 |
-
}
|
42 |
-
|
43 |
-
public function testNameLabelForFunction()
|
44 |
-
{
|
45 |
-
$template = '{{ §() }}';
|
46 |
-
|
47 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
48 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
49 |
-
|
50 |
-
$stream->expect(Token::VAR_START_TYPE);
|
51 |
-
$this->assertSame('§', $stream->expect(Token::NAME_TYPE)->getValue());
|
52 |
-
}
|
53 |
-
|
54 |
-
public function testBracketsNesting()
|
55 |
-
{
|
56 |
-
$template = '{{ {"a":{"b":"c"}} }}';
|
57 |
-
|
58 |
-
$this->assertEquals(2, $this->countToken($template, Token::PUNCTUATION_TYPE, '{'));
|
59 |
-
$this->assertEquals(2, $this->countToken($template, Token::PUNCTUATION_TYPE, '}'));
|
60 |
-
}
|
61 |
-
|
62 |
-
protected function countToken($template, $type, $value = null)
|
63 |
-
{
|
64 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
65 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
66 |
-
|
67 |
-
$count = 0;
|
68 |
-
while (!$stream->isEOF()) {
|
69 |
-
$token = $stream->next();
|
70 |
-
if ($type === $token->getType()) {
|
71 |
-
if (null === $value || $value === $token->getValue()) {
|
72 |
-
++$count;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
return $count;
|
78 |
-
}
|
79 |
-
|
80 |
-
public function testLineDirective()
|
81 |
-
{
|
82 |
-
$template = "foo\n"
|
83 |
-
."bar\n"
|
84 |
-
."{% line 10 %}\n"
|
85 |
-
."{{\n"
|
86 |
-
."baz\n"
|
87 |
-
."}}\n";
|
88 |
-
|
89 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
90 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
91 |
-
|
92 |
-
// foo\nbar\n
|
93 |
-
$this->assertSame(1, $stream->expect(Token::TEXT_TYPE)->getLine());
|
94 |
-
// \n (after {% line %})
|
95 |
-
$this->assertSame(10, $stream->expect(Token::TEXT_TYPE)->getLine());
|
96 |
-
// {{
|
97 |
-
$this->assertSame(11, $stream->expect(Token::VAR_START_TYPE)->getLine());
|
98 |
-
// baz
|
99 |
-
$this->assertSame(12, $stream->expect(Token::NAME_TYPE)->getLine());
|
100 |
-
}
|
101 |
-
|
102 |
-
public function testLineDirectiveInline()
|
103 |
-
{
|
104 |
-
$template = "foo\n"
|
105 |
-
."bar{% line 10 %}{{\n"
|
106 |
-
."baz\n"
|
107 |
-
."}}\n";
|
108 |
-
|
109 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
110 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
111 |
-
|
112 |
-
// foo\nbar
|
113 |
-
$this->assertSame(1, $stream->expect(Token::TEXT_TYPE)->getLine());
|
114 |
-
// {{
|
115 |
-
$this->assertSame(10, $stream->expect(Token::VAR_START_TYPE)->getLine());
|
116 |
-
// baz
|
117 |
-
$this->assertSame(11, $stream->expect(Token::NAME_TYPE)->getLine());
|
118 |
-
}
|
119 |
-
|
120 |
-
public function testLongComments()
|
121 |
-
{
|
122 |
-
$template = '{# '.str_repeat('*', 100000).' #}';
|
123 |
-
|
124 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
125 |
-
$lexer->tokenize(new Source($template, 'index'));
|
126 |
-
|
127 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
128 |
-
// can be executed without throwing any exceptions
|
129 |
-
$this->addToAssertionCount(1);
|
130 |
-
}
|
131 |
-
|
132 |
-
public function testLongVerbatim()
|
133 |
-
{
|
134 |
-
$template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}';
|
135 |
-
|
136 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
137 |
-
$lexer->tokenize(new Source($template, 'index'));
|
138 |
-
|
139 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
140 |
-
// can be executed without throwing any exceptions
|
141 |
-
$this->addToAssertionCount(1);
|
142 |
-
}
|
143 |
-
|
144 |
-
public function testLongVar()
|
145 |
-
{
|
146 |
-
$template = '{{ '.str_repeat('x', 100000).' }}';
|
147 |
-
|
148 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
149 |
-
$lexer->tokenize(new Source($template, 'index'));
|
150 |
-
|
151 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
152 |
-
// can be executed without throwing any exceptions
|
153 |
-
$this->addToAssertionCount(1);
|
154 |
-
}
|
155 |
-
|
156 |
-
public function testLongBlock()
|
157 |
-
{
|
158 |
-
$template = '{% '.str_repeat('x', 100000).' %}';
|
159 |
-
|
160 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
161 |
-
$lexer->tokenize(new Source($template, 'index'));
|
162 |
-
|
163 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
164 |
-
// can be executed without throwing any exceptions
|
165 |
-
$this->addToAssertionCount(1);
|
166 |
-
}
|
167 |
-
|
168 |
-
public function testBigNumbers()
|
169 |
-
{
|
170 |
-
$template = '{{ 922337203685477580700 }}';
|
171 |
-
|
172 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
173 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
174 |
-
$stream->next();
|
175 |
-
$node = $stream->next();
|
176 |
-
$this->assertEquals('922337203685477580700', $node->getValue());
|
177 |
-
}
|
178 |
-
|
179 |
-
public function testStringWithEscapedDelimiter()
|
180 |
-
{
|
181 |
-
$tests = [
|
182 |
-
"{{ 'foo \' bar' }}" => 'foo \' bar',
|
183 |
-
'{{ "foo \" bar" }}' => 'foo " bar',
|
184 |
-
];
|
185 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
186 |
-
foreach ($tests as $template => $expected) {
|
187 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
188 |
-
$stream->expect(Token::VAR_START_TYPE);
|
189 |
-
$stream->expect(Token::STRING_TYPE, $expected);
|
190 |
-
|
191 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
192 |
-
// can be executed without throwing any exceptions
|
193 |
-
$this->addToAssertionCount(1);
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
public function testStringWithInterpolation()
|
198 |
-
{
|
199 |
-
$template = 'foo {{ "bar #{ baz + 1 }" }}';
|
200 |
-
|
201 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
202 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
203 |
-
$stream->expect(Token::TEXT_TYPE, 'foo ');
|
204 |
-
$stream->expect(Token::VAR_START_TYPE);
|
205 |
-
$stream->expect(Token::STRING_TYPE, 'bar ');
|
206 |
-
$stream->expect(Token::INTERPOLATION_START_TYPE);
|
207 |
-
$stream->expect(Token::NAME_TYPE, 'baz');
|
208 |
-
$stream->expect(Token::OPERATOR_TYPE, '+');
|
209 |
-
$stream->expect(Token::NUMBER_TYPE, '1');
|
210 |
-
$stream->expect(Token::INTERPOLATION_END_TYPE);
|
211 |
-
$stream->expect(Token::VAR_END_TYPE);
|
212 |
-
|
213 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
214 |
-
// can be executed without throwing any exceptions
|
215 |
-
$this->addToAssertionCount(1);
|
216 |
-
}
|
217 |
-
|
218 |
-
public function testStringWithEscapedInterpolation()
|
219 |
-
{
|
220 |
-
$template = '{{ "bar \#{baz+1}" }}';
|
221 |
-
|
222 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
223 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
224 |
-
$stream->expect(Token::VAR_START_TYPE);
|
225 |
-
$stream->expect(Token::STRING_TYPE, 'bar #{baz+1}');
|
226 |
-
$stream->expect(Token::VAR_END_TYPE);
|
227 |
-
|
228 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
229 |
-
// can be executed without throwing any exceptions
|
230 |
-
$this->addToAssertionCount(1);
|
231 |
-
}
|
232 |
-
|
233 |
-
public function testStringWithHash()
|
234 |
-
{
|
235 |
-
$template = '{{ "bar # baz" }}';
|
236 |
-
|
237 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
238 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
239 |
-
$stream->expect(Token::VAR_START_TYPE);
|
240 |
-
$stream->expect(Token::STRING_TYPE, 'bar # baz');
|
241 |
-
$stream->expect(Token::VAR_END_TYPE);
|
242 |
-
|
243 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
244 |
-
// can be executed without throwing any exceptions
|
245 |
-
$this->addToAssertionCount(1);
|
246 |
-
}
|
247 |
-
|
248 |
-
public function testStringWithUnterminatedInterpolation()
|
249 |
-
{
|
250 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
251 |
-
$this->expectExceptionMessage('Unclosed """');
|
252 |
-
|
253 |
-
$template = '{{ "bar #{x" }}';
|
254 |
-
|
255 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
256 |
-
$lexer->tokenize(new Source($template, 'index'));
|
257 |
-
}
|
258 |
-
|
259 |
-
public function testStringWithNestedInterpolations()
|
260 |
-
{
|
261 |
-
$template = '{{ "bar #{ "foo#{bar}" }" }}';
|
262 |
-
|
263 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
264 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
265 |
-
$stream->expect(Token::VAR_START_TYPE);
|
266 |
-
$stream->expect(Token::STRING_TYPE, 'bar ');
|
267 |
-
$stream->expect(Token::INTERPOLATION_START_TYPE);
|
268 |
-
$stream->expect(Token::STRING_TYPE, 'foo');
|
269 |
-
$stream->expect(Token::INTERPOLATION_START_TYPE);
|
270 |
-
$stream->expect(Token::NAME_TYPE, 'bar');
|
271 |
-
$stream->expect(Token::INTERPOLATION_END_TYPE);
|
272 |
-
$stream->expect(Token::INTERPOLATION_END_TYPE);
|
273 |
-
$stream->expect(Token::VAR_END_TYPE);
|
274 |
-
|
275 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
276 |
-
// can be executed without throwing any exceptions
|
277 |
-
$this->addToAssertionCount(1);
|
278 |
-
}
|
279 |
-
|
280 |
-
public function testStringWithNestedInterpolationsInBlock()
|
281 |
-
{
|
282 |
-
$template = '{% foo "bar #{ "foo#{bar}" }" %}';
|
283 |
-
|
284 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
285 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
286 |
-
$stream->expect(Token::BLOCK_START_TYPE);
|
287 |
-
$stream->expect(Token::NAME_TYPE, 'foo');
|
288 |
-
$stream->expect(Token::STRING_TYPE, 'bar ');
|
289 |
-
$stream->expect(Token::INTERPOLATION_START_TYPE);
|
290 |
-
$stream->expect(Token::STRING_TYPE, 'foo');
|
291 |
-
$stream->expect(Token::INTERPOLATION_START_TYPE);
|
292 |
-
$stream->expect(Token::NAME_TYPE, 'bar');
|
293 |
-
$stream->expect(Token::INTERPOLATION_END_TYPE);
|
294 |
-
$stream->expect(Token::INTERPOLATION_END_TYPE);
|
295 |
-
$stream->expect(Token::BLOCK_END_TYPE);
|
296 |
-
|
297 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
298 |
-
// can be executed without throwing any exceptions
|
299 |
-
$this->addToAssertionCount(1);
|
300 |
-
}
|
301 |
-
|
302 |
-
public function testOperatorEndingWithALetterAtTheEndOfALine()
|
303 |
-
{
|
304 |
-
$template = "{{ 1 and\n0}}";
|
305 |
-
|
306 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
307 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
308 |
-
$stream->expect(Token::VAR_START_TYPE);
|
309 |
-
$stream->expect(Token::NUMBER_TYPE, 1);
|
310 |
-
$stream->expect(Token::OPERATOR_TYPE, 'and');
|
311 |
-
|
312 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
313 |
-
// can be executed without throwing any exceptions
|
314 |
-
$this->addToAssertionCount(1);
|
315 |
-
}
|
316 |
-
|
317 |
-
public function testUnterminatedVariable()
|
318 |
-
{
|
319 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
320 |
-
$this->expectExceptionMessage('Unclosed "variable" in "index" at line 3');
|
321 |
-
|
322 |
-
$template = '
|
323 |
-
|
324 |
-
{{
|
325 |
-
|
326 |
-
bar
|
327 |
-
|
328 |
-
|
329 |
-
';
|
330 |
-
|
331 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
332 |
-
$lexer->tokenize(new Source($template, 'index'));
|
333 |
-
}
|
334 |
-
|
335 |
-
public function testUnterminatedBlock()
|
336 |
-
{
|
337 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
338 |
-
$this->expectExceptionMessage('Unclosed "block" in "index" at line 3');
|
339 |
-
|
340 |
-
$template = '
|
341 |
-
|
342 |
-
{%
|
343 |
-
|
344 |
-
bar
|
345 |
-
|
346 |
-
|
347 |
-
';
|
348 |
-
|
349 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
350 |
-
$lexer->tokenize(new Source($template, 'index'));
|
351 |
-
}
|
352 |
-
|
353 |
-
public function testOverridingSyntax()
|
354 |
-
{
|
355 |
-
$template = '[# comment #]{# variable #}/# if true #/true/# endif #/';
|
356 |
-
$lexer = new Lexer(new Environment($this->createMock('\Twig\Loader\LoaderInterface')), [
|
357 |
-
'tag_comment' => ['[#', '#]'],
|
358 |
-
'tag_block' => ['/#', '#/'],
|
359 |
-
'tag_variable' => ['{#', '#}'],
|
360 |
-
]);
|
361 |
-
$stream = $lexer->tokenize(new Source($template, 'index'));
|
362 |
-
$stream->expect(Token::VAR_START_TYPE);
|
363 |
-
$stream->expect(Token::NAME_TYPE, 'variable');
|
364 |
-
$stream->expect(Token::VAR_END_TYPE);
|
365 |
-
$stream->expect(Token::BLOCK_START_TYPE);
|
366 |
-
$stream->expect(Token::NAME_TYPE, 'if');
|
367 |
-
$stream->expect(Token::NAME_TYPE, 'true');
|
368 |
-
$stream->expect(Token::BLOCK_END_TYPE);
|
369 |
-
$stream->expect(Token::TEXT_TYPE, 'true');
|
370 |
-
$stream->expect(Token::BLOCK_START_TYPE);
|
371 |
-
$stream->expect(Token::NAME_TYPE, 'endif');
|
372 |
-
$stream->expect(Token::BLOCK_END_TYPE);
|
373 |
-
|
374 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
375 |
-
// can be executed without throwing any exceptions
|
376 |
-
$this->addToAssertionCount(1);
|
377 |
-
}
|
378 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/ArrayTest.php
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Loader;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Loader\ArrayLoader;
|
15 |
-
|
16 |
-
class ArrayTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
/**
|
19 |
-
* @group legacy
|
20 |
-
*/
|
21 |
-
public function testGetSource()
|
22 |
-
{
|
23 |
-
$loader = new ArrayLoader(['foo' => 'bar']);
|
24 |
-
|
25 |
-
$this->assertEquals('bar', $loader->getSource('foo'));
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @group legacy
|
30 |
-
*/
|
31 |
-
public function testGetSourceWhenTemplateDoesNotExist()
|
32 |
-
{
|
33 |
-
$this->expectException('\Twig\Error\LoaderError');
|
34 |
-
|
35 |
-
$loader = new ArrayLoader([]);
|
36 |
-
|
37 |
-
$loader->getSource('foo');
|
38 |
-
}
|
39 |
-
|
40 |
-
public function testGetSourceContextWhenTemplateDoesNotExist()
|
41 |
-
{
|
42 |
-
$this->expectException('\Twig\Error\LoaderError');
|
43 |
-
|
44 |
-
$loader = new ArrayLoader([]);
|
45 |
-
|
46 |
-
$loader->getSourceContext('foo');
|
47 |
-
}
|
48 |
-
|
49 |
-
public function testGetCacheKey()
|
50 |
-
{
|
51 |
-
$loader = new ArrayLoader(['foo' => 'bar']);
|
52 |
-
|
53 |
-
$this->assertEquals('foo:bar', $loader->getCacheKey('foo'));
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testGetCacheKeyWhenTemplateHasDuplicateContent()
|
57 |
-
{
|
58 |
-
$loader = new ArrayLoader([
|
59 |
-
'foo' => 'bar',
|
60 |
-
'baz' => 'bar',
|
61 |
-
]);
|
62 |
-
|
63 |
-
$this->assertEquals('foo:bar', $loader->getCacheKey('foo'));
|
64 |
-
$this->assertEquals('baz:bar', $loader->getCacheKey('baz'));
|
65 |
-
}
|
66 |
-
|
67 |
-
public function testGetCacheKeyIsProtectedFromEdgeCollisions()
|
68 |
-
{
|
69 |
-
$loader = new ArrayLoader([
|
70 |
-
'foo__' => 'bar',
|
71 |
-
'foo' => '__bar',
|
72 |
-
]);
|
73 |
-
|
74 |
-
$this->assertEquals('foo__:bar', $loader->getCacheKey('foo__'));
|
75 |
-
$this->assertEquals('foo:__bar', $loader->getCacheKey('foo'));
|
76 |
-
}
|
77 |
-
|
78 |
-
public function testGetCacheKeyWhenTemplateDoesNotExist()
|
79 |
-
{
|
80 |
-
$this->expectException('\Twig\Error\LoaderError');
|
81 |
-
|
82 |
-
$loader = new ArrayLoader([]);
|
83 |
-
|
84 |
-
$loader->getCacheKey('foo');
|
85 |
-
}
|
86 |
-
|
87 |
-
public function testSetTemplate()
|
88 |
-
{
|
89 |
-
$loader = new ArrayLoader([]);
|
90 |
-
$loader->setTemplate('foo', 'bar');
|
91 |
-
|
92 |
-
$this->assertEquals('bar', $loader->getSourceContext('foo')->getCode());
|
93 |
-
}
|
94 |
-
|
95 |
-
public function testIsFresh()
|
96 |
-
{
|
97 |
-
$loader = new ArrayLoader(['foo' => 'bar']);
|
98 |
-
$this->assertTrue($loader->isFresh('foo', time()));
|
99 |
-
}
|
100 |
-
|
101 |
-
public function testIsFreshWhenTemplateDoesNotExist()
|
102 |
-
{
|
103 |
-
$this->expectException('\Twig\Error\LoaderError');
|
104 |
-
|
105 |
-
$loader = new ArrayLoader([]);
|
106 |
-
|
107 |
-
$loader->isFresh('foo', time());
|
108 |
-
}
|
109 |
-
|
110 |
-
public function testTemplateReference()
|
111 |
-
{
|
112 |
-
$name = new Twig_Test_Loader_TemplateReference('foo');
|
113 |
-
$loader = new ArrayLoader(['foo' => 'bar']);
|
114 |
-
|
115 |
-
$loader->getCacheKey($name);
|
116 |
-
$loader->getSourceContext($name);
|
117 |
-
$loader->isFresh($name, time());
|
118 |
-
$loader->setTemplate($name, 'foo:bar');
|
119 |
-
|
120 |
-
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
|
121 |
-
// can be executed without crashing PHP
|
122 |
-
$this->addToAssertionCount(1);
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
class Twig_Test_Loader_TemplateReference
|
127 |
-
{
|
128 |
-
private $name;
|
129 |
-
|
130 |
-
public function __construct($name)
|
131 |
-
{
|
132 |
-
$this->name = $name;
|
133 |
-
}
|
134 |
-
|
135 |
-
public function __toString()
|
136 |
-
{
|
137 |
-
return $this->name;
|
138 |
-
}
|
139 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/ChainTest.php
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Loader;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Loader\ArrayLoader;
|
15 |
-
use Twig\Loader\ChainLoader;
|
16 |
-
use Twig\Loader\ExistsLoaderInterface;
|
17 |
-
use Twig\Loader\FilesystemLoader;
|
18 |
-
use Twig\Loader\LoaderInterface;
|
19 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
20 |
-
use Twig\Source;
|
21 |
-
|
22 |
-
class ChainTest extends \PHPUnit\Framework\TestCase
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* @group legacy
|
26 |
-
*/
|
27 |
-
public function testGetSource()
|
28 |
-
{
|
29 |
-
$loader = new ChainLoader([
|
30 |
-
new ArrayLoader(['foo' => 'bar']),
|
31 |
-
new ArrayLoader(['foo' => 'foobar', 'bar' => 'foo']),
|
32 |
-
]);
|
33 |
-
|
34 |
-
$this->assertEquals('bar', $loader->getSource('foo'));
|
35 |
-
$this->assertEquals('foo', $loader->getSource('bar'));
|
36 |
-
}
|
37 |
-
|
38 |
-
public function testGetSourceContext()
|
39 |
-
{
|
40 |
-
$path = __DIR__.'/../Fixtures';
|
41 |
-
$loader = new ChainLoader([
|
42 |
-
new ArrayLoader(['foo' => 'bar']),
|
43 |
-
new ArrayLoader(['errors/index.html' => 'baz']),
|
44 |
-
new FilesystemLoader([$path]),
|
45 |
-
]);
|
46 |
-
|
47 |
-
$this->assertEquals('foo', $loader->getSourceContext('foo')->getName());
|
48 |
-
$this->assertSame('', $loader->getSourceContext('foo')->getPath());
|
49 |
-
|
50 |
-
$this->assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName());
|
51 |
-
$this->assertSame('', $loader->getSourceContext('errors/index.html')->getPath());
|
52 |
-
$this->assertEquals('baz', $loader->getSourceContext('errors/index.html')->getCode());
|
53 |
-
|
54 |
-
$this->assertEquals('errors/base.html', $loader->getSourceContext('errors/base.html')->getName());
|
55 |
-
$this->assertEquals(realpath($path.'/errors/base.html'), realpath($loader->getSourceContext('errors/base.html')->getPath()));
|
56 |
-
$this->assertNotEquals('baz', $loader->getSourceContext('errors/base.html')->getCode());
|
57 |
-
}
|
58 |
-
|
59 |
-
public function testGetSourceContextWhenTemplateDoesNotExist()
|
60 |
-
{
|
61 |
-
$this->expectException('\Twig\Error\LoaderError');
|
62 |
-
|
63 |
-
$loader = new ChainLoader([]);
|
64 |
-
|
65 |
-
$loader->getSourceContext('foo');
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @group legacy
|
70 |
-
*/
|
71 |
-
public function testGetSourceWhenTemplateDoesNotExist()
|
72 |
-
{
|
73 |
-
$this->expectException('\Twig\Error\LoaderError');
|
74 |
-
|
75 |
-
$loader = new ChainLoader([]);
|
76 |
-
|
77 |
-
$loader->getSource('foo');
|
78 |
-
}
|
79 |
-
|
80 |
-
public function testGetCacheKey()
|
81 |
-
{
|
82 |
-
$loader = new ChainLoader([
|
83 |
-
new ArrayLoader(['foo' => 'bar']),
|
84 |
-
new ArrayLoader(['foo' => 'foobar', 'bar' => 'foo']),
|
85 |
-
]);
|
86 |
-
|
87 |
-
$this->assertEquals('foo:bar', $loader->getCacheKey('foo'));
|
88 |
-
$this->assertEquals('bar:foo', $loader->getCacheKey('bar'));
|
89 |
-
}
|
90 |
-
|
91 |
-
public function testGetCacheKeyWhenTemplateDoesNotExist()
|
92 |
-
{
|
93 |
-
$this->expectException('\Twig\Error\LoaderError');
|
94 |
-
|
95 |
-
$loader = new ChainLoader([]);
|
96 |
-
|
97 |
-
$loader->getCacheKey('foo');
|
98 |
-
}
|
99 |
-
|
100 |
-
public function testAddLoader()
|
101 |
-
{
|
102 |
-
$loader = new ChainLoader();
|
103 |
-
$loader->addLoader(new ArrayLoader(['foo' => 'bar']));
|
104 |
-
|
105 |
-
$this->assertEquals('bar', $loader->getSourceContext('foo')->getCode());
|
106 |
-
}
|
107 |
-
|
108 |
-
public function testExists()
|
109 |
-
{
|
110 |
-
$loader1 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderWithExistsInterface');
|
111 |
-
$loader1->expects($this->once())->method('exists')->willReturn(false);
|
112 |
-
$loader1->expects($this->never())->method('getSourceContext');
|
113 |
-
|
114 |
-
// can be removed in 2.0
|
115 |
-
$loader2 = $this->createMock('Twig\Tests\Loader\ChainTestLoaderInterface');
|
116 |
-
//$loader2 = $this->createMock(['\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface']);
|
117 |
-
$loader2->expects($this->once())->method('getSourceContext')->willReturn(new Source('content', 'index'));
|
118 |
-
|
119 |
-
$loader = new ChainLoader();
|
120 |
-
$loader->addLoader($loader1);
|
121 |
-
$loader->addLoader($loader2);
|
122 |
-
|
123 |
-
$this->assertTrue($loader->exists('foo'));
|
124 |
-
}
|
125 |
-
}
|
126 |
-
|
127 |
-
interface ChainTestLoaderInterface extends LoaderInterface, SourceContextLoaderInterface
|
128 |
-
{
|
129 |
-
}
|
130 |
-
|
131 |
-
interface ChainTestLoaderWithExistsInterface extends LoaderInterface, ExistsLoaderInterface, SourceContextLoaderInterface
|
132 |
-
{
|
133 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/FilesystemTest.php
DELETED
@@ -1,247 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Loader;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Error\LoaderError;
|
16 |
-
use Twig\Loader\FilesystemLoader;
|
17 |
-
|
18 |
-
class FilesystemTest extends \PHPUnit\Framework\TestCase
|
19 |
-
{
|
20 |
-
public function testGetSourceContext()
|
21 |
-
{
|
22 |
-
$path = __DIR__.'/../Fixtures';
|
23 |
-
$loader = new FilesystemLoader([$path]);
|
24 |
-
$this->assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName());
|
25 |
-
$this->assertEquals(realpath($path.'/errors/index.html'), realpath($loader->getSourceContext('errors/index.html')->getPath()));
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @dataProvider getSecurityTests
|
30 |
-
*/
|
31 |
-
public function testSecurity($template)
|
32 |
-
{
|
33 |
-
$loader = new FilesystemLoader([__DIR__.'/../Fixtures']);
|
34 |
-
|
35 |
-
try {
|
36 |
-
$loader->getCacheKey($template);
|
37 |
-
$this->fail();
|
38 |
-
} catch (LoaderError $e) {
|
39 |
-
$this->assertStringNotContainsString('Unable to find template', $e->getMessage());
|
40 |
-
}
|
41 |
-
}
|
42 |
-
|
43 |
-
public function getSecurityTests()
|
44 |
-
{
|
45 |
-
return [
|
46 |
-
["AutoloaderTest\0.php"],
|
47 |
-
['..\\AutoloaderTest.php'],
|
48 |
-
['..\\\\\\AutoloaderTest.php'],
|
49 |
-
['../AutoloaderTest.php'],
|
50 |
-
['..////AutoloaderTest.php'],
|
51 |
-
['./../AutoloaderTest.php'],
|
52 |
-
['.\\..\\AutoloaderTest.php'],
|
53 |
-
['././././././../AutoloaderTest.php'],
|
54 |
-
['.\\./.\\./.\\./../AutoloaderTest.php'],
|
55 |
-
['foo/../../AutoloaderTest.php'],
|
56 |
-
['foo\\..\\..\\AutoloaderTest.php'],
|
57 |
-
['foo/../bar/../../AutoloaderTest.php'],
|
58 |
-
['foo/bar/../../../AutoloaderTest.php'],
|
59 |
-
['filters/../../AutoloaderTest.php'],
|
60 |
-
['filters//..//..//AutoloaderTest.php'],
|
61 |
-
['filters\\..\\..\\AutoloaderTest.php'],
|
62 |
-
['filters\\\\..\\\\..\\\\AutoloaderTest.php'],
|
63 |
-
['filters\\//../\\/\\..\\AutoloaderTest.php'],
|
64 |
-
['/../AutoloaderTest.php'],
|
65 |
-
];
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @dataProvider getBasePaths
|
70 |
-
*/
|
71 |
-
public function testPaths($basePath, $cacheKey, $rootPath)
|
72 |
-
{
|
73 |
-
$loader = new FilesystemLoader([$basePath.'/normal', $basePath.'/normal_bis'], $rootPath);
|
74 |
-
$loader->setPaths([$basePath.'/named', $basePath.'/named_bis'], 'named');
|
75 |
-
$loader->addPath($basePath.'/named_ter', 'named');
|
76 |
-
$loader->addPath($basePath.'/normal_ter');
|
77 |
-
$loader->prependPath($basePath.'/normal_final');
|
78 |
-
$loader->prependPath($basePath.'/named/../named_quater', 'named');
|
79 |
-
$loader->prependPath($basePath.'/named_final', 'named');
|
80 |
-
|
81 |
-
$this->assertEquals([
|
82 |
-
$basePath.'/normal_final',
|
83 |
-
$basePath.'/normal',
|
84 |
-
$basePath.'/normal_bis',
|
85 |
-
$basePath.'/normal_ter',
|
86 |
-
], $loader->getPaths());
|
87 |
-
$this->assertEquals([
|
88 |
-
$basePath.'/named_final',
|
89 |
-
$basePath.'/named/../named_quater',
|
90 |
-
$basePath.'/named',
|
91 |
-
$basePath.'/named_bis',
|
92 |
-
$basePath.'/named_ter',
|
93 |
-
], $loader->getPaths('named'));
|
94 |
-
|
95 |
-
// do not use realpath here as it would make the test unuseful
|
96 |
-
$this->assertEquals($cacheKey, str_replace('\\', '/', $loader->getCacheKey('@named/named_absolute.html')));
|
97 |
-
$this->assertEquals("path (final)\n", $loader->getSourceContext('index.html')->getCode());
|
98 |
-
$this->assertEquals("path (final)\n", $loader->getSourceContext('@__main__/index.html')->getCode());
|
99 |
-
$this->assertEquals("named path (final)\n", $loader->getSourceContext('@named/index.html')->getCode());
|
100 |
-
}
|
101 |
-
|
102 |
-
public function getBasePaths()
|
103 |
-
{
|
104 |
-
return [
|
105 |
-
[
|
106 |
-
__DIR__.'/Fixtures',
|
107 |
-
'tests/Loader/Fixtures/named_quater/named_absolute.html',
|
108 |
-
null,
|
109 |
-
],
|
110 |
-
[
|
111 |
-
__DIR__.'/Fixtures/../Fixtures',
|
112 |
-
'tests/Loader/Fixtures/named_quater/named_absolute.html',
|
113 |
-
null,
|
114 |
-
],
|
115 |
-
[
|
116 |
-
'tests/Loader/Fixtures',
|
117 |
-
'tests/Loader/Fixtures/named_quater/named_absolute.html',
|
118 |
-
getcwd(),
|
119 |
-
],
|
120 |
-
[
|
121 |
-
'Fixtures',
|
122 |
-
'Fixtures/named_quater/named_absolute.html',
|
123 |
-
getcwd().'/tests/Loader',
|
124 |
-
],
|
125 |
-
[
|
126 |
-
'Fixtures',
|
127 |
-
'Fixtures/named_quater/named_absolute.html',
|
128 |
-
getcwd().'/tests/../tests/Loader',
|
129 |
-
],
|
130 |
-
];
|
131 |
-
}
|
132 |
-
|
133 |
-
public function testEmptyConstructor()
|
134 |
-
{
|
135 |
-
$loader = new FilesystemLoader();
|
136 |
-
$this->assertEquals([], $loader->getPaths());
|
137 |
-
}
|
138 |
-
|
139 |
-
public function testGetNamespaces()
|
140 |
-
{
|
141 |
-
$loader = new FilesystemLoader(sys_get_temp_dir());
|
142 |
-
$this->assertEquals([FilesystemLoader::MAIN_NAMESPACE], $loader->getNamespaces());
|
143 |
-
|
144 |
-
$loader->addPath(sys_get_temp_dir(), 'named');
|
145 |
-
$this->assertEquals([FilesystemLoader::MAIN_NAMESPACE, 'named'], $loader->getNamespaces());
|
146 |
-
}
|
147 |
-
|
148 |
-
public function testFindTemplateExceptionNamespace()
|
149 |
-
{
|
150 |
-
$basePath = __DIR__.'/Fixtures';
|
151 |
-
|
152 |
-
$loader = new FilesystemLoader([$basePath.'/normal']);
|
153 |
-
$loader->addPath($basePath.'/named', 'named');
|
154 |
-
|
155 |
-
try {
|
156 |
-
$loader->getSourceContext('@named/nowhere.html');
|
157 |
-
} catch (\Exception $e) {
|
158 |
-
$this->assertInstanceOf('\Twig\Error\LoaderError', $e);
|
159 |
-
$this->assertStringContainsString('Unable to find template "@named/nowhere.html"', $e->getMessage());
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
public function testFindTemplateWithCache()
|
164 |
-
{
|
165 |
-
$basePath = __DIR__.'/Fixtures';
|
166 |
-
|
167 |
-
$loader = new FilesystemLoader([$basePath.'/normal']);
|
168 |
-
$loader->addPath($basePath.'/named', 'named');
|
169 |
-
|
170 |
-
// prime the cache for index.html in the named namespace
|
171 |
-
$namedSource = $loader->getSourceContext('@named/index.html')->getCode();
|
172 |
-
$this->assertEquals("named path\n", $namedSource);
|
173 |
-
|
174 |
-
// get index.html from the main namespace
|
175 |
-
$this->assertEquals("path\n", $loader->getSourceContext('index.html')->getCode());
|
176 |
-
}
|
177 |
-
|
178 |
-
public function testLoadTemplateAndRenderBlockWithCache()
|
179 |
-
{
|
180 |
-
$loader = new FilesystemLoader([]);
|
181 |
-
$loader->addPath(__DIR__.'/Fixtures/themes/theme2');
|
182 |
-
$loader->addPath(__DIR__.'/Fixtures/themes/theme1');
|
183 |
-
$loader->addPath(__DIR__.'/Fixtures/themes/theme1', 'default_theme');
|
184 |
-
|
185 |
-
$twig = new Environment($loader);
|
186 |
-
|
187 |
-
$template = $twig->load('blocks.html.twig');
|
188 |
-
$this->assertSame('block from theme 1', $template->renderBlock('b1', []));
|
189 |
-
|
190 |
-
$template = $twig->load('blocks.html.twig');
|
191 |
-
$this->assertSame('block from theme 2', $template->renderBlock('b2', []));
|
192 |
-
}
|
193 |
-
|
194 |
-
public function getArrayInheritanceTests()
|
195 |
-
{
|
196 |
-
return [
|
197 |
-
'valid array inheritance' => ['array_inheritance_valid_parent.html.twig'],
|
198 |
-
'array inheritance with null first template' => ['array_inheritance_null_parent.html.twig'],
|
199 |
-
'array inheritance with empty first template' => ['array_inheritance_empty_parent.html.twig'],
|
200 |
-
'array inheritance with non-existent first template' => ['array_inheritance_nonexistent_parent.html.twig'],
|
201 |
-
];
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @dataProvider getArrayInheritanceTests
|
206 |
-
*
|
207 |
-
* @param $templateName string Template name with array inheritance
|
208 |
-
*/
|
209 |
-
public function testArrayInheritance($templateName)
|
210 |
-
{
|
211 |
-
$loader = new FilesystemLoader([]);
|
212 |
-
$loader->addPath(__DIR__.'/Fixtures/inheritance');
|
213 |
-
|
214 |
-
$twig = new Environment($loader);
|
215 |
-
|
216 |
-
$template = $twig->load($templateName);
|
217 |
-
$this->assertSame('VALID Child', $template->renderBlock('body', []));
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* @requires PHP 5.3
|
222 |
-
*/
|
223 |
-
public function testLoadTemplateFromPhar()
|
224 |
-
{
|
225 |
-
$loader = new FilesystemLoader([]);
|
226 |
-
// phar-sample.phar was created with the following script:
|
227 |
-
// $f = new Phar('phar-test.phar');
|
228 |
-
// $f->addFromString('hello.twig', 'hello from phar');
|
229 |
-
$loader->addPath('phar://'.__DIR__.'/Fixtures/phar/phar-sample.phar');
|
230 |
-
$this->assertSame('hello from phar', $loader->getSourceContext('hello.twig')->getCode());
|
231 |
-
}
|
232 |
-
|
233 |
-
public function testTemplateExistsAlwaysReturnsBool()
|
234 |
-
{
|
235 |
-
$loader = new FilesystemLoader([]);
|
236 |
-
$this->assertFalse($loader->exists("foo\0.twig"));
|
237 |
-
$this->assertFalse($loader->exists('../foo.twig'));
|
238 |
-
$this->assertFalse($loader->exists('@foo'));
|
239 |
-
$this->assertFalse($loader->exists('foo'));
|
240 |
-
$this->assertFalse($loader->exists('@foo/bar.twig'));
|
241 |
-
|
242 |
-
$loader->addPath(__DIR__.'/Fixtures/normal');
|
243 |
-
$this->assertTrue($loader->exists('index.html'));
|
244 |
-
$loader->addPath(__DIR__.'/Fixtures/normal', 'foo');
|
245 |
-
$this->assertTrue($loader->exists('@foo/index.html'));
|
246 |
-
}
|
247 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_empty_parent.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% extends ['','parent.html.twig'] %}
|
2 |
-
|
3 |
-
{% block body %}{{ parent() }} Child{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_nonexistent_parent.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% extends ['nonexistent.html.twig','parent.html.twig'] %}
|
2 |
-
|
3 |
-
{% block body %}{{ parent() }} Child{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_null_parent.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% extends [null,'parent.html.twig'] %}
|
2 |
-
|
3 |
-
{% block body %}{{ parent() }} Child{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/array_inheritance_valid_parent.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% extends ['parent.html.twig','spare_parent.html.twig'] %}
|
2 |
-
|
3 |
-
{% block body %}{{ parent() }} Child{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/parent.html.twig
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{% block body %}VALID{% endblock %}
|
|
vendor/twig/twig/tests/Loader/Fixtures/inheritance/spare_parent.html.twig
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{% block body %}SPARE PARENT{% endblock %}
|
|
vendor/twig/twig/tests/Loader/Fixtures/named/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
named path
|
|
vendor/twig/twig/tests/Loader/Fixtures/named_bis/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
named path (bis)
|
|
vendor/twig/twig/tests/Loader/Fixtures/named_final/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
named path (final)
|
|
vendor/twig/twig/tests/Loader/Fixtures/named_quater/named_absolute.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
named path (quater)
|
|
vendor/twig/twig/tests/Loader/Fixtures/named_ter/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
named path (ter)
|
|
vendor/twig/twig/tests/Loader/Fixtures/normal/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
path
|
|
vendor/twig/twig/tests/Loader/Fixtures/normal_bis/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
path (bis)
|
|
vendor/twig/twig/tests/Loader/Fixtures/normal_final/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
path (final)
|
|
vendor/twig/twig/tests/Loader/Fixtures/normal_ter/index.html
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
path (ter)
|
|
vendor/twig/twig/tests/Loader/Fixtures/phar/phar-sample.phar
DELETED
Binary file
|
vendor/twig/twig/tests/Loader/Fixtures/themes/theme1/blocks.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% block b1 %}block from theme 1{% endblock %}
|
2 |
-
|
3 |
-
{% block b2 %}block from theme 1{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/Loader/Fixtures/themes/theme2/blocks.html.twig
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{% use '@default_theme/blocks.html.twig' %}
|
2 |
-
|
3 |
-
{% block b2 %}block from theme 2{% endblock %}
|
|
|
|
|
|
vendor/twig/twig/tests/NativeExtensionTest.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
namespace Twig\Tests;
|
6 |
-
|
7 |
-
/*
|
8 |
-
* This file is part of Twig.
|
9 |
-
*
|
10 |
-
* (c) Fabien Potencier
|
11 |
-
*
|
12 |
-
* For the full copyright and license information, please view the LICENSE
|
13 |
-
* file that was distributed with this source code.
|
14 |
-
*/
|
15 |
-
|
16 |
-
use Twig\Environment;
|
17 |
-
use Twig\Loader\ArrayLoader;
|
18 |
-
|
19 |
-
class NativeExtensionTest extends \PHPUnit\Framework\TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @requires PHP 5.3
|
23 |
-
*/
|
24 |
-
public function testGetProperties()
|
25 |
-
{
|
26 |
-
if (\PHP_VERSION_ID >= 70000) {
|
27 |
-
$this->markTestSkipped('Extension is not available on PHP 7+');
|
28 |
-
}
|
29 |
-
|
30 |
-
$twig = new Environment(new ArrayLoader(['index' => '{{ d1.date }}{{ d2.date }}']), [
|
31 |
-
'debug' => true,
|
32 |
-
'cache' => false,
|
33 |
-
'autoescape' => false,
|
34 |
-
]);
|
35 |
-
|
36 |
-
$d1 = new \DateTime();
|
37 |
-
$d2 = new \DateTime();
|
38 |
-
$output = $twig->render('index', compact('d1', 'd2'));
|
39 |
-
|
40 |
-
// If it fails, PHP will crash.
|
41 |
-
$this->assertEquals($output, $d1->date.$d2->date);
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/AutoEscapeTest.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\AutoEscapeNode;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
use Twig\Node\TextNode;
|
17 |
-
use Twig\Test\NodeTestCase;
|
18 |
-
|
19 |
-
class AutoEscapeTest extends NodeTestCase
|
20 |
-
{
|
21 |
-
public function testConstructor()
|
22 |
-
{
|
23 |
-
$body = new Node([new TextNode('foo', 1)]);
|
24 |
-
$node = new AutoEscapeNode(true, $body, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($body, $node->getNode('body'));
|
27 |
-
$this->assertTrue($node->getAttribute('value'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$body = new Node([new TextNode('foo', 1)]);
|
33 |
-
$node = new AutoEscapeNode(true, $body, 1);
|
34 |
-
|
35 |
-
return [
|
36 |
-
[$node, "// line 1\necho \"foo\";"],
|
37 |
-
];
|
38 |
-
}
|
39 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/BlockReferenceTest.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\BlockReferenceNode;
|
15 |
-
use Twig\Test\NodeTestCase;
|
16 |
-
|
17 |
-
class BlockReferenceTest extends NodeTestCase
|
18 |
-
{
|
19 |
-
public function testConstructor()
|
20 |
-
{
|
21 |
-
$node = new BlockReferenceNode('foo', 1);
|
22 |
-
|
23 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTests()
|
27 |
-
{
|
28 |
-
return [
|
29 |
-
[new BlockReferenceNode('foo', 1), <<<EOF
|
30 |
-
// line 1
|
31 |
-
\$this->displayBlock('foo', \$context, \$blocks);
|
32 |
-
EOF
|
33 |
-
],
|
34 |
-
];
|
35 |
-
}
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/BlockTest.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\BlockNode;
|
15 |
-
use Twig\Node\TextNode;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class BlockTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$body = new TextNode('foo', 1);
|
23 |
-
$node = new BlockNode('foo', $body, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($body, $node->getNode('body'));
|
26 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getTests()
|
30 |
-
{
|
31 |
-
$body = new TextNode('foo', 1);
|
32 |
-
$node = new BlockNode('foo', $body, 1);
|
33 |
-
|
34 |
-
return [
|
35 |
-
[$node, <<<EOF
|
36 |
-
// line 1
|
37 |
-
public function block_foo(\$context, array \$blocks = [])
|
38 |
-
{
|
39 |
-
echo "foo";
|
40 |
-
}
|
41 |
-
EOF
|
42 |
-
],
|
43 |
-
];
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/DeprecatedTest.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\DeprecatedNode;
|
16 |
-
use Twig\Node\Expression\ConstantExpression;
|
17 |
-
use Twig\Node\Expression\FunctionExpression;
|
18 |
-
use Twig\Node\IfNode;
|
19 |
-
use Twig\Node\Node;
|
20 |
-
use Twig\Test\NodeTestCase;
|
21 |
-
use Twig\TwigFunction;
|
22 |
-
|
23 |
-
class DeprecatedTest extends NodeTestCase
|
24 |
-
{
|
25 |
-
public function testConstructor()
|
26 |
-
{
|
27 |
-
$expr = new ConstantExpression('foo', 1);
|
28 |
-
$node = new DeprecatedNode($expr, 1);
|
29 |
-
|
30 |
-
$this->assertEquals($expr, $node->getNode('expr'));
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getTests()
|
34 |
-
{
|
35 |
-
$tests = [];
|
36 |
-
|
37 |
-
$expr = new ConstantExpression('This section is deprecated', 1);
|
38 |
-
$node = new DeprecatedNode($expr, 1, 'deprecated');
|
39 |
-
$node->setTemplateName('foo.twig');
|
40 |
-
|
41 |
-
$tests[] = [$node, <<<EOF
|
42 |
-
// line 1
|
43 |
-
@trigger_error("This section is deprecated"." (\"foo.twig\" at line 1).", E_USER_DEPRECATED);
|
44 |
-
EOF
|
45 |
-
];
|
46 |
-
|
47 |
-
$t = new Node([
|
48 |
-
new ConstantExpression(true, 1),
|
49 |
-
new DeprecatedNode($expr, 2, 'deprecated'),
|
50 |
-
], [], 1);
|
51 |
-
$node = new IfNode($t, null, 1);
|
52 |
-
$node->setTemplateName('foo.twig');
|
53 |
-
|
54 |
-
$tests[] = [$node, <<<EOF
|
55 |
-
// line 1
|
56 |
-
if (true) {
|
57 |
-
// line 2
|
58 |
-
@trigger_error("This section is deprecated"." (\"foo.twig\" at line 2).", E_USER_DEPRECATED);
|
59 |
-
}
|
60 |
-
EOF
|
61 |
-
];
|
62 |
-
|
63 |
-
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
64 |
-
$environment->addFunction(new TwigFunction('foo', 'foo', []));
|
65 |
-
|
66 |
-
$expr = new FunctionExpression('foo', new Node(), 1);
|
67 |
-
$node = new DeprecatedNode($expr, 1, 'deprecated');
|
68 |
-
$node->setTemplateName('foo.twig');
|
69 |
-
|
70 |
-
$compiler = $this->getCompiler($environment);
|
71 |
-
$varName = $compiler->getVarName();
|
72 |
-
|
73 |
-
$tests[] = [$node, <<<EOF
|
74 |
-
// line 1
|
75 |
-
\$$varName = foo();
|
76 |
-
@trigger_error(\$$varName." (\"foo.twig\" at line 1).", E_USER_DEPRECATED);
|
77 |
-
EOF
|
78 |
-
, $environment];
|
79 |
-
|
80 |
-
return $tests;
|
81 |
-
}
|
82 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/DoTest.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\DoNode;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class DoTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr = new ConstantExpression('foo', 1);
|
23 |
-
$node = new DoNode($expr, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($expr, $node->getNode('expr'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$tests = [];
|
31 |
-
|
32 |
-
$expr = new ConstantExpression('foo', 1);
|
33 |
-
$node = new DoNode($expr, 1);
|
34 |
-
$tests[] = [$node, "// line 1\n\"foo\";"];
|
35 |
-
|
36 |
-
return $tests;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/ArrayTest.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ArrayExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class ArrayTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$elements = [new ConstantExpression('foo', 1), $foo = new ConstantExpression('bar', 1)];
|
23 |
-
$node = new ArrayExpression($elements, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($foo, $node->getNode(1));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$elements = [
|
31 |
-
new ConstantExpression('foo', 1),
|
32 |
-
new ConstantExpression('bar', 1),
|
33 |
-
|
34 |
-
new ConstantExpression('bar', 1),
|
35 |
-
new ConstantExpression('foo', 1),
|
36 |
-
];
|
37 |
-
$node = new ArrayExpression($elements, 1);
|
38 |
-
|
39 |
-
return [
|
40 |
-
[$node, '["foo" => "bar", "bar" => "foo"]'],
|
41 |
-
];
|
42 |
-
}
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/AssignNameTest.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\AssignNameExpression;
|
15 |
-
use Twig\Test\NodeTestCase;
|
16 |
-
|
17 |
-
class AssignNameTest extends NodeTestCase
|
18 |
-
{
|
19 |
-
public function testConstructor()
|
20 |
-
{
|
21 |
-
$node = new AssignNameExpression('foo', 1);
|
22 |
-
|
23 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTests()
|
27 |
-
{
|
28 |
-
$node = new AssignNameExpression('foo', 1);
|
29 |
-
|
30 |
-
return [
|
31 |
-
[$node, '$context["foo"]'],
|
32 |
-
];
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/AddTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\AddBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class AddTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new AddBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new AddBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 + 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/AndTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\AndBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class AndTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new AndBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new AndBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 && 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/ConcatTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\ConcatBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class ConcatTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new ConcatBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new ConcatBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 . 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/DivTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\DivBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class DivTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new DivBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new DivBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 / 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/FloorDivTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\FloorDivBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class FloorDivTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new FloorDivBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new FloorDivBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(int) floor((1 / 2))'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/ModTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\ModBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class ModTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new ModBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new ModBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 % 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/MulTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\MulBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class MulTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new MulBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new MulBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 * 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/OrTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\OrBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class OrTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new OrBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new OrBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 || 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Binary/SubTest.php
DELETED
@@ -1,40 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Binary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\Binary\SubBinary;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class SubTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$left = new ConstantExpression(1, 1);
|
23 |
-
$right = new ConstantExpression(2, 1);
|
24 |
-
$node = new SubBinary($left, $right, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($left, $node->getNode('left'));
|
27 |
-
$this->assertEquals($right, $node->getNode('right'));
|
28 |
-
}
|
29 |
-
|
30 |
-
public function getTests()
|
31 |
-
{
|
32 |
-
$left = new ConstantExpression(1, 1);
|
33 |
-
$right = new ConstantExpression(2, 1);
|
34 |
-
$node = new SubBinary($left, $right, 1);
|
35 |
-
|
36 |
-
return [
|
37 |
-
[$node, '(1 - 2)'],
|
38 |
-
];
|
39 |
-
}
|
40 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/CallTest.php
DELETED
@@ -1,139 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\CallExpression;
|
15 |
-
|
16 |
-
class CallTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
public function testGetArguments()
|
19 |
-
{
|
20 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']);
|
21 |
-
$this->assertEquals(['U', null], $node->getArguments('date', ['format' => 'U', 'timestamp' => null]));
|
22 |
-
}
|
23 |
-
|
24 |
-
public function testGetArgumentsWhenPositionalArgumentsAfterNamedArguments()
|
25 |
-
{
|
26 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
27 |
-
$this->expectExceptionMessage('Positional arguments cannot be used after named arguments for function "date".');
|
28 |
-
|
29 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']);
|
30 |
-
$node->getArguments('date', ['timestamp' => 123456, 'Y-m-d']);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function testGetArgumentsWhenArgumentIsDefinedTwice()
|
34 |
-
{
|
35 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
36 |
-
$this->expectExceptionMessage('Argument "format" is defined twice for function "date".');
|
37 |
-
|
38 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']);
|
39 |
-
$node->getArguments('date', ['Y-m-d', 'format' => 'U']);
|
40 |
-
}
|
41 |
-
|
42 |
-
public function testGetArgumentsWithWrongNamedArgumentName()
|
43 |
-
{
|
44 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
45 |
-
$this->expectExceptionMessage('Unknown argument "unknown" for function "date(format, timestamp)".');
|
46 |
-
|
47 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']);
|
48 |
-
$node->getArguments('date', ['Y-m-d', 'timestamp' => null, 'unknown' => '']);
|
49 |
-
}
|
50 |
-
|
51 |
-
public function testGetArgumentsWithWrongNamedArgumentNames()
|
52 |
-
{
|
53 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
54 |
-
$this->expectExceptionMessage('Unknown arguments "unknown1", "unknown2" for function "date(format, timestamp)".');
|
55 |
-
|
56 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'date']);
|
57 |
-
$node->getArguments('date', ['Y-m-d', 'timestamp' => null, 'unknown1' => '', 'unknown2' => '']);
|
58 |
-
}
|
59 |
-
|
60 |
-
public function testResolveArgumentsWithMissingValueForOptionalArgument()
|
61 |
-
{
|
62 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
63 |
-
$this->expectExceptionMessage('Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length".');
|
64 |
-
|
65 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'substr_compare']);
|
66 |
-
$node->getArguments('substr_compare', ['abcd', 'bc', 'offset' => 1, 'case_sensitivity' => true]);
|
67 |
-
}
|
68 |
-
|
69 |
-
public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction()
|
70 |
-
{
|
71 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'custom_function']);
|
72 |
-
|
73 |
-
$this->assertEquals(['arg1'], $node->getArguments([$this, 'customFunction'], ['arg1' => 'arg1']));
|
74 |
-
}
|
75 |
-
|
76 |
-
public function testGetArgumentsForStaticMethod()
|
77 |
-
{
|
78 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'custom_static_function']);
|
79 |
-
$this->assertEquals(['arg1'], $node->getArguments(__CLASS__.'::customStaticFunction', ['arg1' => 'arg1']));
|
80 |
-
}
|
81 |
-
|
82 |
-
public function testResolveArgumentsWithMissingParameterForArbitraryArguments()
|
83 |
-
{
|
84 |
-
$this->expectException('\LogicException');
|
85 |
-
$this->expectExceptionMessage('The last parameter of "Twig\\Tests\\Node\\Expression\\CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = []".');
|
86 |
-
|
87 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]);
|
88 |
-
$node->getArguments([$this, 'customFunctionWithArbitraryArguments'], []);
|
89 |
-
}
|
90 |
-
|
91 |
-
public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = [])
|
92 |
-
{
|
93 |
-
}
|
94 |
-
|
95 |
-
public function customFunction($arg1, $arg2 = 'default', $arg3 = [])
|
96 |
-
{
|
97 |
-
}
|
98 |
-
|
99 |
-
public function customFunctionWithArbitraryArguments()
|
100 |
-
{
|
101 |
-
}
|
102 |
-
|
103 |
-
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction()
|
104 |
-
{
|
105 |
-
$this->expectException('\LogicException');
|
106 |
-
$this->expectExceptionMessageRegExp('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\custom_Twig_Tests_Node_Expression_CallTest_function" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#');
|
107 |
-
|
108 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]);
|
109 |
-
$node->getArguments('Twig\Tests\Node\Expression\custom_Twig_Tests_Node_Expression_CallTest_function', []);
|
110 |
-
}
|
111 |
-
|
112 |
-
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject()
|
113 |
-
{
|
114 |
-
$this->expectException('\LogicException');
|
115 |
-
$this->expectExceptionMessageRegExp('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\CallableTestClass\\:\\:__invoke" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#');
|
116 |
-
|
117 |
-
$node = new Node_Expression_Call([], ['type' => 'function', 'name' => 'foo', 'is_variadic' => true]);
|
118 |
-
$node->getArguments(new CallableTestClass(), []);
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
class Node_Expression_Call extends CallExpression
|
123 |
-
{
|
124 |
-
public function getArguments($callable, $arguments)
|
125 |
-
{
|
126 |
-
return parent::getArguments($callable, $arguments);
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
class CallableTestClass
|
131 |
-
{
|
132 |
-
public function __invoke($required)
|
133 |
-
{
|
134 |
-
}
|
135 |
-
}
|
136 |
-
|
137 |
-
function custom_Twig_Tests_Node_Expression_CallTest_function($required)
|
138 |
-
{
|
139 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/ConditionalTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConditionalExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class ConditionalTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr1 = new ConstantExpression(1, 1);
|
23 |
-
$expr2 = new ConstantExpression(2, 1);
|
24 |
-
$expr3 = new ConstantExpression(3, 1);
|
25 |
-
$node = new ConditionalExpression($expr1, $expr2, $expr3, 1);
|
26 |
-
|
27 |
-
$this->assertEquals($expr1, $node->getNode('expr1'));
|
28 |
-
$this->assertEquals($expr2, $node->getNode('expr2'));
|
29 |
-
$this->assertEquals($expr3, $node->getNode('expr3'));
|
30 |
-
}
|
31 |
-
|
32 |
-
public function getTests()
|
33 |
-
{
|
34 |
-
$tests = [];
|
35 |
-
|
36 |
-
$expr1 = new ConstantExpression(1, 1);
|
37 |
-
$expr2 = new ConstantExpression(2, 1);
|
38 |
-
$expr3 = new ConstantExpression(3, 1);
|
39 |
-
$node = new ConditionalExpression($expr1, $expr2, $expr3, 1);
|
40 |
-
$tests[] = [$node, '((1) ? (2) : (3))'];
|
41 |
-
|
42 |
-
return $tests;
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/ConstantTest.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Test\NodeTestCase;
|
16 |
-
|
17 |
-
class ConstantTest extends NodeTestCase
|
18 |
-
{
|
19 |
-
public function testConstructor()
|
20 |
-
{
|
21 |
-
$node = new ConstantExpression('foo', 1);
|
22 |
-
|
23 |
-
$this->assertEquals('foo', $node->getAttribute('value'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTests()
|
27 |
-
{
|
28 |
-
$tests = [];
|
29 |
-
|
30 |
-
$node = new ConstantExpression('foo', 1);
|
31 |
-
$tests[] = [$node, '"foo"'];
|
32 |
-
|
33 |
-
return $tests;
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/FilterTest.php
DELETED
@@ -1,161 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\FilterExpression;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\Test\NodeTestCase;
|
19 |
-
use Twig\TwigFilter;
|
20 |
-
|
21 |
-
class FilterTest extends NodeTestCase
|
22 |
-
{
|
23 |
-
public function testConstructor()
|
24 |
-
{
|
25 |
-
$expr = new ConstantExpression('foo', 1);
|
26 |
-
$name = new ConstantExpression('upper', 1);
|
27 |
-
$args = new Node();
|
28 |
-
$node = new FilterExpression($expr, $name, $args, 1);
|
29 |
-
|
30 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
31 |
-
$this->assertEquals($name, $node->getNode('filter'));
|
32 |
-
$this->assertEquals($args, $node->getNode('arguments'));
|
33 |
-
}
|
34 |
-
|
35 |
-
public function getTests()
|
36 |
-
{
|
37 |
-
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
38 |
-
$environment->addFilter(new TwigFilter('bar', 'bar', ['needs_environment' => true]));
|
39 |
-
$environment->addFilter(new TwigFilter('barbar', 'Twig\Tests\Node\Expression\twig_tests_filter_barbar', ['needs_context' => true, 'is_variadic' => true]));
|
40 |
-
|
41 |
-
$tests = [];
|
42 |
-
|
43 |
-
$expr = new ConstantExpression('foo', 1);
|
44 |
-
$node = $this->createFilter($expr, 'upper');
|
45 |
-
$node = $this->createFilter($node, 'number_format', [new ConstantExpression(2, 1), new ConstantExpression('.', 1), new ConstantExpression(',', 1)]);
|
46 |
-
|
47 |
-
if (\function_exists('mb_get_info')) {
|
48 |
-
$tests[] = [$node, 'twig_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")'];
|
49 |
-
} else {
|
50 |
-
$tests[] = [$node, 'twig_number_format_filter($this->env, strtoupper("foo"), 2, ".", ",")'];
|
51 |
-
}
|
52 |
-
|
53 |
-
// named arguments
|
54 |
-
$date = new ConstantExpression(0, 1);
|
55 |
-
$node = $this->createFilter($date, 'date', [
|
56 |
-
'timezone' => new ConstantExpression('America/Chicago', 1),
|
57 |
-
'format' => new ConstantExpression('d/m/Y H:i:s P', 1),
|
58 |
-
]);
|
59 |
-
$tests[] = [$node, 'twig_date_format_filter($this->env, 0, "d/m/Y H:i:s P", "America/Chicago")'];
|
60 |
-
|
61 |
-
// skip an optional argument
|
62 |
-
$date = new ConstantExpression(0, 1);
|
63 |
-
$node = $this->createFilter($date, 'date', [
|
64 |
-
'timezone' => new ConstantExpression('America/Chicago', 1),
|
65 |
-
]);
|
66 |
-
$tests[] = [$node, 'twig_date_format_filter($this->env, 0, null, "America/Chicago")'];
|
67 |
-
|
68 |
-
// underscores vs camelCase for named arguments
|
69 |
-
$string = new ConstantExpression('abc', 1);
|
70 |
-
$node = $this->createFilter($string, 'reverse', [
|
71 |
-
'preserve_keys' => new ConstantExpression(true, 1),
|
72 |
-
]);
|
73 |
-
$tests[] = [$node, 'twig_reverse_filter($this->env, "abc", true)'];
|
74 |
-
$node = $this->createFilter($string, 'reverse', [
|
75 |
-
'preserveKeys' => new ConstantExpression(true, 1),
|
76 |
-
]);
|
77 |
-
$tests[] = [$node, 'twig_reverse_filter($this->env, "abc", true)'];
|
78 |
-
|
79 |
-
// filter as an anonymous function
|
80 |
-
if (\PHP_VERSION_ID >= 50300) {
|
81 |
-
$node = $this->createFilter(new ConstantExpression('foo', 1), 'anonymous');
|
82 |
-
$tests[] = [$node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), ["foo"])'];
|
83 |
-
}
|
84 |
-
|
85 |
-
// needs environment
|
86 |
-
$node = $this->createFilter($string, 'bar');
|
87 |
-
$tests[] = [$node, 'bar($this->env, "abc")', $environment];
|
88 |
-
|
89 |
-
$node = $this->createFilter($string, 'bar', [new ConstantExpression('bar', 1)]);
|
90 |
-
$tests[] = [$node, 'bar($this->env, "abc", "bar")', $environment];
|
91 |
-
|
92 |
-
// arbitrary named arguments
|
93 |
-
$node = $this->createFilter($string, 'barbar');
|
94 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc")', $environment];
|
95 |
-
|
96 |
-
$node = $this->createFilter($string, 'barbar', ['foo' => new ConstantExpression('bar', 1)]);
|
97 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc", null, null, ["foo" => "bar"])', $environment];
|
98 |
-
|
99 |
-
$node = $this->createFilter($string, 'barbar', ['arg2' => new ConstantExpression('bar', 1)]);
|
100 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc", null, "bar")', $environment];
|
101 |
-
|
102 |
-
$node = $this->createFilter($string, 'barbar', [
|
103 |
-
new ConstantExpression('1', 1),
|
104 |
-
new ConstantExpression('2', 1),
|
105 |
-
new ConstantExpression('3', 1),
|
106 |
-
'foo' => new ConstantExpression('bar', 1),
|
107 |
-
]);
|
108 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_filter_barbar($context, "abc", "1", "2", [0 => "3", "foo" => "bar"])', $environment];
|
109 |
-
|
110 |
-
return $tests;
|
111 |
-
}
|
112 |
-
|
113 |
-
public function testCompileWithWrongNamedArgumentName()
|
114 |
-
{
|
115 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
116 |
-
$this->expectExceptionMessage('Unknown argument "foobar" for filter "date(format, timezone)" at line 1.');
|
117 |
-
|
118 |
-
$date = new ConstantExpression(0, 1);
|
119 |
-
$node = $this->createFilter($date, 'date', [
|
120 |
-
'foobar' => new ConstantExpression('America/Chicago', 1),
|
121 |
-
]);
|
122 |
-
|
123 |
-
$compiler = $this->getCompiler();
|
124 |
-
$compiler->compile($node);
|
125 |
-
}
|
126 |
-
|
127 |
-
public function testCompileWithMissingNamedArgument()
|
128 |
-
{
|
129 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
130 |
-
$this->expectExceptionMessage('Value for argument "from" is required for filter "replace" at line 1.');
|
131 |
-
|
132 |
-
$value = new ConstantExpression(0, 1);
|
133 |
-
$node = $this->createFilter($value, 'replace', [
|
134 |
-
'to' => new ConstantExpression('foo', 1),
|
135 |
-
]);
|
136 |
-
|
137 |
-
$compiler = $this->getCompiler();
|
138 |
-
$compiler->compile($node);
|
139 |
-
}
|
140 |
-
|
141 |
-
protected function createFilter($node, $name, array $arguments = [])
|
142 |
-
{
|
143 |
-
$name = new ConstantExpression($name, 1);
|
144 |
-
$arguments = new Node($arguments);
|
145 |
-
|
146 |
-
return new FilterExpression($node, $name, $arguments, 1);
|
147 |
-
}
|
148 |
-
|
149 |
-
protected function getEnvironment()
|
150 |
-
{
|
151 |
-
if (\PHP_VERSION_ID >= 50300) {
|
152 |
-
return include 'PHP53/FilterInclude.php';
|
153 |
-
}
|
154 |
-
|
155 |
-
return parent::getEnvironment();
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
function twig_tests_filter_barbar($context, $string, $arg1 = null, $arg2 = null, array $args = [])
|
160 |
-
{
|
161 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/FunctionTest.php
DELETED
@@ -1,119 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\FunctionExpression;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\Test\NodeTestCase;
|
19 |
-
use Twig\TwigFunction;
|
20 |
-
|
21 |
-
class FunctionTest extends NodeTestCase
|
22 |
-
{
|
23 |
-
public function testConstructor()
|
24 |
-
{
|
25 |
-
$name = 'function';
|
26 |
-
$args = new Node();
|
27 |
-
$node = new FunctionExpression($name, $args, 1);
|
28 |
-
|
29 |
-
$this->assertEquals($name, $node->getAttribute('name'));
|
30 |
-
$this->assertEquals($args, $node->getNode('arguments'));
|
31 |
-
}
|
32 |
-
|
33 |
-
public function getTests()
|
34 |
-
{
|
35 |
-
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
36 |
-
$environment->addFunction(new TwigFunction('foo', 'foo', []));
|
37 |
-
$environment->addFunction(new TwigFunction('bar', 'bar', ['needs_environment' => true]));
|
38 |
-
$environment->addFunction(new TwigFunction('foofoo', 'foofoo', ['needs_context' => true]));
|
39 |
-
$environment->addFunction(new TwigFunction('foobar', 'foobar', ['needs_environment' => true, 'needs_context' => true]));
|
40 |
-
$environment->addFunction(new TwigFunction('barbar', 'Twig\Tests\Node\Expression\twig_tests_function_barbar', ['is_variadic' => true]));
|
41 |
-
|
42 |
-
$tests = [];
|
43 |
-
|
44 |
-
$node = $this->createFunction('foo');
|
45 |
-
$tests[] = [$node, 'foo()', $environment];
|
46 |
-
|
47 |
-
$node = $this->createFunction('foo', [new ConstantExpression('bar', 1), new ConstantExpression('foobar', 1)]);
|
48 |
-
$tests[] = [$node, 'foo("bar", "foobar")', $environment];
|
49 |
-
|
50 |
-
$node = $this->createFunction('bar');
|
51 |
-
$tests[] = [$node, 'bar($this->env)', $environment];
|
52 |
-
|
53 |
-
$node = $this->createFunction('bar', [new ConstantExpression('bar', 1)]);
|
54 |
-
$tests[] = [$node, 'bar($this->env, "bar")', $environment];
|
55 |
-
|
56 |
-
$node = $this->createFunction('foofoo');
|
57 |
-
$tests[] = [$node, 'foofoo($context)', $environment];
|
58 |
-
|
59 |
-
$node = $this->createFunction('foofoo', [new ConstantExpression('bar', 1)]);
|
60 |
-
$tests[] = [$node, 'foofoo($context, "bar")', $environment];
|
61 |
-
|
62 |
-
$node = $this->createFunction('foobar');
|
63 |
-
$tests[] = [$node, 'foobar($this->env, $context)', $environment];
|
64 |
-
|
65 |
-
$node = $this->createFunction('foobar', [new ConstantExpression('bar', 1)]);
|
66 |
-
$tests[] = [$node, 'foobar($this->env, $context, "bar")', $environment];
|
67 |
-
|
68 |
-
// named arguments
|
69 |
-
$node = $this->createFunction('date', [
|
70 |
-
'timezone' => new ConstantExpression('America/Chicago', 1),
|
71 |
-
'date' => new ConstantExpression(0, 1),
|
72 |
-
]);
|
73 |
-
$tests[] = [$node, 'twig_date_converter($this->env, 0, "America/Chicago")'];
|
74 |
-
|
75 |
-
// arbitrary named arguments
|
76 |
-
$node = $this->createFunction('barbar');
|
77 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar()', $environment];
|
78 |
-
|
79 |
-
$node = $this->createFunction('barbar', ['foo' => new ConstantExpression('bar', 1)]);
|
80 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar(null, null, ["foo" => "bar"])', $environment];
|
81 |
-
|
82 |
-
$node = $this->createFunction('barbar', ['arg2' => new ConstantExpression('bar', 1)]);
|
83 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar(null, "bar")', $environment];
|
84 |
-
|
85 |
-
$node = $this->createFunction('barbar', [
|
86 |
-
new ConstantExpression('1', 1),
|
87 |
-
new ConstantExpression('2', 1),
|
88 |
-
new ConstantExpression('3', 1),
|
89 |
-
'foo' => new ConstantExpression('bar', 1),
|
90 |
-
]);
|
91 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_function_barbar("1", "2", [0 => "3", "foo" => "bar"])', $environment];
|
92 |
-
|
93 |
-
// function as an anonymous function
|
94 |
-
if (\PHP_VERSION_ID >= 50300) {
|
95 |
-
$node = $this->createFunction('anonymous', [new ConstantExpression('foo', 1)]);
|
96 |
-
$tests[] = [$node, 'call_user_func_array($this->env->getFunction(\'anonymous\')->getCallable(), ["foo"])'];
|
97 |
-
}
|
98 |
-
|
99 |
-
return $tests;
|
100 |
-
}
|
101 |
-
|
102 |
-
protected function createFunction($name, array $arguments = [])
|
103 |
-
{
|
104 |
-
return new FunctionExpression($name, new Node($arguments), 1);
|
105 |
-
}
|
106 |
-
|
107 |
-
protected function getEnvironment()
|
108 |
-
{
|
109 |
-
if (\PHP_VERSION_ID >= 50300) {
|
110 |
-
return include 'PHP53/FunctionInclude.php';
|
111 |
-
}
|
112 |
-
|
113 |
-
return parent::getEnvironment();
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
function twig_tests_function_barbar($arg1 = null, $arg2 = null, array $args = [])
|
118 |
-
{
|
119 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/GetAttrTest.php
DELETED
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ArrayExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\GetAttrExpression;
|
17 |
-
use Twig\Node\Expression\NameExpression;
|
18 |
-
use Twig\Template;
|
19 |
-
use Twig\Test\NodeTestCase;
|
20 |
-
|
21 |
-
class GetAttrTest extends NodeTestCase
|
22 |
-
{
|
23 |
-
public function testConstructor()
|
24 |
-
{
|
25 |
-
$expr = new NameExpression('foo', 1);
|
26 |
-
$attr = new ConstantExpression('bar', 1);
|
27 |
-
$args = new ArrayExpression([], 1);
|
28 |
-
$args->addElement(new NameExpression('foo', 1));
|
29 |
-
$args->addElement(new ConstantExpression('bar', 1));
|
30 |
-
$node = new GetAttrExpression($expr, $attr, $args, Template::ARRAY_CALL, 1);
|
31 |
-
|
32 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
33 |
-
$this->assertEquals($attr, $node->getNode('attribute'));
|
34 |
-
$this->assertEquals($args, $node->getNode('arguments'));
|
35 |
-
$this->assertEquals(Template::ARRAY_CALL, $node->getAttribute('type'));
|
36 |
-
}
|
37 |
-
|
38 |
-
public function getTests()
|
39 |
-
{
|
40 |
-
$tests = [];
|
41 |
-
|
42 |
-
$expr = new NameExpression('foo', 1);
|
43 |
-
$attr = new ConstantExpression('bar', 1);
|
44 |
-
$args = new ArrayExpression([], 1);
|
45 |
-
$node = new GetAttrExpression($expr, $attr, $args, Template::ANY_CALL, 1);
|
46 |
-
$tests[] = [$node, sprintf('%s%s, "bar", [])', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1))];
|
47 |
-
|
48 |
-
$node = new GetAttrExpression($expr, $attr, $args, Template::ARRAY_CALL, 1);
|
49 |
-
$tests[] = [$node, sprintf('%s%s, "bar", [], "array")', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1))];
|
50 |
-
|
51 |
-
$args = new ArrayExpression([], 1);
|
52 |
-
$args->addElement(new NameExpression('foo', 1));
|
53 |
-
$args->addElement(new ConstantExpression('bar', 1));
|
54 |
-
$node = new GetAttrExpression($expr, $attr, $args, Template::METHOD_CALL, 1);
|
55 |
-
$tests[] = [$node, sprintf('%s%s, "bar", [0 => %s, 1 => "bar"], "method")', $this->getAttributeGetter(), $this->getVariableGetter('foo', 1), $this->getVariableGetter('foo'))];
|
56 |
-
|
57 |
-
return $tests;
|
58 |
-
}
|
59 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/NameTest.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class NameTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$node = new NameExpression('foo', 1);
|
23 |
-
|
24 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
25 |
-
}
|
26 |
-
|
27 |
-
public function getTests()
|
28 |
-
{
|
29 |
-
$node = new NameExpression('foo', 1);
|
30 |
-
$context = new NameExpression('_context', 1);
|
31 |
-
|
32 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]);
|
33 |
-
$env1 = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => false]);
|
34 |
-
|
35 |
-
if (\PHP_VERSION_ID >= 70000) {
|
36 |
-
$output = '($context["foo"] ?? $this->getContext($context, "foo"))';
|
37 |
-
} elseif (\PHP_VERSION_ID >= 50400) {
|
38 |
-
$output = '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))';
|
39 |
-
} else {
|
40 |
-
$output = '$this->getContext($context, "foo")';
|
41 |
-
}
|
42 |
-
|
43 |
-
return [
|
44 |
-
[$node, "// line 1\n".$output, $env],
|
45 |
-
[$node, $this->getVariableGetter('foo', 1), $env1],
|
46 |
-
[$context, "// line 1\n\$context"],
|
47 |
-
];
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/NullCoalesceTest.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
use Twig\Node\Expression\NullCoalesceExpression;
|
17 |
-
use Twig\Test\NodeTestCase;
|
18 |
-
|
19 |
-
class NullCoalesceTest extends NodeTestCase
|
20 |
-
{
|
21 |
-
public function getTests()
|
22 |
-
{
|
23 |
-
$tests = [];
|
24 |
-
|
25 |
-
$left = new NameExpression('foo', 1);
|
26 |
-
$right = new ConstantExpression(2, 1);
|
27 |
-
$node = new NullCoalesceExpression($left, $right, 1);
|
28 |
-
if (\PHP_VERSION_ID >= 70000) {
|
29 |
-
$tests[] = [$node, "((// line 1\n\$context[\"foo\"]) ?? (2))"];
|
30 |
-
} elseif (\PHP_VERSION_ID >= 50400) {
|
31 |
-
$tests[] = [$node, "(((// line 1\n(isset(\$context[\"foo\"]) || array_key_exists(\"foo\", \$context)) && !(null === (isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)))) ? ((isset(\$context[\"foo\"]) ? \$context[\"foo\"] : null)) : (2))"];
|
32 |
-
} else {
|
33 |
-
$tests[] = [$node, "(((// line 1\n(isset(\$context[\"foo\"]) || array_key_exists(\"foo\", \$context)) && !(null === \$this->getContext(\$context, \"foo\")))) ? (\$this->getContext(\$context, \"foo\")) : (2))"];
|
34 |
-
}
|
35 |
-
|
36 |
-
return $tests;
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/PHP53/FilterInclude.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\PHP53;
|
4 |
-
|
5 |
-
$env = new \Twig\Environment(new \Twig\Loader\ArrayLoader([]));
|
6 |
-
$env->addFilter(new \Twig\TwigFilter('anonymous', function () {}));
|
7 |
-
|
8 |
-
return $env;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/PHP53/FunctionInclude.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\PHP53;
|
4 |
-
|
5 |
-
$env = new \Twig\Environment(new \Twig\Loader\ArrayLoader([]));
|
6 |
-
$env->addFunction(new \Twig\TwigFunction('anonymous', function () {}));
|
7 |
-
|
8 |
-
return $env;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/PHP53/TestInclude.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\PHP53;
|
4 |
-
|
5 |
-
$env = new \Twig\Environment(new \Twig\Loader\ArrayLoader([]));
|
6 |
-
$env->addTest(new \Twig\TwigTest('anonymous', function () {}));
|
7 |
-
|
8 |
-
return $env;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/ParentTest.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ParentExpression;
|
15 |
-
use Twig\Test\NodeTestCase;
|
16 |
-
|
17 |
-
class ParentTest extends NodeTestCase
|
18 |
-
{
|
19 |
-
public function testConstructor()
|
20 |
-
{
|
21 |
-
$node = new ParentExpression('foo', 1);
|
22 |
-
|
23 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTests()
|
27 |
-
{
|
28 |
-
$tests = [];
|
29 |
-
$tests[] = [new ParentExpression('foo', 1), '$this->renderParentBlock("foo", $context, $blocks)'];
|
30 |
-
|
31 |
-
return $tests;
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/TestTest.php
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\Test\NullTest;
|
17 |
-
use Twig\Node\Expression\TestExpression;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
use Twig\Test\NodeTestCase;
|
20 |
-
use Twig\TwigTest;
|
21 |
-
|
22 |
-
class TestTest extends NodeTestCase
|
23 |
-
{
|
24 |
-
public function testConstructor()
|
25 |
-
{
|
26 |
-
$expr = new ConstantExpression('foo', 1);
|
27 |
-
$name = new ConstantExpression('null', 1);
|
28 |
-
$args = new Node();
|
29 |
-
$node = new TestExpression($expr, $name, $args, 1);
|
30 |
-
|
31 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
32 |
-
$this->assertEquals($args, $node->getNode('arguments'));
|
33 |
-
$this->assertEquals($name, $node->getAttribute('name'));
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getTests()
|
37 |
-
{
|
38 |
-
$environment = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
39 |
-
$environment->addTest(new TwigTest('barbar', 'Twig\Tests\Node\Expression\twig_tests_test_barbar', ['is_variadic' => true, 'need_context' => true]));
|
40 |
-
|
41 |
-
$tests = [];
|
42 |
-
|
43 |
-
$expr = new ConstantExpression('foo', 1);
|
44 |
-
$node = new NullTest($expr, 'null', new Node([]), 1);
|
45 |
-
$tests[] = [$node, '(null === "foo")'];
|
46 |
-
|
47 |
-
// test as an anonymous function
|
48 |
-
if (\PHP_VERSION_ID >= 50300) {
|
49 |
-
$node = $this->createTest(new ConstantExpression('foo', 1), 'anonymous', [new ConstantExpression('foo', 1)]);
|
50 |
-
$tests[] = [$node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), ["foo", "foo"])'];
|
51 |
-
}
|
52 |
-
|
53 |
-
// arbitrary named arguments
|
54 |
-
$string = new ConstantExpression('abc', 1);
|
55 |
-
$node = $this->createTest($string, 'barbar');
|
56 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc")', $environment];
|
57 |
-
|
58 |
-
$node = $this->createTest($string, 'barbar', ['foo' => new ConstantExpression('bar', 1)]);
|
59 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc", null, null, ["foo" => "bar"])', $environment];
|
60 |
-
|
61 |
-
$node = $this->createTest($string, 'barbar', ['arg2' => new ConstantExpression('bar', 1)]);
|
62 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc", null, "bar")', $environment];
|
63 |
-
|
64 |
-
$node = $this->createTest($string, 'barbar', [
|
65 |
-
new ConstantExpression('1', 1),
|
66 |
-
new ConstantExpression('2', 1),
|
67 |
-
new ConstantExpression('3', 1),
|
68 |
-
'foo' => new ConstantExpression('bar', 1),
|
69 |
-
]);
|
70 |
-
$tests[] = [$node, 'Twig\Tests\Node\Expression\twig_tests_test_barbar("abc", "1", "2", [0 => "3", "foo" => "bar"])', $environment];
|
71 |
-
|
72 |
-
return $tests;
|
73 |
-
}
|
74 |
-
|
75 |
-
protected function createTest($node, $name, array $arguments = [])
|
76 |
-
{
|
77 |
-
return new TestExpression($node, $name, new Node($arguments), 1);
|
78 |
-
}
|
79 |
-
|
80 |
-
protected function getEnvironment()
|
81 |
-
{
|
82 |
-
if (\PHP_VERSION_ID >= 50300) {
|
83 |
-
return include 'PHP53/TestInclude.php';
|
84 |
-
}
|
85 |
-
|
86 |
-
return parent::getEnvironment();
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
function twig_tests_test_barbar($string, $arg1 = null, $arg2 = null, array $args = [])
|
91 |
-
{
|
92 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Unary/NegTest.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Unary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\Unary\NegUnary;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class NegTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr = new ConstantExpression(1, 1);
|
23 |
-
$node = new NegUnary($expr, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$node = new ConstantExpression(1, 1);
|
31 |
-
$node = new NegUnary($node, 1);
|
32 |
-
|
33 |
-
return [
|
34 |
-
[$node, '-1'],
|
35 |
-
[new NegUnary($node, 1), '- -1'],
|
36 |
-
];
|
37 |
-
}
|
38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Unary/NotTest.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Unary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\Unary\NotUnary;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class NotTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr = new ConstantExpression(1, 1);
|
23 |
-
$node = new NotUnary($expr, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$node = new ConstantExpression(1, 1);
|
31 |
-
$node = new NotUnary($node, 1);
|
32 |
-
|
33 |
-
return [
|
34 |
-
[$node, '!1'],
|
35 |
-
];
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/Expression/Unary/PosTest.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node\Expression\Unary;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\Unary\PosUnary;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class PosTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr = new ConstantExpression(1, 1);
|
23 |
-
$node = new PosUnary($expr, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($expr, $node->getNode('node'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$node = new ConstantExpression(1, 1);
|
31 |
-
$node = new PosUnary($node, 1);
|
32 |
-
|
33 |
-
return [
|
34 |
-
[$node, '+1'],
|
35 |
-
];
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/ForTest.php
DELETED
@@ -1,201 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\AssignNameExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\NameExpression;
|
17 |
-
use Twig\Node\ForNode;
|
18 |
-
use Twig\Node\Node;
|
19 |
-
use Twig\Node\PrintNode;
|
20 |
-
use Twig\Test\NodeTestCase;
|
21 |
-
|
22 |
-
class ForTest extends NodeTestCase
|
23 |
-
{
|
24 |
-
public function testConstructor()
|
25 |
-
{
|
26 |
-
$keyTarget = new AssignNameExpression('key', 1);
|
27 |
-
$valueTarget = new AssignNameExpression('item', 1);
|
28 |
-
$seq = new NameExpression('items', 1);
|
29 |
-
$ifexpr = new ConstantExpression(true, 1);
|
30 |
-
$body = new Node([new PrintNode(new NameExpression('foo', 1), 1)], [], 1);
|
31 |
-
$else = null;
|
32 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
33 |
-
$node->setAttribute('with_loop', false);
|
34 |
-
|
35 |
-
$this->assertEquals($keyTarget, $node->getNode('key_target'));
|
36 |
-
$this->assertEquals($valueTarget, $node->getNode('value_target'));
|
37 |
-
$this->assertEquals($seq, $node->getNode('seq'));
|
38 |
-
$this->assertTrue($node->getAttribute('ifexpr'));
|
39 |
-
$this->assertInstanceOf('\Twig\Node\IfNode', $node->getNode('body'));
|
40 |
-
$this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0));
|
41 |
-
$this->assertFalse($node->hasNode('else'));
|
42 |
-
|
43 |
-
$else = new PrintNode(new NameExpression('foo', 1), 1);
|
44 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
45 |
-
$node->setAttribute('with_loop', false);
|
46 |
-
$this->assertEquals($else, $node->getNode('else'));
|
47 |
-
}
|
48 |
-
|
49 |
-
public function getTests()
|
50 |
-
{
|
51 |
-
$tests = [];
|
52 |
-
|
53 |
-
$keyTarget = new AssignNameExpression('key', 1);
|
54 |
-
$valueTarget = new AssignNameExpression('item', 1);
|
55 |
-
$seq = new NameExpression('items', 1);
|
56 |
-
$ifexpr = null;
|
57 |
-
$body = new Node([new PrintNode(new NameExpression('foo', 1), 1)], [], 1);
|
58 |
-
$else = null;
|
59 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
60 |
-
$node->setAttribute('with_loop', false);
|
61 |
-
|
62 |
-
$tests[] = [$node, <<<EOF
|
63 |
-
// line 1
|
64 |
-
\$context['_parent'] = \$context;
|
65 |
-
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('items')});
|
66 |
-
foreach (\$context['_seq'] as \$context["key"] => \$context["item"]) {
|
67 |
-
echo {$this->getVariableGetter('foo')};
|
68 |
-
}
|
69 |
-
\$_parent = \$context['_parent'];
|
70 |
-
unset(\$context['_seq'], \$context['_iterated'], \$context['key'], \$context['item'], \$context['_parent'], \$context['loop']);
|
71 |
-
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
72 |
-
EOF
|
73 |
-
];
|
74 |
-
|
75 |
-
$keyTarget = new AssignNameExpression('k', 1);
|
76 |
-
$valueTarget = new AssignNameExpression('v', 1);
|
77 |
-
$seq = new NameExpression('values', 1);
|
78 |
-
$ifexpr = null;
|
79 |
-
$body = new Node([new PrintNode(new NameExpression('foo', 1), 1)], [], 1);
|
80 |
-
$else = null;
|
81 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
82 |
-
$node->setAttribute('with_loop', true);
|
83 |
-
|
84 |
-
$tests[] = [$node, <<<EOF
|
85 |
-
// line 1
|
86 |
-
\$context['_parent'] = \$context;
|
87 |
-
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
|
88 |
-
\$context['loop'] = [
|
89 |
-
'parent' => \$context['_parent'],
|
90 |
-
'index0' => 0,
|
91 |
-
'index' => 1,
|
92 |
-
'first' => true,
|
93 |
-
];
|
94 |
-
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {
|
95 |
-
\$length = count(\$context['_seq']);
|
96 |
-
\$context['loop']['revindex0'] = \$length - 1;
|
97 |
-
\$context['loop']['revindex'] = \$length;
|
98 |
-
\$context['loop']['length'] = \$length;
|
99 |
-
\$context['loop']['last'] = 1 === \$length;
|
100 |
-
}
|
101 |
-
foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
102 |
-
echo {$this->getVariableGetter('foo')};
|
103 |
-
++\$context['loop']['index0'];
|
104 |
-
++\$context['loop']['index'];
|
105 |
-
\$context['loop']['first'] = false;
|
106 |
-
if (isset(\$context['loop']['length'])) {
|
107 |
-
--\$context['loop']['revindex0'];
|
108 |
-
--\$context['loop']['revindex'];
|
109 |
-
\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
|
110 |
-
}
|
111 |
-
}
|
112 |
-
\$_parent = \$context['_parent'];
|
113 |
-
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
114 |
-
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
115 |
-
EOF
|
116 |
-
];
|
117 |
-
|
118 |
-
$keyTarget = new AssignNameExpression('k', 1);
|
119 |
-
$valueTarget = new AssignNameExpression('v', 1);
|
120 |
-
$seq = new NameExpression('values', 1);
|
121 |
-
$ifexpr = new ConstantExpression(true, 1);
|
122 |
-
$body = new Node([new PrintNode(new NameExpression('foo', 1), 1)], [], 1);
|
123 |
-
$else = null;
|
124 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
125 |
-
$node->setAttribute('with_loop', true);
|
126 |
-
|
127 |
-
$tests[] = [$node, <<<EOF
|
128 |
-
// line 1
|
129 |
-
\$context['_parent'] = \$context;
|
130 |
-
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
|
131 |
-
\$context['loop'] = [
|
132 |
-
'parent' => \$context['_parent'],
|
133 |
-
'index0' => 0,
|
134 |
-
'index' => 1,
|
135 |
-
'first' => true,
|
136 |
-
];
|
137 |
-
foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
138 |
-
if (true) {
|
139 |
-
echo {$this->getVariableGetter('foo')};
|
140 |
-
++\$context['loop']['index0'];
|
141 |
-
++\$context['loop']['index'];
|
142 |
-
\$context['loop']['first'] = false;
|
143 |
-
}
|
144 |
-
}
|
145 |
-
\$_parent = \$context['_parent'];
|
146 |
-
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
147 |
-
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
148 |
-
EOF
|
149 |
-
];
|
150 |
-
|
151 |
-
$keyTarget = new AssignNameExpression('k', 1);
|
152 |
-
$valueTarget = new AssignNameExpression('v', 1);
|
153 |
-
$seq = new NameExpression('values', 1);
|
154 |
-
$ifexpr = null;
|
155 |
-
$body = new Node([new PrintNode(new NameExpression('foo', 1), 1)], [], 1);
|
156 |
-
$else = new PrintNode(new NameExpression('foo', 1), 1);
|
157 |
-
$node = new ForNode($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
|
158 |
-
$node->setAttribute('with_loop', true);
|
159 |
-
|
160 |
-
$tests[] = [$node, <<<EOF
|
161 |
-
// line 1
|
162 |
-
\$context['_parent'] = \$context;
|
163 |
-
\$context['_seq'] = twig_ensure_traversable({$this->getVariableGetter('values')});
|
164 |
-
\$context['_iterated'] = false;
|
165 |
-
\$context['loop'] = [
|
166 |
-
'parent' => \$context['_parent'],
|
167 |
-
'index0' => 0,
|
168 |
-
'index' => 1,
|
169 |
-
'first' => true,
|
170 |
-
];
|
171 |
-
if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {
|
172 |
-
\$length = count(\$context['_seq']);
|
173 |
-
\$context['loop']['revindex0'] = \$length - 1;
|
174 |
-
\$context['loop']['revindex'] = \$length;
|
175 |
-
\$context['loop']['length'] = \$length;
|
176 |
-
\$context['loop']['last'] = 1 === \$length;
|
177 |
-
}
|
178 |
-
foreach (\$context['_seq'] as \$context["k"] => \$context["v"]) {
|
179 |
-
echo {$this->getVariableGetter('foo')};
|
180 |
-
\$context['_iterated'] = true;
|
181 |
-
++\$context['loop']['index0'];
|
182 |
-
++\$context['loop']['index'];
|
183 |
-
\$context['loop']['first'] = false;
|
184 |
-
if (isset(\$context['loop']['length'])) {
|
185 |
-
--\$context['loop']['revindex0'];
|
186 |
-
--\$context['loop']['revindex'];
|
187 |
-
\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
|
188 |
-
}
|
189 |
-
}
|
190 |
-
if (!\$context['_iterated']) {
|
191 |
-
echo {$this->getVariableGetter('foo')};
|
192 |
-
}
|
193 |
-
\$_parent = \$context['_parent'];
|
194 |
-
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);
|
195 |
-
\$context = array_intersect_key(\$context, \$_parent) + \$_parent;
|
196 |
-
EOF
|
197 |
-
];
|
198 |
-
|
199 |
-
return $tests;
|
200 |
-
}
|
201 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/IfTest.php
DELETED
@@ -1,97 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
use Twig\Node\IfNode;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\Node\PrintNode;
|
19 |
-
use Twig\Test\NodeTestCase;
|
20 |
-
|
21 |
-
class IfTest extends NodeTestCase
|
22 |
-
{
|
23 |
-
public function testConstructor()
|
24 |
-
{
|
25 |
-
$t = new Node([
|
26 |
-
new ConstantExpression(true, 1),
|
27 |
-
new PrintNode(new NameExpression('foo', 1), 1),
|
28 |
-
], [], 1);
|
29 |
-
$else = null;
|
30 |
-
$node = new IfNode($t, $else, 1);
|
31 |
-
|
32 |
-
$this->assertEquals($t, $node->getNode('tests'));
|
33 |
-
$this->assertFalse($node->hasNode('else'));
|
34 |
-
|
35 |
-
$else = new PrintNode(new NameExpression('bar', 1), 1);
|
36 |
-
$node = new IfNode($t, $else, 1);
|
37 |
-
$this->assertEquals($else, $node->getNode('else'));
|
38 |
-
}
|
39 |
-
|
40 |
-
public function getTests()
|
41 |
-
{
|
42 |
-
$tests = [];
|
43 |
-
|
44 |
-
$t = new Node([
|
45 |
-
new ConstantExpression(true, 1),
|
46 |
-
new PrintNode(new NameExpression('foo', 1), 1),
|
47 |
-
], [], 1);
|
48 |
-
$else = null;
|
49 |
-
$node = new IfNode($t, $else, 1);
|
50 |
-
|
51 |
-
$tests[] = [$node, <<<EOF
|
52 |
-
// line 1
|
53 |
-
if (true) {
|
54 |
-
echo {$this->getVariableGetter('foo')};
|
55 |
-
}
|
56 |
-
EOF
|
57 |
-
];
|
58 |
-
|
59 |
-
$t = new Node([
|
60 |
-
new ConstantExpression(true, 1),
|
61 |
-
new PrintNode(new NameExpression('foo', 1), 1),
|
62 |
-
new ConstantExpression(false, 1),
|
63 |
-
new PrintNode(new NameExpression('bar', 1), 1),
|
64 |
-
], [], 1);
|
65 |
-
$else = null;
|
66 |
-
$node = new IfNode($t, $else, 1);
|
67 |
-
|
68 |
-
$tests[] = [$node, <<<EOF
|
69 |
-
// line 1
|
70 |
-
if (true) {
|
71 |
-
echo {$this->getVariableGetter('foo')};
|
72 |
-
} elseif (false) {
|
73 |
-
echo {$this->getVariableGetter('bar')};
|
74 |
-
}
|
75 |
-
EOF
|
76 |
-
];
|
77 |
-
|
78 |
-
$t = new Node([
|
79 |
-
new ConstantExpression(true, 1),
|
80 |
-
new PrintNode(new NameExpression('foo', 1), 1),
|
81 |
-
], [], 1);
|
82 |
-
$else = new PrintNode(new NameExpression('bar', 1), 1);
|
83 |
-
$node = new IfNode($t, $else, 1);
|
84 |
-
|
85 |
-
$tests[] = [$node, <<<EOF
|
86 |
-
// line 1
|
87 |
-
if (true) {
|
88 |
-
echo {$this->getVariableGetter('foo')};
|
89 |
-
} else {
|
90 |
-
echo {$this->getVariableGetter('bar')};
|
91 |
-
}
|
92 |
-
EOF
|
93 |
-
];
|
94 |
-
|
95 |
-
return $tests;
|
96 |
-
}
|
97 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/ImportTest.php
DELETED
@@ -1,47 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\AssignNameExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\ImportNode;
|
17 |
-
use Twig\Test\NodeTestCase;
|
18 |
-
|
19 |
-
class ImportTest extends NodeTestCase
|
20 |
-
{
|
21 |
-
public function testConstructor()
|
22 |
-
{
|
23 |
-
$macro = new ConstantExpression('foo.twig', 1);
|
24 |
-
$var = new AssignNameExpression('macro', 1);
|
25 |
-
$node = new ImportNode($macro, $var, 1);
|
26 |
-
|
27 |
-
$this->assertEquals($macro, $node->getNode('expr'));
|
28 |
-
$this->assertEquals($var, $node->getNode('var'));
|
29 |
-
}
|
30 |
-
|
31 |
-
public function getTests()
|
32 |
-
{
|
33 |
-
$tests = [];
|
34 |
-
|
35 |
-
$macro = new ConstantExpression('foo.twig', 1);
|
36 |
-
$var = new AssignNameExpression('macro', 1);
|
37 |
-
$node = new ImportNode($macro, $var, 1);
|
38 |
-
|
39 |
-
$tests[] = [$node, <<<EOF
|
40 |
-
// line 1
|
41 |
-
\$context["macro"] = \$this->loadTemplate("foo.twig", null, 1)->unwrap();
|
42 |
-
EOF
|
43 |
-
];
|
44 |
-
|
45 |
-
return $tests;
|
46 |
-
}
|
47 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/IncludeTest.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ArrayExpression;
|
15 |
-
use Twig\Node\Expression\ConditionalExpression;
|
16 |
-
use Twig\Node\Expression\ConstantExpression;
|
17 |
-
use Twig\Node\IncludeNode;
|
18 |
-
use Twig\Test\NodeTestCase;
|
19 |
-
|
20 |
-
class IncludeTest extends NodeTestCase
|
21 |
-
{
|
22 |
-
public function testConstructor()
|
23 |
-
{
|
24 |
-
$expr = new ConstantExpression('foo.twig', 1);
|
25 |
-
$node = new IncludeNode($expr, null, false, false, 1);
|
26 |
-
|
27 |
-
$this->assertFalse($node->hasNode('variables'));
|
28 |
-
$this->assertEquals($expr, $node->getNode('expr'));
|
29 |
-
$this->assertFalse($node->getAttribute('only'));
|
30 |
-
|
31 |
-
$vars = new ArrayExpression([new ConstantExpression('foo', 1), new ConstantExpression(true, 1)], 1);
|
32 |
-
$node = new IncludeNode($expr, $vars, true, false, 1);
|
33 |
-
$this->assertEquals($vars, $node->getNode('variables'));
|
34 |
-
$this->assertTrue($node->getAttribute('only'));
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getTests()
|
38 |
-
{
|
39 |
-
$tests = [];
|
40 |
-
|
41 |
-
$expr = new ConstantExpression('foo.twig', 1);
|
42 |
-
$node = new IncludeNode($expr, null, false, false, 1);
|
43 |
-
$tests[] = [$node, <<<EOF
|
44 |
-
// line 1
|
45 |
-
\$this->loadTemplate("foo.twig", null, 1)->display(\$context);
|
46 |
-
EOF
|
47 |
-
];
|
48 |
-
|
49 |
-
$expr = new ConditionalExpression(
|
50 |
-
new ConstantExpression(true, 1),
|
51 |
-
new ConstantExpression('foo', 1),
|
52 |
-
new ConstantExpression('foo', 1),
|
53 |
-
0
|
54 |
-
);
|
55 |
-
$node = new IncludeNode($expr, null, false, false, 1);
|
56 |
-
$tests[] = [$node, <<<EOF
|
57 |
-
// line 1
|
58 |
-
\$this->loadTemplate(((true) ? ("foo") : ("foo")), null, 1)->display(\$context);
|
59 |
-
EOF
|
60 |
-
];
|
61 |
-
|
62 |
-
$expr = new ConstantExpression('foo.twig', 1);
|
63 |
-
$vars = new ArrayExpression([new ConstantExpression('foo', 1), new ConstantExpression(true, 1)], 1);
|
64 |
-
$node = new IncludeNode($expr, $vars, false, false, 1);
|
65 |
-
$tests[] = [$node, <<<EOF
|
66 |
-
// line 1
|
67 |
-
\$this->loadTemplate("foo.twig", null, 1)->display(twig_array_merge(\$context, ["foo" => true]));
|
68 |
-
EOF
|
69 |
-
];
|
70 |
-
|
71 |
-
$node = new IncludeNode($expr, $vars, true, false, 1);
|
72 |
-
$tests[] = [$node, <<<EOF
|
73 |
-
// line 1
|
74 |
-
\$this->loadTemplate("foo.twig", null, 1)->display(twig_to_array(["foo" => true]));
|
75 |
-
EOF
|
76 |
-
];
|
77 |
-
|
78 |
-
$node = new IncludeNode($expr, $vars, true, true, 1);
|
79 |
-
$tests[] = [$node, <<<EOF
|
80 |
-
// line 1
|
81 |
-
\$__internal_%s = null;
|
82 |
-
try {
|
83 |
-
\$__internal_%s = \$this->loadTemplate("foo.twig", null, 1);
|
84 |
-
} catch (LoaderError \$e) {
|
85 |
-
// ignore missing template
|
86 |
-
}
|
87 |
-
if (\$__internal_%s) {
|
88 |
-
\$__internal_%s->display(twig_to_array(["foo" => true]));
|
89 |
-
}
|
90 |
-
EOF
|
91 |
-
, null, true];
|
92 |
-
|
93 |
-
return $tests;
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/MacroTest.php
DELETED
@@ -1,83 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\Expression\NameExpression;
|
16 |
-
use Twig\Node\MacroNode;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\Node\TextNode;
|
19 |
-
use Twig\Test\NodeTestCase;
|
20 |
-
|
21 |
-
class MacroTest extends NodeTestCase
|
22 |
-
{
|
23 |
-
public function testConstructor()
|
24 |
-
{
|
25 |
-
$body = new TextNode('foo', 1);
|
26 |
-
$arguments = new Node([new NameExpression('foo', 1)], [], 1);
|
27 |
-
$node = new MacroNode('foo', $body, $arguments, 1);
|
28 |
-
|
29 |
-
$this->assertEquals($body, $node->getNode('body'));
|
30 |
-
$this->assertEquals($arguments, $node->getNode('arguments'));
|
31 |
-
$this->assertEquals('foo', $node->getAttribute('name'));
|
32 |
-
}
|
33 |
-
|
34 |
-
public function getTests()
|
35 |
-
{
|
36 |
-
$body = new TextNode('foo', 1);
|
37 |
-
$arguments = new Node([
|
38 |
-
'foo' => new ConstantExpression(null, 1),
|
39 |
-
'bar' => new ConstantExpression('Foo', 1),
|
40 |
-
], [], 1);
|
41 |
-
$node = new MacroNode('foo', $body, $arguments, 1);
|
42 |
-
|
43 |
-
if (\PHP_VERSION_ID >= 50600) {
|
44 |
-
$declaration = ', ...$__varargs__';
|
45 |
-
$varargs = '$__varargs__';
|
46 |
-
} else {
|
47 |
-
$declaration = '';
|
48 |
-
$varargs = 'func_num_args() > 2 ? array_slice(func_get_args(), 2) : []';
|
49 |
-
}
|
50 |
-
|
51 |
-
return [
|
52 |
-
[$node, <<<EOF
|
53 |
-
// line 1
|
54 |
-
public function getfoo(\$__foo__ = null, \$__bar__ = "Foo"$declaration)
|
55 |
-
{
|
56 |
-
\$context = \$this->env->mergeGlobals([
|
57 |
-
"foo" => \$__foo__,
|
58 |
-
"bar" => \$__bar__,
|
59 |
-
"varargs" => $varargs,
|
60 |
-
]);
|
61 |
-
|
62 |
-
\$blocks = [];
|
63 |
-
|
64 |
-
ob_start(function () { return ''; });
|
65 |
-
try {
|
66 |
-
echo "foo";
|
67 |
-
} catch (\Exception \$e) {
|
68 |
-
ob_end_clean();
|
69 |
-
|
70 |
-
throw \$e;
|
71 |
-
} catch (\Throwable \$e) {
|
72 |
-
ob_end_clean();
|
73 |
-
|
74 |
-
throw \$e;
|
75 |
-
}
|
76 |
-
|
77 |
-
return ('' === \$tmp = ob_get_clean()) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
78 |
-
}
|
79 |
-
EOF
|
80 |
-
],
|
81 |
-
];
|
82 |
-
}
|
83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/ModuleTest.php
DELETED
@@ -1,270 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Expression\AssignNameExpression;
|
16 |
-
use Twig\Node\Expression\ConditionalExpression;
|
17 |
-
use Twig\Node\Expression\ConstantExpression;
|
18 |
-
use Twig\Node\ImportNode;
|
19 |
-
use Twig\Node\ModuleNode;
|
20 |
-
use Twig\Node\Node;
|
21 |
-
use Twig\Node\SetNode;
|
22 |
-
use Twig\Node\TextNode;
|
23 |
-
use Twig\Source;
|
24 |
-
use Twig\Test\NodeTestCase;
|
25 |
-
|
26 |
-
class ModuleTest extends NodeTestCase
|
27 |
-
{
|
28 |
-
public function testConstructor()
|
29 |
-
{
|
30 |
-
$body = new TextNode('foo', 1);
|
31 |
-
$parent = new ConstantExpression('layout.twig', 1);
|
32 |
-
$blocks = new Node();
|
33 |
-
$macros = new Node();
|
34 |
-
$traits = new Node();
|
35 |
-
$source = new Source('{{ foo }}', 'foo.twig');
|
36 |
-
$node = new ModuleNode($body, $parent, $blocks, $macros, $traits, new Node([]), $source);
|
37 |
-
|
38 |
-
$this->assertEquals($body, $node->getNode('body'));
|
39 |
-
$this->assertEquals($blocks, $node->getNode('blocks'));
|
40 |
-
$this->assertEquals($macros, $node->getNode('macros'));
|
41 |
-
$this->assertEquals($parent, $node->getNode('parent'));
|
42 |
-
$this->assertEquals($source->getName(), $node->getTemplateName());
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getTests()
|
46 |
-
{
|
47 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
48 |
-
|
49 |
-
$tests = [];
|
50 |
-
|
51 |
-
$body = new TextNode('foo', 1);
|
52 |
-
$extends = null;
|
53 |
-
$blocks = new Node();
|
54 |
-
$macros = new Node();
|
55 |
-
$traits = new Node();
|
56 |
-
$source = new Source('{{ foo }}', 'foo.twig');
|
57 |
-
|
58 |
-
$node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source);
|
59 |
-
$tests[] = [$node, <<<EOF
|
60 |
-
<?php
|
61 |
-
|
62 |
-
use Twig\Environment;
|
63 |
-
use Twig\Error\LoaderError;
|
64 |
-
use Twig\Error\RuntimeError;
|
65 |
-
use Twig\Markup;
|
66 |
-
use Twig\Sandbox\SecurityError;
|
67 |
-
use Twig\Sandbox\SecurityNotAllowedTagError;
|
68 |
-
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
69 |
-
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
70 |
-
use Twig\Source;
|
71 |
-
use Twig\Template;
|
72 |
-
|
73 |
-
/* foo.twig */
|
74 |
-
class __TwigTemplate_%x extends \Twig\Template
|
75 |
-
{
|
76 |
-
public function __construct(Environment \$env)
|
77 |
-
{
|
78 |
-
parent::__construct(\$env);
|
79 |
-
|
80 |
-
\$this->parent = false;
|
81 |
-
|
82 |
-
\$this->blocks = [
|
83 |
-
];
|
84 |
-
}
|
85 |
-
|
86 |
-
protected function doDisplay(array \$context, array \$blocks = [])
|
87 |
-
{
|
88 |
-
// line 1
|
89 |
-
echo "foo";
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getTemplateName()
|
93 |
-
{
|
94 |
-
return "foo.twig";
|
95 |
-
}
|
96 |
-
|
97 |
-
public function getDebugInfo()
|
98 |
-
{
|
99 |
-
return array ( 30 => 1,);
|
100 |
-
}
|
101 |
-
|
102 |
-
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
103 |
-
public function getSource()
|
104 |
-
{
|
105 |
-
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
|
106 |
-
|
107 |
-
return \$this->getSourceContext()->getCode();
|
108 |
-
}
|
109 |
-
|
110 |
-
public function getSourceContext()
|
111 |
-
{
|
112 |
-
return new Source("", "foo.twig", "");
|
113 |
-
}
|
114 |
-
}
|
115 |
-
EOF
|
116 |
-
, $twig, true];
|
117 |
-
|
118 |
-
$import = new ImportNode(new ConstantExpression('foo.twig', 1), new AssignNameExpression('macro', 1), 2);
|
119 |
-
|
120 |
-
$body = new Node([$import]);
|
121 |
-
$extends = new ConstantExpression('layout.twig', 1);
|
122 |
-
|
123 |
-
$node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source);
|
124 |
-
$tests[] = [$node, <<<EOF
|
125 |
-
<?php
|
126 |
-
|
127 |
-
use Twig\Environment;
|
128 |
-
use Twig\Error\LoaderError;
|
129 |
-
use Twig\Error\RuntimeError;
|
130 |
-
use Twig\Markup;
|
131 |
-
use Twig\Sandbox\SecurityError;
|
132 |
-
use Twig\Sandbox\SecurityNotAllowedTagError;
|
133 |
-
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
134 |
-
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
135 |
-
use Twig\Source;
|
136 |
-
use Twig\Template;
|
137 |
-
|
138 |
-
/* foo.twig */
|
139 |
-
class __TwigTemplate_%x extends \Twig\Template
|
140 |
-
{
|
141 |
-
public function __construct(Environment \$env)
|
142 |
-
{
|
143 |
-
parent::__construct(\$env);
|
144 |
-
|
145 |
-
\$this->blocks = [
|
146 |
-
];
|
147 |
-
}
|
148 |
-
|
149 |
-
protected function doGetParent(array \$context)
|
150 |
-
{
|
151 |
-
// line 1
|
152 |
-
return "layout.twig";
|
153 |
-
}
|
154 |
-
|
155 |
-
protected function doDisplay(array \$context, array \$blocks = [])
|
156 |
-
{
|
157 |
-
// line 2
|
158 |
-
\$context["macro"] = \$this->loadTemplate("foo.twig", "foo.twig", 2)->unwrap();
|
159 |
-
// line 1
|
160 |
-
\$this->parent = \$this->loadTemplate("layout.twig", "foo.twig", 1);
|
161 |
-
\$this->parent->display(\$context, array_merge(\$this->blocks, \$blocks));
|
162 |
-
}
|
163 |
-
|
164 |
-
public function getTemplateName()
|
165 |
-
{
|
166 |
-
return "foo.twig";
|
167 |
-
}
|
168 |
-
|
169 |
-
public function isTraitable()
|
170 |
-
{
|
171 |
-
return false;
|
172 |
-
}
|
173 |
-
|
174 |
-
public function getDebugInfo()
|
175 |
-
{
|
176 |
-
return array ( 36 => 1, 34 => 2, 28 => 1,);
|
177 |
-
}
|
178 |
-
|
179 |
-
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
180 |
-
public function getSource()
|
181 |
-
{
|
182 |
-
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
|
183 |
-
|
184 |
-
return \$this->getSourceContext()->getCode();
|
185 |
-
}
|
186 |
-
|
187 |
-
public function getSourceContext()
|
188 |
-
{
|
189 |
-
return new Source("", "foo.twig", "");
|
190 |
-
}
|
191 |
-
}
|
192 |
-
EOF
|
193 |
-
, $twig, true];
|
194 |
-
|
195 |
-
$set = new SetNode(false, new Node([new AssignNameExpression('foo', 4)]), new Node([new ConstantExpression('foo', 4)]), 4);
|
196 |
-
$body = new Node([$set]);
|
197 |
-
$extends = new ConditionalExpression(
|
198 |
-
new ConstantExpression(true, 2),
|
199 |
-
new ConstantExpression('foo', 2),
|
200 |
-
new ConstantExpression('foo', 2),
|
201 |
-
2
|
202 |
-
);
|
203 |
-
|
204 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['debug' => true]);
|
205 |
-
$node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source);
|
206 |
-
$tests[] = [$node, <<<EOF
|
207 |
-
<?php
|
208 |
-
|
209 |
-
use Twig\Environment;
|
210 |
-
use Twig\Error\LoaderError;
|
211 |
-
use Twig\Error\RuntimeError;
|
212 |
-
use Twig\Markup;
|
213 |
-
use Twig\Sandbox\SecurityError;
|
214 |
-
use Twig\Sandbox\SecurityNotAllowedTagError;
|
215 |
-
use Twig\Sandbox\SecurityNotAllowedFilterError;
|
216 |
-
use Twig\Sandbox\SecurityNotAllowedFunctionError;
|
217 |
-
use Twig\Source;
|
218 |
-
use Twig\Template;
|
219 |
-
|
220 |
-
/* foo.twig */
|
221 |
-
class __TwigTemplate_%x extends \Twig\Template
|
222 |
-
{
|
223 |
-
protected function doGetParent(array \$context)
|
224 |
-
{
|
225 |
-
// line 2
|
226 |
-
return \$this->loadTemplate(((true) ? ("foo") : ("foo")), "foo.twig", 2);
|
227 |
-
}
|
228 |
-
|
229 |
-
protected function doDisplay(array \$context, array \$blocks = [])
|
230 |
-
{
|
231 |
-
// line 4
|
232 |
-
\$context["foo"] = "foo";
|
233 |
-
// line 2
|
234 |
-
\$this->getParent(\$context)->display(\$context, array_merge(\$this->blocks, \$blocks));
|
235 |
-
}
|
236 |
-
|
237 |
-
public function getTemplateName()
|
238 |
-
{
|
239 |
-
return "foo.twig";
|
240 |
-
}
|
241 |
-
|
242 |
-
public function isTraitable()
|
243 |
-
{
|
244 |
-
return false;
|
245 |
-
}
|
246 |
-
|
247 |
-
public function getDebugInfo()
|
248 |
-
{
|
249 |
-
return array ( 28 => 2, 26 => 4, 20 => 2,);
|
250 |
-
}
|
251 |
-
|
252 |
-
/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */
|
253 |
-
public function getSource()
|
254 |
-
{
|
255 |
-
@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);
|
256 |
-
|
257 |
-
return \$this->getSourceContext()->getCode();
|
258 |
-
}
|
259 |
-
|
260 |
-
public function getSourceContext()
|
261 |
-
{
|
262 |
-
return new Source("{{ foo }}", "foo.twig", "");
|
263 |
-
}
|
264 |
-
}
|
265 |
-
EOF
|
266 |
-
, $twig, true];
|
267 |
-
|
268 |
-
return $tests;
|
269 |
-
}
|
270 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/PrintTest.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\ConstantExpression;
|
15 |
-
use Twig\Node\PrintNode;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class PrintTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$expr = new ConstantExpression('foo', 1);
|
23 |
-
$node = new PrintNode($expr, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($expr, $node->getNode('expr'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$tests = [];
|
31 |
-
$tests[] = [new PrintNode(new ConstantExpression('foo', 1), 1), "// line 1\necho \"foo\";"];
|
32 |
-
|
33 |
-
return $tests;
|
34 |
-
}
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/SandboxTest.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\SandboxNode;
|
15 |
-
use Twig\Node\TextNode;
|
16 |
-
use Twig\Test\NodeTestCase;
|
17 |
-
|
18 |
-
class SandboxTest extends NodeTestCase
|
19 |
-
{
|
20 |
-
public function testConstructor()
|
21 |
-
{
|
22 |
-
$body = new TextNode('foo', 1);
|
23 |
-
$node = new SandboxNode($body, 1);
|
24 |
-
|
25 |
-
$this->assertEquals($body, $node->getNode('body'));
|
26 |
-
}
|
27 |
-
|
28 |
-
public function getTests()
|
29 |
-
{
|
30 |
-
$tests = [];
|
31 |
-
|
32 |
-
$body = new TextNode('foo', 1);
|
33 |
-
$node = new SandboxNode($body, 1);
|
34 |
-
|
35 |
-
$tests[] = [$node, <<<EOF
|
36 |
-
// line 1
|
37 |
-
if (!\$alreadySandboxed = \$this->sandbox->isSandboxed()) {
|
38 |
-
\$this->sandbox->enableSandbox();
|
39 |
-
}
|
40 |
-
echo "foo";
|
41 |
-
if (!\$alreadySandboxed) {
|
42 |
-
\$this->sandbox->disableSandbox();
|
43 |
-
}
|
44 |
-
EOF
|
45 |
-
];
|
46 |
-
|
47 |
-
return $tests;
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/SetTest.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Expression\AssignNameExpression;
|
15 |
-
use Twig\Node\Expression\ConstantExpression;
|
16 |
-
use Twig\Node\Expression\NameExpression;
|
17 |
-
use Twig\Node\Node;
|
18 |
-
use Twig\Node\PrintNode;
|
19 |
-
use Twig\Node\SetNode;
|
20 |
-
use Twig\Node\TextNode;
|
21 |
-
use Twig\Test\NodeTestCase;
|
22 |
-
|
23 |
-
class SetTest extends NodeTestCase
|
24 |
-
{
|
25 |
-
public function testConstructor()
|
26 |
-
{
|
27 |
-
$names = new Node([new AssignNameExpression('foo', 1)], [], 1);
|
28 |
-
$values = new Node([new ConstantExpression('foo', 1)], [], 1);
|
29 |
-
$node = new SetNode(false, $names, $values, 1);
|
30 |
-
|
31 |
-
$this->assertEquals($names, $node->getNode('names'));
|
32 |
-
$this->assertEquals($values, $node->getNode('values'));
|
33 |
-
$this->assertFalse($node->getAttribute('capture'));
|
34 |
-
}
|
35 |
-
|
36 |
-
public function getTests()
|
37 |
-
{
|
38 |
-
$tests = [];
|
39 |
-
|
40 |
-
$names = new Node([new AssignNameExpression('foo', 1)], [], 1);
|
41 |
-
$values = new Node([new ConstantExpression('foo', 1)], [], 1);
|
42 |
-
$node = new SetNode(false, $names, $values, 1);
|
43 |
-
$tests[] = [$node, <<<EOF
|
44 |
-
// line 1
|
45 |
-
\$context["foo"] = "foo";
|
46 |
-
EOF
|
47 |
-
];
|
48 |
-
|
49 |
-
$names = new Node([new AssignNameExpression('foo', 1)], [], 1);
|
50 |
-
$values = new Node([new PrintNode(new ConstantExpression('foo', 1), 1)], [], 1);
|
51 |
-
$node = new SetNode(true, $names, $values, 1);
|
52 |
-
$tests[] = [$node, <<<EOF
|
53 |
-
// line 1
|
54 |
-
ob_start(function () { return ''; });
|
55 |
-
echo "foo";
|
56 |
-
\$context["foo"] = ('' === \$tmp = ob_get_clean()) ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
57 |
-
EOF
|
58 |
-
];
|
59 |
-
|
60 |
-
$names = new Node([new AssignNameExpression('foo', 1)], [], 1);
|
61 |
-
$values = new TextNode('foo', 1);
|
62 |
-
$node = new SetNode(true, $names, $values, 1);
|
63 |
-
$tests[] = [$node, <<<EOF
|
64 |
-
// line 1
|
65 |
-
\$context["foo"] = ('' === \$tmp = "foo") ? '' : new Markup(\$tmp, \$this->env->getCharset());
|
66 |
-
EOF
|
67 |
-
];
|
68 |
-
|
69 |
-
$names = new Node([new AssignNameExpression('foo', 1), new AssignNameExpression('bar', 1)], [], 1);
|
70 |
-
$values = new Node([new ConstantExpression('foo', 1), new NameExpression('bar', 1)], [], 1);
|
71 |
-
$node = new SetNode(false, $names, $values, 1);
|
72 |
-
$tests[] = [$node, <<<EOF
|
73 |
-
// line 1
|
74 |
-
list(\$context["foo"], \$context["bar"]) = ["foo", {$this->getVariableGetter('bar')}];
|
75 |
-
EOF
|
76 |
-
];
|
77 |
-
|
78 |
-
return $tests;
|
79 |
-
}
|
80 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/SpacelessTest.php
DELETED
@@ -1,44 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\Node;
|
15 |
-
use Twig\Node\SpacelessNode;
|
16 |
-
use Twig\Node\TextNode;
|
17 |
-
use Twig\Test\NodeTestCase;
|
18 |
-
|
19 |
-
class SpacelessTest extends NodeTestCase
|
20 |
-
{
|
21 |
-
public function testConstructor()
|
22 |
-
{
|
23 |
-
$body = new Node([new TextNode('<div> <div> foo </div> </div>', 1)]);
|
24 |
-
$node = new SpacelessNode($body, 1);
|
25 |
-
|
26 |
-
$this->assertEquals($body, $node->getNode('body'));
|
27 |
-
}
|
28 |
-
|
29 |
-
public function getTests()
|
30 |
-
{
|
31 |
-
$body = new Node([new TextNode('<div> <div> foo </div> </div>', 1)]);
|
32 |
-
$node = new SpacelessNode($body, 1);
|
33 |
-
|
34 |
-
return [
|
35 |
-
[$node, <<<EOF
|
36 |
-
// line 1
|
37 |
-
ob_start(function () { return ''; });
|
38 |
-
echo "<div> <div> foo </div> </div>";
|
39 |
-
echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));
|
40 |
-
EOF
|
41 |
-
],
|
42 |
-
];
|
43 |
-
}
|
44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Node/TextTest.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Node;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Node\TextNode;
|
15 |
-
use Twig\Test\NodeTestCase;
|
16 |
-
|
17 |
-
class TextTest extends NodeTestCase
|
18 |
-
{
|
19 |
-
public function testConstructor()
|
20 |
-
{
|
21 |
-
$node = new TextNode('foo', 1);
|
22 |
-
|
23 |
-
$this->assertEquals('foo', $node->getAttribute('data'));
|
24 |
-
}
|
25 |
-
|
26 |
-
public function getTests()
|
27 |
-
{
|
28 |
-
$tests = [];
|
29 |
-
$tests[] = [new TextNode('foo', 1), "// line 1\necho \"foo\";"];
|
30 |
-
|
31 |
-
return $tests;
|
32 |
-
}
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/NodeTraverserTest.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\Node;
|
16 |
-
use Twig\NodeTraverser;
|
17 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
18 |
-
|
19 |
-
class NodeTraverserTest extends \PHPUnit\Framework\TestCase
|
20 |
-
{
|
21 |
-
/**
|
22 |
-
* @group legacy
|
23 |
-
*/
|
24 |
-
public function testNodeIsNullWhenTraversing()
|
25 |
-
{
|
26 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
27 |
-
$traverser = new NodeTraverser($env, [new IdentityVisitor()]);
|
28 |
-
$n = new Node([new Node([]), null, new Node([])]);
|
29 |
-
$this->assertCount(3, $traverser->traverse($n));
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
class IdentityVisitor implements NodeVisitorInterface
|
34 |
-
{
|
35 |
-
public function enterNode(\Twig_NodeInterface $node, Environment $env)
|
36 |
-
{
|
37 |
-
return $node;
|
38 |
-
}
|
39 |
-
|
40 |
-
public function leaveNode(\Twig_NodeInterface $node, Environment $env)
|
41 |
-
{
|
42 |
-
return $node;
|
43 |
-
}
|
44 |
-
|
45 |
-
public function getPriority()
|
46 |
-
{
|
47 |
-
return 0;
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/NodeVisitor/OptimizerTest.php
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\NodeVisitor;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\ForNode;
|
16 |
-
use Twig\Source;
|
17 |
-
|
18 |
-
class OptimizerTest extends \PHPUnit\Framework\TestCase
|
19 |
-
{
|
20 |
-
public function testRenderBlockOptimizer()
|
21 |
-
{
|
22 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
23 |
-
|
24 |
-
$stream = $env->parse($env->tokenize(new Source('{{ block("foo") }}', 'index')));
|
25 |
-
|
26 |
-
$node = $stream->getNode('body')->getNode(0);
|
27 |
-
|
28 |
-
$this->assertInstanceOf('\Twig\Node\Expression\BlockReferenceExpression', $node);
|
29 |
-
$this->assertTrue($node->getAttribute('output'));
|
30 |
-
}
|
31 |
-
|
32 |
-
public function testRenderParentBlockOptimizer()
|
33 |
-
{
|
34 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false, 'autoescape' => false]);
|
35 |
-
|
36 |
-
$stream = $env->parse($env->tokenize(new Source('{% extends "foo" %}{% block content %}{{ parent() }}{% endblock %}', 'index')));
|
37 |
-
|
38 |
-
$node = $stream->getNode('blocks')->getNode('content')->getNode(0)->getNode('body');
|
39 |
-
|
40 |
-
$this->assertInstanceOf('\Twig\Node\Expression\ParentExpression', $node);
|
41 |
-
$this->assertTrue($node->getAttribute('output'));
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* @dataProvider getTestsForForOptimizer
|
46 |
-
*/
|
47 |
-
public function testForOptimizer($template, $expected)
|
48 |
-
{
|
49 |
-
$env = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['cache' => false]);
|
50 |
-
|
51 |
-
$stream = $env->parse($env->tokenize(new Source($template, 'index')));
|
52 |
-
|
53 |
-
foreach ($expected as $target => $withLoop) {
|
54 |
-
$this->assertTrue($this->checkForConfiguration($stream, $target, $withLoop), sprintf('variable %s is %soptimized', $target, $withLoop ? 'not ' : ''));
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getTestsForForOptimizer()
|
59 |
-
{
|
60 |
-
return [
|
61 |
-
['{% for i in foo %}{% endfor %}', ['i' => false]],
|
62 |
-
|
63 |
-
['{% for i in foo %}{{ loop.index }}{% endfor %}', ['i' => true]],
|
64 |
-
|
65 |
-
['{% for i in foo %}{% for j in foo %}{% endfor %}{% endfor %}', ['i' => false, 'j' => false]],
|
66 |
-
|
67 |
-
['{% for i in foo %}{% include "foo" %}{% endfor %}', ['i' => true]],
|
68 |
-
|
69 |
-
['{% for i in foo %}{% include "foo" only %}{% endfor %}', ['i' => false]],
|
70 |
-
|
71 |
-
['{% for i in foo %}{% include "foo" with { "foo": "bar" } only %}{% endfor %}', ['i' => false]],
|
72 |
-
|
73 |
-
['{% for i in foo %}{% include "foo" with { "foo": loop.index } only %}{% endfor %}', ['i' => true]],
|
74 |
-
|
75 |
-
['{% for i in foo %}{% for j in foo %}{{ loop.index }}{% endfor %}{% endfor %}', ['i' => false, 'j' => true]],
|
76 |
-
|
77 |
-
['{% for i in foo %}{% for j in foo %}{{ loop.parent.loop.index }}{% endfor %}{% endfor %}', ['i' => true, 'j' => true]],
|
78 |
-
|
79 |
-
['{% for i in foo %}{% set l = loop %}{% for j in foo %}{{ l.index }}{% endfor %}{% endfor %}', ['i' => true, 'j' => false]],
|
80 |
-
|
81 |
-
['{% for i in foo %}{% for j in foo %}{{ foo.parent.loop.index }}{% endfor %}{% endfor %}', ['i' => false, 'j' => false]],
|
82 |
-
|
83 |
-
['{% for i in foo %}{% for j in foo %}{{ loop["parent"].loop.index }}{% endfor %}{% endfor %}', ['i' => true, 'j' => true]],
|
84 |
-
|
85 |
-
['{% for i in foo %}{{ include("foo") }}{% endfor %}', ['i' => true]],
|
86 |
-
|
87 |
-
['{% for i in foo %}{{ include("foo", with_context = false) }}{% endfor %}', ['i' => false]],
|
88 |
-
|
89 |
-
['{% for i in foo %}{{ include("foo", with_context = true) }}{% endfor %}', ['i' => true]],
|
90 |
-
|
91 |
-
['{% for i in foo %}{{ include("foo", { "foo": "bar" }, with_context = false) }}{% endfor %}', ['i' => false]],
|
92 |
-
|
93 |
-
['{% for i in foo %}{{ include("foo", { "foo": loop.index }, with_context = false) }}{% endfor %}', ['i' => true]],
|
94 |
-
];
|
95 |
-
}
|
96 |
-
|
97 |
-
public function checkForConfiguration(\Twig_NodeInterface $node = null, $target, $withLoop)
|
98 |
-
{
|
99 |
-
if (null === $node) {
|
100 |
-
return;
|
101 |
-
}
|
102 |
-
|
103 |
-
foreach ($node as $n) {
|
104 |
-
if ($n instanceof ForNode) {
|
105 |
-
if ($target === $n->getNode('value_target')->getAttribute('name')) {
|
106 |
-
return $withLoop == $n->getAttribute('with_loop');
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
$ret = $this->checkForConfiguration($n, $target, $withLoop);
|
111 |
-
if (null !== $ret) {
|
112 |
-
return $ret;
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/ParserTest.php
DELETED
@@ -1,218 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Node\MacroNode;
|
16 |
-
use Twig\Node\Node;
|
17 |
-
use Twig\Node\SetNode;
|
18 |
-
use Twig\Node\TextNode;
|
19 |
-
use Twig\Parser;
|
20 |
-
use Twig\Source;
|
21 |
-
use Twig\Token;
|
22 |
-
use Twig\TokenParser\AbstractTokenParser;
|
23 |
-
use Twig\TokenStream;
|
24 |
-
|
25 |
-
class ParserTest extends \PHPUnit\Framework\TestCase
|
26 |
-
{
|
27 |
-
public function testSetMacroThrowsExceptionOnReservedMethods()
|
28 |
-
{
|
29 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
30 |
-
|
31 |
-
$parser = $this->getParser();
|
32 |
-
$parser->setMacro('parent', new MacroNode('foo', new Node(), new Node(), 1));
|
33 |
-
}
|
34 |
-
|
35 |
-
public function testUnknownTag()
|
36 |
-
{
|
37 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
38 |
-
$this->expectExceptionMessage('Unknown "foo" tag. Did you mean "for" at line 1?');
|
39 |
-
|
40 |
-
$stream = new TokenStream([
|
41 |
-
new Token(Token::BLOCK_START_TYPE, '', 1),
|
42 |
-
new Token(Token::NAME_TYPE, 'foo', 1),
|
43 |
-
new Token(Token::BLOCK_END_TYPE, '', 1),
|
44 |
-
new Token(Token::EOF_TYPE, '', 1),
|
45 |
-
]);
|
46 |
-
$parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
47 |
-
$parser->parse($stream);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function testUnknownTagWithoutSuggestions()
|
51 |
-
{
|
52 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
53 |
-
$this->expectExceptionMessage('Unknown "foobar" tag at line 1.');
|
54 |
-
|
55 |
-
$stream = new TokenStream([
|
56 |
-
new Token(Token::BLOCK_START_TYPE, '', 1),
|
57 |
-
new Token(Token::NAME_TYPE, 'foobar', 1),
|
58 |
-
new Token(Token::BLOCK_END_TYPE, '', 1),
|
59 |
-
new Token(Token::EOF_TYPE, '', 1),
|
60 |
-
]);
|
61 |
-
$parser = new Parser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
62 |
-
$parser->parse($stream);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* @dataProvider getFilterBodyNodesData
|
67 |
-
*/
|
68 |
-
public function testFilterBodyNodes($input, $expected)
|
69 |
-
{
|
70 |
-
$parser = $this->getParser();
|
71 |
-
|
72 |
-
$this->assertEquals($expected, $parser->filterBodyNodes($input));
|
73 |
-
}
|
74 |
-
|
75 |
-
public function getFilterBodyNodesData()
|
76 |
-
{
|
77 |
-
return [
|
78 |
-
[
|
79 |
-
new Node([new TextNode(' ', 1)]),
|
80 |
-
new Node([]),
|
81 |
-
],
|
82 |
-
[
|
83 |
-
$input = new Node([new SetNode(false, new Node(), new Node(), 1)]),
|
84 |
-
$input,
|
85 |
-
],
|
86 |
-
[
|
87 |
-
$input = new Node([new SetNode(true, new Node(), new Node([new Node([new TextNode('foo', 1)])]), 1)]),
|
88 |
-
$input,
|
89 |
-
],
|
90 |
-
];
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @dataProvider getFilterBodyNodesDataThrowsException
|
95 |
-
*/
|
96 |
-
public function testFilterBodyNodesThrowsException($input)
|
97 |
-
{
|
98 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
99 |
-
|
100 |
-
$parser = $this->getParser();
|
101 |
-
|
102 |
-
$parser->filterBodyNodes($input);
|
103 |
-
}
|
104 |
-
|
105 |
-
public function getFilterBodyNodesDataThrowsException()
|
106 |
-
{
|
107 |
-
return [
|
108 |
-
[new TextNode('foo', 1)],
|
109 |
-
[new Node([new Node([new TextNode('foo', 1)])])],
|
110 |
-
];
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @dataProvider getFilterBodyNodesWithBOMData
|
115 |
-
*/
|
116 |
-
public function testFilterBodyNodesWithBOM($emptyNode)
|
117 |
-
{
|
118 |
-
$this->assertNull($this->getParser()->filterBodyNodes(new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$emptyNode, 1)));
|
119 |
-
}
|
120 |
-
|
121 |
-
public function getFilterBodyNodesWithBOMData()
|
122 |
-
{
|
123 |
-
return [
|
124 |
-
[' '],
|
125 |
-
["\t"],
|
126 |
-
["\n"],
|
127 |
-
["\n\t\n "],
|
128 |
-
];
|
129 |
-
}
|
130 |
-
|
131 |
-
public function testParseIsReentrant()
|
132 |
-
{
|
133 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
|
134 |
-
'autoescape' => false,
|
135 |
-
'optimizations' => 0,
|
136 |
-
]);
|
137 |
-
$twig->addTokenParser(new TestTokenParser());
|
138 |
-
|
139 |
-
$parser = new Parser($twig);
|
140 |
-
|
141 |
-
$parser->parse(new TokenStream([
|
142 |
-
new Token(Token::BLOCK_START_TYPE, '', 1),
|
143 |
-
new Token(Token::NAME_TYPE, 'test', 1),
|
144 |
-
new Token(Token::BLOCK_END_TYPE, '', 1),
|
145 |
-
new Token(Token::VAR_START_TYPE, '', 1),
|
146 |
-
new Token(Token::NAME_TYPE, 'foo', 1),
|
147 |
-
new Token(Token::VAR_END_TYPE, '', 1),
|
148 |
-
new Token(Token::EOF_TYPE, '', 1),
|
149 |
-
]));
|
150 |
-
|
151 |
-
$this->assertNull($parser->getParent());
|
152 |
-
}
|
153 |
-
|
154 |
-
public function testGetVarName()
|
155 |
-
{
|
156 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'), [
|
157 |
-
'autoescape' => false,
|
158 |
-
'optimizations' => 0,
|
159 |
-
]);
|
160 |
-
|
161 |
-
$twig->parse($twig->tokenize(new Source(<<<EOF
|
162 |
-
{% from _self import foo %}
|
163 |
-
|
164 |
-
{% macro foo() %}
|
165 |
-
{{ foo }}
|
166 |
-
{% endmacro %}
|
167 |
-
EOF
|
168 |
-
, 'index')));
|
169 |
-
|
170 |
-
// The getVarName() must not depend on the template loaders,
|
171 |
-
// If this test does not throw any exception, that's good.
|
172 |
-
// see https://github.com/symfony/symfony/issues/4218
|
173 |
-
$this->addToAssertionCount(1);
|
174 |
-
}
|
175 |
-
|
176 |
-
protected function getParser()
|
177 |
-
{
|
178 |
-
$parser = new TestParser(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
179 |
-
$parser->setParent(new Node());
|
180 |
-
$parser->stream = new TokenStream([]);
|
181 |
-
|
182 |
-
return $parser;
|
183 |
-
}
|
184 |
-
}
|
185 |
-
|
186 |
-
class TestParser extends Parser
|
187 |
-
{
|
188 |
-
public $stream;
|
189 |
-
|
190 |
-
public function filterBodyNodes(\Twig_NodeInterface $node)
|
191 |
-
{
|
192 |
-
return parent::filterBodyNodes($node);
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
class TestTokenParser extends AbstractTokenParser
|
197 |
-
{
|
198 |
-
public function parse(Token $token)
|
199 |
-
{
|
200 |
-
// simulate the parsing of another template right in the middle of the parsing of the current template
|
201 |
-
$this->parser->parse(new TokenStream([
|
202 |
-
new Token(Token::BLOCK_START_TYPE, '', 1),
|
203 |
-
new Token(Token::NAME_TYPE, 'extends', 1),
|
204 |
-
new Token(Token::STRING_TYPE, 'base', 1),
|
205 |
-
new Token(Token::BLOCK_END_TYPE, '', 1),
|
206 |
-
new Token(Token::EOF_TYPE, '', 1),
|
207 |
-
]));
|
208 |
-
|
209 |
-
$this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
|
210 |
-
|
211 |
-
return new Node([]);
|
212 |
-
}
|
213 |
-
|
214 |
-
public function getTag()
|
215 |
-
{
|
216 |
-
return 'test';
|
217 |
-
}
|
218 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Profiler/Dumper/AbstractTest.php
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Profiler\Dumper;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Profiler\Profile;
|
15 |
-
|
16 |
-
abstract class AbstractTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
protected function getProfile()
|
19 |
-
{
|
20 |
-
$profile = new Profile('main');
|
21 |
-
$subProfiles = [
|
22 |
-
$this->getIndexProfile(
|
23 |
-
[
|
24 |
-
$this->getEmbeddedBlockProfile(),
|
25 |
-
$this->getEmbeddedTemplateProfile(
|
26 |
-
[
|
27 |
-
$this->getIncludedTemplateProfile(),
|
28 |
-
]
|
29 |
-
),
|
30 |
-
$this->getMacroProfile(),
|
31 |
-
$this->getEmbeddedTemplateProfile(
|
32 |
-
[
|
33 |
-
$this->getIncludedTemplateProfile(),
|
34 |
-
]
|
35 |
-
),
|
36 |
-
]
|
37 |
-
),
|
38 |
-
];
|
39 |
-
|
40 |
-
$p = new \ReflectionProperty($profile, 'profiles');
|
41 |
-
$p->setAccessible(true);
|
42 |
-
$p->setValue($profile, $subProfiles);
|
43 |
-
|
44 |
-
return $profile;
|
45 |
-
}
|
46 |
-
|
47 |
-
private function getIndexProfile(array $subProfiles = [])
|
48 |
-
{
|
49 |
-
return $this->generateProfile('main', 1, 'template', 'index.twig', $subProfiles);
|
50 |
-
}
|
51 |
-
|
52 |
-
private function getEmbeddedBlockProfile(array $subProfiles = [])
|
53 |
-
{
|
54 |
-
return $this->generateProfile('body', 0.0001, 'block', 'embedded.twig', $subProfiles);
|
55 |
-
}
|
56 |
-
|
57 |
-
private function getEmbeddedTemplateProfile(array $subProfiles = [])
|
58 |
-
{
|
59 |
-
return $this->generateProfile('main', 0.0001, 'template', 'embedded.twig', $subProfiles);
|
60 |
-
}
|
61 |
-
|
62 |
-
private function getIncludedTemplateProfile(array $subProfiles = [])
|
63 |
-
{
|
64 |
-
return $this->generateProfile('main', 0.0001, 'template', 'included.twig', $subProfiles);
|
65 |
-
}
|
66 |
-
|
67 |
-
private function getMacroProfile(array $subProfiles = [])
|
68 |
-
{
|
69 |
-
return $this->generateProfile('foo', 0.0001, 'macro', 'index.twig', $subProfiles);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* @param string $name
|
74 |
-
* @param float $duration
|
75 |
-
* @param bool $isTemplate
|
76 |
-
* @param string $type
|
77 |
-
* @param string $templateName
|
78 |
-
* @param array $subProfiles
|
79 |
-
*
|
80 |
-
* @return Profile
|
81 |
-
*/
|
82 |
-
private function generateProfile($name, $duration, $type, $templateName, array $subProfiles = [])
|
83 |
-
{
|
84 |
-
$profile = new Profile($templateName, $type, $name);
|
85 |
-
|
86 |
-
$p = new \ReflectionProperty($profile, 'profiles');
|
87 |
-
$p->setAccessible(true);
|
88 |
-
$p->setValue($profile, $subProfiles);
|
89 |
-
|
90 |
-
$starts = new \ReflectionProperty($profile, 'starts');
|
91 |
-
$starts->setAccessible(true);
|
92 |
-
$starts->setValue($profile, [
|
93 |
-
'wt' => 0,
|
94 |
-
'mu' => 0,
|
95 |
-
'pmu' => 0,
|
96 |
-
]);
|
97 |
-
$ends = new \ReflectionProperty($profile, 'ends');
|
98 |
-
$ends->setAccessible(true);
|
99 |
-
$ends->setValue($profile, [
|
100 |
-
'wt' => $duration,
|
101 |
-
'mu' => 0,
|
102 |
-
'pmu' => 0,
|
103 |
-
]);
|
104 |
-
|
105 |
-
return $profile;
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Profiler/Dumper/BlackfireTest.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Profiler\Dumper;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Profiler\Dumper\BlackfireDumper;
|
15 |
-
|
16 |
-
class BlackfireTest extends AbstractTest
|
17 |
-
{
|
18 |
-
public function testDump()
|
19 |
-
{
|
20 |
-
$dumper = new BlackfireDumper();
|
21 |
-
|
22 |
-
$this->assertStringMatchesFormat(<<<EOF
|
23 |
-
file-format: BlackfireProbe
|
24 |
-
cost-dimensions: wt mu pmu
|
25 |
-
request-start: %d.%d
|
26 |
-
|
27 |
-
main()//1 %d %d %d
|
28 |
-
main()==>index.twig//1 %d %d %d
|
29 |
-
index.twig==>embedded.twig::block(body)//1 %d %d 0
|
30 |
-
index.twig==>embedded.twig//2 %d %d %d
|
31 |
-
embedded.twig==>included.twig//2 %d %d %d
|
32 |
-
index.twig==>index.twig::macro(foo)//1 %d %d %d
|
33 |
-
EOF
|
34 |
-
, $dumper->dump($this->getProfile()));
|
35 |
-
}
|
36 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Profiler/Dumper/HtmlTest.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Profiler\Dumper;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Profiler\Dumper\HtmlDumper;
|
15 |
-
|
16 |
-
class HtmlTest extends AbstractTest
|
17 |
-
{
|
18 |
-
public function testDump()
|
19 |
-
{
|
20 |
-
$dumper = new HtmlDumper();
|
21 |
-
$this->assertStringMatchesFormat(<<<EOF
|
22 |
-
<pre>main <span style="color: #d44">%d.%dms/%d%</span>
|
23 |
-
└ <span style="background-color: #ffd">index.twig</span> <span style="color: #d44">%d.%dms/%d%</span>
|
24 |
-
└ embedded.twig::block(<span style="background-color: #dfd">body</span>)
|
25 |
-
└ <span style="background-color: #ffd">embedded.twig</span>
|
26 |
-
│ └ <span style="background-color: #ffd">included.twig</span>
|
27 |
-
└ index.twig::macro(<span style="background-color: #ddf">foo</span>)
|
28 |
-
└ <span style="background-color: #ffd">embedded.twig</span>
|
29 |
-
└ <span style="background-color: #ffd">included.twig</span>
|
30 |
-
</pre>
|
31 |
-
EOF
|
32 |
-
, $dumper->dump($this->getProfile()));
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Profiler/Dumper/TextTest.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Profiler\Dumper;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Profiler\Dumper\TextDumper;
|
15 |
-
|
16 |
-
class TextTest extends AbstractTest
|
17 |
-
{
|
18 |
-
public function testDump()
|
19 |
-
{
|
20 |
-
$dumper = new TextDumper();
|
21 |
-
$this->assertStringMatchesFormat(<<<EOF
|
22 |
-
main %d.%dms/%d%
|
23 |
-
└ index.twig %d.%dms/%d%
|
24 |
-
└ embedded.twig::block(body)
|
25 |
-
└ embedded.twig
|
26 |
-
│ └ included.twig
|
27 |
-
└ index.twig::macro(foo)
|
28 |
-
└ embedded.twig
|
29 |
-
└ included.twig
|
30 |
-
|
31 |
-
EOF
|
32 |
-
, $dumper->dump($this->getProfile()));
|
33 |
-
}
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Profiler/ProfileTest.php
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Profiler;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Profiler\Profile;
|
15 |
-
|
16 |
-
class ProfileTest extends \PHPUnit\Framework\TestCase
|
17 |
-
{
|
18 |
-
public function testConstructor()
|
19 |
-
{
|
20 |
-
$profile = new Profile('template', 'type', 'name');
|
21 |
-
|
22 |
-
$this->assertEquals('template', $profile->getTemplate());
|
23 |
-
$this->assertEquals('type', $profile->getType());
|
24 |
-
$this->assertEquals('name', $profile->getName());
|
25 |
-
}
|
26 |
-
|
27 |
-
public function testIsRoot()
|
28 |
-
{
|
29 |
-
$profile = new Profile('template', Profile::ROOT);
|
30 |
-
$this->assertTrue($profile->isRoot());
|
31 |
-
|
32 |
-
$profile = new Profile('template', Profile::TEMPLATE);
|
33 |
-
$this->assertFalse($profile->isRoot());
|
34 |
-
}
|
35 |
-
|
36 |
-
public function testIsTemplate()
|
37 |
-
{
|
38 |
-
$profile = new Profile('template', Profile::TEMPLATE);
|
39 |
-
$this->assertTrue($profile->isTemplate());
|
40 |
-
|
41 |
-
$profile = new Profile('template', Profile::ROOT);
|
42 |
-
$this->assertFalse($profile->isTemplate());
|
43 |
-
}
|
44 |
-
|
45 |
-
public function testIsBlock()
|
46 |
-
{
|
47 |
-
$profile = new Profile('template', Profile::BLOCK);
|
48 |
-
$this->assertTrue($profile->isBlock());
|
49 |
-
|
50 |
-
$profile = new Profile('template', Profile::ROOT);
|
51 |
-
$this->assertFalse($profile->isBlock());
|
52 |
-
}
|
53 |
-
|
54 |
-
public function testIsMacro()
|
55 |
-
{
|
56 |
-
$profile = new Profile('template', Profile::MACRO);
|
57 |
-
$this->assertTrue($profile->isMacro());
|
58 |
-
|
59 |
-
$profile = new Profile('template', Profile::ROOT);
|
60 |
-
$this->assertFalse($profile->isMacro());
|
61 |
-
}
|
62 |
-
|
63 |
-
public function testGetAddProfile()
|
64 |
-
{
|
65 |
-
$profile = new Profile();
|
66 |
-
$profile->addProfile($a = new Profile());
|
67 |
-
$profile->addProfile($b = new Profile());
|
68 |
-
|
69 |
-
$this->assertSame([$a, $b], $profile->getProfiles());
|
70 |
-
$this->assertSame([$a, $b], iterator_to_array($profile));
|
71 |
-
}
|
72 |
-
|
73 |
-
public function testGetDuration()
|
74 |
-
{
|
75 |
-
$profile = new Profile();
|
76 |
-
usleep(1);
|
77 |
-
$profile->leave();
|
78 |
-
|
79 |
-
$this->assertTrue($profile->getDuration() > 0, sprintf('Expected duration > 0, got: %f', $profile->getDuration()));
|
80 |
-
}
|
81 |
-
|
82 |
-
public function testSerialize()
|
83 |
-
{
|
84 |
-
$profile = new Profile('template', 'type', 'name');
|
85 |
-
$profile1 = new Profile('template1', 'type1', 'name1');
|
86 |
-
$profile->addProfile($profile1);
|
87 |
-
$profile->leave();
|
88 |
-
$profile1->leave();
|
89 |
-
|
90 |
-
$profile2 = unserialize(serialize($profile));
|
91 |
-
$profiles = $profile->getProfiles();
|
92 |
-
$this->assertCount(1, $profiles);
|
93 |
-
$profile3 = $profiles[0];
|
94 |
-
|
95 |
-
$this->assertEquals($profile->getTemplate(), $profile2->getTemplate());
|
96 |
-
$this->assertEquals($profile->getType(), $profile2->getType());
|
97 |
-
$this->assertEquals($profile->getName(), $profile2->getName());
|
98 |
-
$this->assertEquals($profile->getDuration(), $profile2->getDuration());
|
99 |
-
|
100 |
-
$this->assertEquals($profile1->getTemplate(), $profile3->getTemplate());
|
101 |
-
$this->assertEquals($profile1->getType(), $profile3->getType());
|
102 |
-
$this->assertEquals($profile1->getName(), $profile3->getName());
|
103 |
-
}
|
104 |
-
|
105 |
-
public function testReset()
|
106 |
-
{
|
107 |
-
$profile = new Profile();
|
108 |
-
usleep(1);
|
109 |
-
$profile->leave();
|
110 |
-
$profile->reset();
|
111 |
-
|
112 |
-
$this->assertEquals(0, $profile->getDuration());
|
113 |
-
}
|
114 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/TemplateTest.php
DELETED
@@ -1,809 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Error\RuntimeError;
|
16 |
-
use Twig\Extension\SandboxExtension;
|
17 |
-
use Twig\Loader\ArrayLoader;
|
18 |
-
use Twig\Loader\LoaderInterface;
|
19 |
-
use Twig\Loader\SourceContextLoaderInterface;
|
20 |
-
use Twig\Node\Expression\GetAttrExpression;
|
21 |
-
use Twig\NodeVisitor\NodeVisitorInterface;
|
22 |
-
use Twig\Sandbox\SecurityError;
|
23 |
-
use Twig\Sandbox\SecurityPolicy;
|
24 |
-
use Twig\Template;
|
25 |
-
|
26 |
-
class TemplateTest extends \PHPUnit\Framework\TestCase
|
27 |
-
{
|
28 |
-
public function testDisplayBlocksAcceptTemplateOnlyAsBlocks()
|
29 |
-
{
|
30 |
-
$this->expectException('\LogicException');
|
31 |
-
|
32 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
33 |
-
$template = new TemplateForTest($twig);
|
34 |
-
$template->displayBlock('foo', [], ['foo' => [new \stdClass(), 'foo']]);
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @dataProvider getAttributeExceptions
|
39 |
-
*/
|
40 |
-
public function testGetAttributeExceptions($template, $message)
|
41 |
-
{
|
42 |
-
$templates = ['index' => $template];
|
43 |
-
$env = new Environment(new ArrayLoader($templates), ['strict_variables' => true]);
|
44 |
-
$template = $env->load('index');
|
45 |
-
|
46 |
-
$context = [
|
47 |
-
'string' => 'foo',
|
48 |
-
'null' => null,
|
49 |
-
'empty_array' => [],
|
50 |
-
'array' => ['foo' => 'foo'],
|
51 |
-
'array_access' => new TemplateArrayAccessObject(),
|
52 |
-
'magic_exception' => new TemplateMagicPropertyObjectWithException(),
|
53 |
-
'object' => new \stdClass(),
|
54 |
-
];
|
55 |
-
|
56 |
-
try {
|
57 |
-
$template->render($context);
|
58 |
-
$this->fail('Accessing an invalid attribute should throw an exception.');
|
59 |
-
} catch (RuntimeError $e) {
|
60 |
-
$this->assertSame(sprintf($message, 'index'), $e->getMessage());
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
public function getAttributeExceptions()
|
65 |
-
{
|
66 |
-
return [
|
67 |
-
['{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'],
|
68 |
-
['{{ null["a"] }}', 'Impossible to access a key ("a") on a null variable in "%s" at line 1.'],
|
69 |
-
['{{ empty_array["a"] }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'],
|
70 |
-
['{{ array["a"] }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'],
|
71 |
-
['{{ array_access["a"] }}', 'Key "a" in object with ArrayAccess of class "Twig\Tests\TemplateArrayAccessObject" does not exist in "%s" at line 1.'],
|
72 |
-
['{{ string.a }}', 'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1.'],
|
73 |
-
['{{ string.a() }}', 'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1.'],
|
74 |
-
['{{ null.a }}', 'Impossible to access an attribute ("a") on a null variable in "%s" at line 1.'],
|
75 |
-
['{{ null.a() }}', 'Impossible to invoke a method ("a") on a null variable in "%s" at line 1.'],
|
76 |
-
['{{ array.a() }}', 'Impossible to invoke a method ("a") on an array in "%s" at line 1.'],
|
77 |
-
['{{ empty_array.a }}', 'Key "a" does not exist as the array is empty in "%s" at line 1.'],
|
78 |
-
['{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1.'],
|
79 |
-
['{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1.'],
|
80 |
-
['{{ array_access.a }}', 'Neither the property "a" nor one of the methods "a()", "geta()"/"isa()" or "__call()" exist and have public access in class "Twig\Tests\TemplateArrayAccessObject" in "%s" at line 1.'],
|
81 |
-
['{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Neither the property "missing_method" nor one of the methods "missing_method()", "getmissing_method()"/"ismissing_method()" or "__call()" exist and have public access in class "Twig\Tests\TemplateArrayAccessObject" in "%s" at line 1.'],
|
82 |
-
['{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.'],
|
83 |
-
['{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1.'],
|
84 |
-
];
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @dataProvider getGetAttributeWithSandbox
|
89 |
-
*/
|
90 |
-
public function testGetAttributeWithSandbox($object, $item, $allowed)
|
91 |
-
{
|
92 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
93 |
-
$policy = new SecurityPolicy([], [], [/*method*/], [/*prop*/], []);
|
94 |
-
$twig->addExtension(new SandboxExtension($policy, !$allowed));
|
95 |
-
$template = new TemplateForTest($twig);
|
96 |
-
|
97 |
-
try {
|
98 |
-
$template->getAttribute($object, $item, [], 'any');
|
99 |
-
|
100 |
-
if (!$allowed) {
|
101 |
-
$this->fail();
|
102 |
-
} else {
|
103 |
-
$this->addToAssertionCount(1);
|
104 |
-
}
|
105 |
-
} catch (SecurityError $e) {
|
106 |
-
if ($allowed) {
|
107 |
-
$this->fail();
|
108 |
-
} else {
|
109 |
-
$this->addToAssertionCount(1);
|
110 |
-
}
|
111 |
-
|
112 |
-
$this->assertStringContainsString('is not allowed', $e->getMessage());
|
113 |
-
}
|
114 |
-
}
|
115 |
-
|
116 |
-
public function getGetAttributeWithSandbox()
|
117 |
-
{
|
118 |
-
return [
|
119 |
-
[new TemplatePropertyObject(), 'defined', false],
|
120 |
-
[new TemplatePropertyObject(), 'defined', true],
|
121 |
-
[new TemplateMethodObject(), 'defined', false],
|
122 |
-
[new TemplateMethodObject(), 'defined', true],
|
123 |
-
];
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @group legacy
|
128 |
-
*/
|
129 |
-
public function testGetAttributeWithTemplateAsObject()
|
130 |
-
{
|
131 |
-
// to be removed in 2.0
|
132 |
-
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
|
133 |
-
//$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
|
134 |
-
|
135 |
-
$template = new TemplateForTest($twig, 'index.twig');
|
136 |
-
$template1 = new TemplateForTest($twig, 'index1.twig');
|
137 |
-
|
138 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'string'));
|
139 |
-
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
140 |
-
|
141 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'true'));
|
142 |
-
$this->assertEquals('1', $template->getAttribute($template1, 'true'));
|
143 |
-
|
144 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'zero'));
|
145 |
-
$this->assertEquals('0', $template->getAttribute($template1, 'zero'));
|
146 |
-
|
147 |
-
$this->assertNotInstanceof('\Twig\Markup', $template->getAttribute($template1, 'empty'));
|
148 |
-
$this->assertSame('', $template->getAttribute($template1, 'empty'));
|
149 |
-
|
150 |
-
$this->assertFalse($template->getAttribute($template1, 'env', [], Template::ANY_CALL, true));
|
151 |
-
$this->assertFalse($template->getAttribute($template1, 'environment', [], Template::ANY_CALL, true));
|
152 |
-
$this->assertFalse($template->getAttribute($template1, 'getEnvironment', [], Template::METHOD_CALL, true));
|
153 |
-
$this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', [], Template::METHOD_CALL, true));
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* @group legacy
|
158 |
-
* @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
159 |
-
* @expectedDeprecation Calling "string" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
160 |
-
* @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
161 |
-
* @expectedDeprecation Calling "true" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
162 |
-
* @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
163 |
-
* @expectedDeprecation Calling "zero" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
164 |
-
* @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
165 |
-
* @expectedDeprecation Calling "empty" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0.
|
166 |
-
* @expectedDeprecation Calling "renderBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
167 |
-
* @expectedDeprecation Calling "displayBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name") instead).
|
168 |
-
* @expectedDeprecation Calling "hasBlock" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name") is defined" instead).
|
169 |
-
* @expectedDeprecation Calling "render" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead).
|
170 |
-
* @expectedDeprecation Calling "display" on template "index.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index.twig") instead).
|
171 |
-
* @expectedDeprecation Calling "renderBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead).
|
172 |
-
* @expectedDeprecation Calling "displayBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use block("name", template) instead).
|
173 |
-
* @expectedDeprecation Calling "hasBlock" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use "block("name", template) is defined" instead).
|
174 |
-
* @expectedDeprecation Calling "render" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead).
|
175 |
-
* @expectedDeprecation Calling "display" on template "index1.twig" from template "index.twig" is deprecated since version 1.28 and won't be supported anymore in 2.0. Use include("index1.twig") instead).
|
176 |
-
*/
|
177 |
-
public function testGetAttributeWithTemplateAsObjectForDeprecations()
|
178 |
-
{
|
179 |
-
// to be removed in 2.0
|
180 |
-
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
|
181 |
-
//$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface', '\Twig\Loader\SourceContextLoaderInterface'));
|
182 |
-
|
183 |
-
$template = new TemplateForTest($twig, 'index.twig');
|
184 |
-
$template1 = new TemplateForTest($twig, 'index1.twig');
|
185 |
-
|
186 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'string'));
|
187 |
-
$this->assertEquals('some_string', $template->getAttribute($template1, 'string'));
|
188 |
-
|
189 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'true'));
|
190 |
-
$this->assertEquals('1', $template->getAttribute($template1, 'true'));
|
191 |
-
|
192 |
-
$this->assertInstanceOf('\Twig\Markup', $template->getAttribute($template1, 'zero'));
|
193 |
-
$this->assertEquals('0', $template->getAttribute($template1, 'zero'));
|
194 |
-
|
195 |
-
$this->assertNotInstanceof('\Twig\Markup', $template->getAttribute($template1, 'empty'));
|
196 |
-
$this->assertSame('', $template->getAttribute($template1, 'empty'));
|
197 |
-
|
198 |
-
$blocks = ['name' => [$template1, 'block_name']];
|
199 |
-
|
200 |
-
// trigger some deprecation notice messages to check them with @expectedDeprecation
|
201 |
-
$template->getAttribute($template, 'renderBlock', ['name', [], $blocks]);
|
202 |
-
$template->getAttribute($template, 'displayBlock', ['name', [], $blocks]);
|
203 |
-
$template->getAttribute($template, 'hasBlock', ['name', []]);
|
204 |
-
$template->getAttribute($template, 'render', [[]]);
|
205 |
-
$template->getAttribute($template, 'display', [[]]);
|
206 |
-
|
207 |
-
$template->getAttribute($template1, 'renderBlock', ['name', [], $blocks]);
|
208 |
-
$template->getAttribute($template1, 'displayBlock', ['name', [], $blocks]);
|
209 |
-
$template->getAttribute($template1, 'hasBlock', ['name', []]);
|
210 |
-
$template->getAttribute($template1, 'render', [[]]);
|
211 |
-
$template->getAttribute($template1, 'display', [[]]);
|
212 |
-
|
213 |
-
$this->assertFalse($template->getAttribute($template1, 'env', [], Template::ANY_CALL, true));
|
214 |
-
$this->assertFalse($template->getAttribute($template1, 'environment', [], Template::ANY_CALL, true));
|
215 |
-
$this->assertFalse($template->getAttribute($template1, 'getEnvironment', [], Template::METHOD_CALL, true));
|
216 |
-
$this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', [], Template::METHOD_CALL, true));
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* @group legacy
|
221 |
-
* @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
|
222 |
-
* @expectedDeprecation Silent display of undefined block "unknown" in template "index.twig" is deprecated since version 1.29 and will throw an exception in 2.0. Use the "block('unknown') is defined" expression to test for block existence.
|
223 |
-
*/
|
224 |
-
public function testRenderBlockWithUndefinedBlock()
|
225 |
-
{
|
226 |
-
$twig = new Environment($this->createMock('Twig\Tests\TemplateTestLoaderInterface'));
|
227 |
-
|
228 |
-
$template = new TemplateForTest($twig, 'index.twig');
|
229 |
-
$template->renderBlock('unknown', []);
|
230 |
-
$template->displayBlock('unknown', []);
|
231 |
-
}
|
232 |
-
|
233 |
-
public function testGetAttributeOnArrayWithConfusableKey()
|
234 |
-
{
|
235 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
236 |
-
|
237 |
-
$array = ['Zero', 'One', -1 => 'MinusOne', '' => 'EmptyString', '1.5' => 'FloatButString', '01' => 'IntegerButStringWithLeadingZeros'];
|
238 |
-
|
239 |
-
$this->assertSame('Zero', $array[false]);
|
240 |
-
$this->assertSame('One', $array[true]);
|
241 |
-
$this->assertSame('One', $array[1.5]);
|
242 |
-
$this->assertSame('One', $array['1']);
|
243 |
-
$this->assertSame('MinusOne', $array[-1.5]);
|
244 |
-
$this->assertSame('FloatButString', $array['1.5']);
|
245 |
-
$this->assertSame('IntegerButStringWithLeadingZeros', $array['01']);
|
246 |
-
$this->assertSame('EmptyString', $array[null]);
|
247 |
-
|
248 |
-
$this->assertSame('Zero', $template->getAttribute($array, false), 'false is treated as 0 when accessing an array (equals PHP behavior)');
|
249 |
-
$this->assertSame('One', $template->getAttribute($array, true), 'true is treated as 1 when accessing an array (equals PHP behavior)');
|
250 |
-
$this->assertSame('One', $template->getAttribute($array, 1.5), 'float is casted to int when accessing an array (equals PHP behavior)');
|
251 |
-
$this->assertSame('One', $template->getAttribute($array, '1'), '"1" is treated as integer 1 when accessing an array (equals PHP behavior)');
|
252 |
-
$this->assertSame('MinusOne', $template->getAttribute($array, -1.5), 'negative float is casted to int when accessing an array (equals PHP behavior)');
|
253 |
-
$this->assertSame('FloatButString', $template->getAttribute($array, '1.5'), '"1.5" is treated as-is when accessing an array (equals PHP behavior)');
|
254 |
-
$this->assertSame('IntegerButStringWithLeadingZeros', $template->getAttribute($array, '01'), '"01" is treated as-is when accessing an array (equals PHP behavior)');
|
255 |
-
$this->assertSame('EmptyString', $template->getAttribute($array, null), 'null is treated as "" when accessing an array (equals PHP behavior)');
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* @dataProvider getGetAttributeTests
|
260 |
-
*/
|
261 |
-
public function testGetAttribute($defined, $value, $object, $item, $arguments, $type)
|
262 |
-
{
|
263 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
264 |
-
|
265 |
-
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
266 |
-
}
|
267 |
-
|
268 |
-
/**
|
269 |
-
* @dataProvider getGetAttributeTests
|
270 |
-
*/
|
271 |
-
public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $exceptionMessage = null)
|
272 |
-
{
|
273 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
|
274 |
-
|
275 |
-
if ($defined) {
|
276 |
-
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
277 |
-
} else {
|
278 |
-
$this->expectException('\Twig\Error\RuntimeError');
|
279 |
-
if (null !== $exceptionMessage) {
|
280 |
-
$this->expectExceptionMessage($exceptionMessage);
|
281 |
-
}
|
282 |
-
$this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type));
|
283 |
-
}
|
284 |
-
}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* @dataProvider getGetAttributeTests
|
288 |
-
*/
|
289 |
-
public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type)
|
290 |
-
{
|
291 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
292 |
-
|
293 |
-
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
294 |
-
}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* @dataProvider getGetAttributeTests
|
298 |
-
*/
|
299 |
-
public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type)
|
300 |
-
{
|
301 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
|
302 |
-
|
303 |
-
$this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true));
|
304 |
-
}
|
305 |
-
|
306 |
-
public function testGetAttributeCallExceptions()
|
307 |
-
{
|
308 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface')));
|
309 |
-
|
310 |
-
$object = new TemplateMagicMethodExceptionObject();
|
311 |
-
|
312 |
-
$this->assertNull($template->getAttribute($object, 'foo'));
|
313 |
-
}
|
314 |
-
|
315 |
-
public function getGetAttributeTests()
|
316 |
-
{
|
317 |
-
$array = [
|
318 |
-
'defined' => 'defined',
|
319 |
-
'zero' => 0,
|
320 |
-
'null' => null,
|
321 |
-
'1' => 1,
|
322 |
-
'bar' => true,
|
323 |
-
'baz' => 'baz',
|
324 |
-
'09' => '09',
|
325 |
-
'+4' => '+4',
|
326 |
-
];
|
327 |
-
|
328 |
-
$objectArray = new TemplateArrayAccessObject();
|
329 |
-
$arrayObject = new \ArrayObject($array);
|
330 |
-
$stdObject = (object) $array;
|
331 |
-
$magicPropertyObject = new TemplateMagicPropertyObject();
|
332 |
-
$propertyObject = new TemplatePropertyObject();
|
333 |
-
$propertyObject1 = new TemplatePropertyObjectAndIterator();
|
334 |
-
$propertyObject2 = new TemplatePropertyObjectAndArrayAccess();
|
335 |
-
$propertyObject3 = new TemplatePropertyObjectDefinedWithUndefinedValue();
|
336 |
-
$methodObject = new TemplateMethodObject();
|
337 |
-
$magicMethodObject = new TemplateMagicMethodObject();
|
338 |
-
|
339 |
-
$anyType = Template::ANY_CALL;
|
340 |
-
$methodType = Template::METHOD_CALL;
|
341 |
-
$arrayType = Template::ARRAY_CALL;
|
342 |
-
|
343 |
-
$basicTests = [
|
344 |
-
// array(defined, value, property to fetch)
|
345 |
-
[true, 'defined', 'defined'],
|
346 |
-
[false, null, 'undefined'],
|
347 |
-
[false, null, 'protected'],
|
348 |
-
[true, 0, 'zero'],
|
349 |
-
[true, 1, 1],
|
350 |
-
[true, 1, 1.0],
|
351 |
-
[true, null, 'null'],
|
352 |
-
[true, true, 'bar'],
|
353 |
-
[true, 'baz', 'baz'],
|
354 |
-
[true, '09', '09'],
|
355 |
-
[true, '+4', '+4'],
|
356 |
-
];
|
357 |
-
$testObjects = [
|
358 |
-
// array(object, type of fetch)
|
359 |
-
[$array, $arrayType],
|
360 |
-
[$objectArray, $arrayType],
|
361 |
-
[$arrayObject, $anyType],
|
362 |
-
[$stdObject, $anyType],
|
363 |
-
[$magicPropertyObject, $anyType],
|
364 |
-
[$methodObject, $methodType],
|
365 |
-
[$methodObject, $anyType],
|
366 |
-
[$propertyObject, $anyType],
|
367 |
-
[$propertyObject1, $anyType],
|
368 |
-
[$propertyObject2, $anyType],
|
369 |
-
];
|
370 |
-
|
371 |
-
$tests = [];
|
372 |
-
foreach ($testObjects as $testObject) {
|
373 |
-
foreach ($basicTests as $test) {
|
374 |
-
// properties cannot be numbers
|
375 |
-
if (($testObject[0] instanceof \stdClass || $testObject[0] instanceof TemplatePropertyObject) && is_numeric($test[2])) {
|
376 |
-
continue;
|
377 |
-
}
|
378 |
-
|
379 |
-
if ('+4' === $test[2] && $methodObject === $testObject[0]) {
|
380 |
-
continue;
|
381 |
-
}
|
382 |
-
|
383 |
-
$tests[] = [$test[0], $test[1], $testObject[0], $test[2], [], $testObject[1]];
|
384 |
-
}
|
385 |
-
}
|
386 |
-
|
387 |
-
// additional properties tests
|
388 |
-
$tests = array_merge($tests, [
|
389 |
-
[true, null, $propertyObject3, 'foo', [], $anyType],
|
390 |
-
]);
|
391 |
-
|
392 |
-
// additional method tests
|
393 |
-
$tests = array_merge($tests, [
|
394 |
-
[true, 'defined', $methodObject, 'defined', [], $methodType],
|
395 |
-
[true, 'defined', $methodObject, 'DEFINED', [], $methodType],
|
396 |
-
[true, 'defined', $methodObject, 'getDefined', [], $methodType],
|
397 |
-
[true, 'defined', $methodObject, 'GETDEFINED', [], $methodType],
|
398 |
-
[true, 'static', $methodObject, 'static', [], $methodType],
|
399 |
-
[true, 'static', $methodObject, 'getStatic', [], $methodType],
|
400 |
-
|
401 |
-
[true, '__call_undefined', $magicMethodObject, 'undefined', [], $methodType],
|
402 |
-
[true, '__call_UNDEFINED', $magicMethodObject, 'UNDEFINED', [], $methodType],
|
403 |
-
]);
|
404 |
-
|
405 |
-
// add the same tests for the any type
|
406 |
-
foreach ($tests as $test) {
|
407 |
-
if ($anyType !== $test[5]) {
|
408 |
-
$test[5] = $anyType;
|
409 |
-
$tests[] = $test;
|
410 |
-
}
|
411 |
-
}
|
412 |
-
|
413 |
-
$methodAndPropObject = new TemplateMethodAndPropObject();
|
414 |
-
|
415 |
-
// additional method tests
|
416 |
-
$tests = array_merge($tests, [
|
417 |
-
[true, 'a', $methodAndPropObject, 'a', [], $anyType],
|
418 |
-
[true, 'a', $methodAndPropObject, 'a', [], $methodType],
|
419 |
-
[false, null, $methodAndPropObject, 'a', [], $arrayType],
|
420 |
-
|
421 |
-
[true, 'b_prop', $methodAndPropObject, 'b', [], $anyType],
|
422 |
-
[true, 'b', $methodAndPropObject, 'B', [], $anyType],
|
423 |
-
[true, 'b', $methodAndPropObject, 'b', [], $methodType],
|
424 |
-
[true, 'b', $methodAndPropObject, 'B', [], $methodType],
|
425 |
-
[false, null, $methodAndPropObject, 'b', [], $arrayType],
|
426 |
-
|
427 |
-
[false, null, $methodAndPropObject, 'c', [], $anyType],
|
428 |
-
[false, null, $methodAndPropObject, 'c', [], $methodType],
|
429 |
-
[false, null, $methodAndPropObject, 'c', [], $arrayType],
|
430 |
-
]);
|
431 |
-
|
432 |
-
$arrayAccess = new TemplateArrayAccess();
|
433 |
-
$tests = array_merge($tests, [
|
434 |
-
[true, ['foo' => 'bar'], $arrayAccess, 'vars', [], $anyType],
|
435 |
-
]);
|
436 |
-
|
437 |
-
// tests when input is not an array or object
|
438 |
-
$tests = array_merge($tests, [
|
439 |
-
[false, null, 42, 'a', [], $anyType, 'Impossible to access an attribute ("a") on a integer variable ("42") in "index.twig".'],
|
440 |
-
[false, null, 'string', 'a', [], $anyType, 'Impossible to access an attribute ("a") on a string variable ("string") in "index.twig".'],
|
441 |
-
[false, null, [], 'a', [], $anyType, 'Key "a" does not exist as the array is empty in "index.twig".'],
|
442 |
-
]);
|
443 |
-
|
444 |
-
return $tests;
|
445 |
-
}
|
446 |
-
|
447 |
-
public function testGetIsMethods()
|
448 |
-
{
|
449 |
-
$this->expectException('\Twig\Error\RuntimeError');
|
450 |
-
|
451 |
-
$getIsObject = new TemplateGetIsMethods();
|
452 |
-
$template = new TemplateForTest(new Environment($this->createMock('\Twig\Loader\LoaderInterface'), ['strict_variables' => true]));
|
453 |
-
// first time should not create a cache for "get"
|
454 |
-
$this->assertNull($template->getAttribute($getIsObject, 'get'));
|
455 |
-
// 0 should be in the method cache now, so this should fail
|
456 |
-
$this->assertNull($template->getAttribute($getIsObject, 0));
|
457 |
-
}
|
458 |
-
}
|
459 |
-
|
460 |
-
class TemplateForTest extends Template
|
461 |
-
{
|
462 |
-
private $name;
|
463 |
-
|
464 |
-
public function __construct(Environment $env, $name = 'index.twig')
|
465 |
-
{
|
466 |
-
parent::__construct($env);
|
467 |
-
self::$cache = [];
|
468 |
-
$this->name = $name;
|
469 |
-
}
|
470 |
-
|
471 |
-
public function getZero()
|
472 |
-
{
|
473 |
-
return 0;
|
474 |
-
}
|
475 |
-
|
476 |
-
public function getEmpty()
|
477 |
-
{
|
478 |
-
return '';
|
479 |
-
}
|
480 |
-
|
481 |
-
public function getString()
|
482 |
-
{
|
483 |
-
return 'some_string';
|
484 |
-
}
|
485 |
-
|
486 |
-
public function getTrue()
|
487 |
-
{
|
488 |
-
return true;
|
489 |
-
}
|
490 |
-
|
491 |
-
public function getTemplateName()
|
492 |
-
{
|
493 |
-
return $this->name;
|
494 |
-
}
|
495 |
-
|
496 |
-
public function getDebugInfo()
|
497 |
-
{
|
498 |
-
return [];
|
499 |
-
}
|
500 |
-
|
501 |
-
protected function doGetParent(array $context)
|
502 |
-
{
|
503 |
-
return false;
|
504 |
-
}
|
505 |
-
|
506 |
-
protected function doDisplay(array $context, array $blocks = [])
|
507 |
-
{
|
508 |
-
}
|
509 |
-
|
510 |
-
public function getAttribute($object, $item, array $arguments = [], $type = Template::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
511 |
-
{
|
512 |
-
if (\function_exists('twig_template_get_attributes')) {
|
513 |
-
return twig_template_get_attributes($this, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
514 |
-
} else {
|
515 |
-
return parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
|
516 |
-
}
|
517 |
-
}
|
518 |
-
|
519 |
-
public function block_name($context, array $blocks = [])
|
520 |
-
{
|
521 |
-
}
|
522 |
-
}
|
523 |
-
|
524 |
-
class TemplateArrayAccessObject implements \ArrayAccess
|
525 |
-
{
|
526 |
-
protected $protected = 'protected';
|
527 |
-
|
528 |
-
public $attributes = [
|
529 |
-
'defined' => 'defined',
|
530 |
-
'zero' => 0,
|
531 |
-
'null' => null,
|
532 |
-
'1' => 1,
|
533 |
-
'bar' => true,
|
534 |
-
'baz' => 'baz',
|
535 |
-
'09' => '09',
|
536 |
-
'+4' => '+4',
|
537 |
-
];
|
538 |
-
|
539 |
-
public function offsetExists($name)
|
540 |
-
{
|
541 |
-
return \array_key_exists($name, $this->attributes);
|
542 |
-
}
|
543 |
-
|
544 |
-
public function offsetGet($name)
|
545 |
-
{
|
546 |
-
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null;
|
547 |
-
}
|
548 |
-
|
549 |
-
public function offsetSet($name, $value)
|
550 |
-
{
|
551 |
-
}
|
552 |
-
|
553 |
-
public function offsetUnset($name)
|
554 |
-
{
|
555 |
-
}
|
556 |
-
}
|
557 |
-
|
558 |
-
class TemplateMagicPropertyObject
|
559 |
-
{
|
560 |
-
public $defined = 'defined';
|
561 |
-
|
562 |
-
public $attributes = [
|
563 |
-
'zero' => 0,
|
564 |
-
'null' => null,
|
565 |
-
'1' => 1,
|
566 |
-
'bar' => true,
|
567 |
-
'baz' => 'baz',
|
568 |
-
'09' => '09',
|
569 |
-
'+4' => '+4',
|
570 |
-
];
|
571 |
-
|
572 |
-
protected $protected = 'protected';
|
573 |
-
|
574 |
-
public function __isset($name)
|
575 |
-
{
|
576 |
-
return \array_key_exists($name, $this->attributes);
|
577 |
-
}
|
578 |
-
|
579 |
-
public function __get($name)
|
580 |
-
{
|
581 |
-
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null;
|
582 |
-
}
|
583 |
-
}
|
584 |
-
|
585 |
-
class TemplateMagicPropertyObjectWithException
|
586 |
-
{
|
587 |
-
public function __isset($key)
|
588 |
-
{
|
589 |
-
throw new \Exception('Hey! Don\'t try to isset me!');
|
590 |
-
}
|
591 |
-
}
|
592 |
-
|
593 |
-
class TemplatePropertyObject
|
594 |
-
{
|
595 |
-
public $defined = 'defined';
|
596 |
-
public $zero = 0;
|
597 |
-
public $null = null;
|
598 |
-
public $bar = true;
|
599 |
-
public $baz = 'baz';
|
600 |
-
|
601 |
-
protected $protected = 'protected';
|
602 |
-
}
|
603 |
-
|
604 |
-
class TemplatePropertyObjectAndIterator extends TemplatePropertyObject implements \IteratorAggregate
|
605 |
-
{
|
606 |
-
public function getIterator()
|
607 |
-
{
|
608 |
-
return new \ArrayIterator(['foo', 'bar']);
|
609 |
-
}
|
610 |
-
}
|
611 |
-
|
612 |
-
class TemplatePropertyObjectAndArrayAccess extends TemplatePropertyObject implements \ArrayAccess
|
613 |
-
{
|
614 |
-
private $data = [
|
615 |
-
'defined' => 'defined',
|
616 |
-
'zero' => 0,
|
617 |
-
'null' => null,
|
618 |
-
'bar' => true,
|
619 |
-
'foo' => true,
|
620 |
-
'baz' => 'baz',
|
621 |
-
'baf' => 'baf',
|
622 |
-
];
|
623 |
-
|
624 |
-
public function offsetExists($offset)
|
625 |
-
{
|
626 |
-
return \array_key_exists($offset, $this->data);
|
627 |
-
}
|
628 |
-
|
629 |
-
public function offsetGet($offset)
|
630 |
-
{
|
631 |
-
return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a';
|
632 |
-
}
|
633 |
-
|
634 |
-
public function offsetSet($offset, $value)
|
635 |
-
{
|
636 |
-
}
|
637 |
-
|
638 |
-
public function offsetUnset($offset)
|
639 |
-
{
|
640 |
-
}
|
641 |
-
}
|
642 |
-
|
643 |
-
class TemplatePropertyObjectDefinedWithUndefinedValue
|
644 |
-
{
|
645 |
-
public $foo;
|
646 |
-
|
647 |
-
public function __construct()
|
648 |
-
{
|
649 |
-
$this->foo = @$notExist;
|
650 |
-
}
|
651 |
-
}
|
652 |
-
|
653 |
-
class TemplateMethodObject
|
654 |
-
{
|
655 |
-
public function getDefined()
|
656 |
-
{
|
657 |
-
return 'defined';
|
658 |
-
}
|
659 |
-
|
660 |
-
public function get1()
|
661 |
-
{
|
662 |
-
return 1;
|
663 |
-
}
|
664 |
-
|
665 |
-
public function get09()
|
666 |
-
{
|
667 |
-
return '09';
|
668 |
-
}
|
669 |
-
|
670 |
-
public function getZero()
|
671 |
-
{
|
672 |
-
return 0;
|
673 |
-
}
|
674 |
-
|
675 |
-
public function getNull()
|
676 |
-
{
|
677 |
-
}
|
678 |
-
|
679 |
-
public function isBar()
|
680 |
-
{
|
681 |
-
return true;
|
682 |
-
}
|
683 |
-
|
684 |
-
public function isBaz()
|
685 |
-
{
|
686 |
-
return 'should never be returned';
|
687 |
-
}
|
688 |
-
|
689 |
-
public function getBaz()
|
690 |
-
{
|
691 |
-
return 'baz';
|
692 |
-
}
|
693 |
-
|
694 |
-
protected function getProtected()
|
695 |
-
{
|
696 |
-
return 'protected';
|
697 |
-
}
|
698 |
-
|
699 |
-
public static function getStatic()
|
700 |
-
{
|
701 |
-
return 'static';
|
702 |
-
}
|
703 |
-
}
|
704 |
-
|
705 |
-
class TemplateGetIsMethods
|
706 |
-
{
|
707 |
-
public function get()
|
708 |
-
{
|
709 |
-
}
|
710 |
-
|
711 |
-
public function is()
|
712 |
-
{
|
713 |
-
}
|
714 |
-
}
|
715 |
-
|
716 |
-
class TemplateMethodAndPropObject
|
717 |
-
{
|
718 |
-
private $a = 'a_prop';
|
719 |
-
|
720 |
-
public function getA()
|
721 |
-
{
|
722 |
-
return 'a';
|
723 |
-
}
|
724 |
-
|
725 |
-
public $b = 'b_prop';
|
726 |
-
|
727 |
-
public function getB()
|
728 |
-
{
|
729 |
-
return 'b';
|
730 |
-
}
|
731 |
-
|
732 |
-
private $c = 'c_prop';
|
733 |
-
|
734 |
-
private function getC()
|
735 |
-
{
|
736 |
-
return 'c';
|
737 |
-
}
|
738 |
-
}
|
739 |
-
|
740 |
-
class TemplateArrayAccess implements \ArrayAccess
|
741 |
-
{
|
742 |
-
public $vars = [
|
743 |
-
'foo' => 'bar',
|
744 |
-
];
|
745 |
-
private $children = [];
|
746 |
-
|
747 |
-
public function offsetExists($offset)
|
748 |
-
{
|
749 |
-
return \array_key_exists($offset, $this->children);
|
750 |
-
}
|
751 |
-
|
752 |
-
public function offsetGet($offset)
|
753 |
-
{
|
754 |
-
return $this->children[$offset];
|
755 |
-
}
|
756 |
-
|
757 |
-
public function offsetSet($offset, $value)
|
758 |
-
{
|
759 |
-
$this->children[$offset] = $value;
|
760 |
-
}
|
761 |
-
|
762 |
-
public function offsetUnset($offset)
|
763 |
-
{
|
764 |
-
unset($this->children[$offset]);
|
765 |
-
}
|
766 |
-
}
|
767 |
-
|
768 |
-
class TemplateMagicMethodObject
|
769 |
-
{
|
770 |
-
public function __call($method, $arguments)
|
771 |
-
{
|
772 |
-
return '__call_'.$method;
|
773 |
-
}
|
774 |
-
}
|
775 |
-
|
776 |
-
class TemplateMagicMethodExceptionObject
|
777 |
-
{
|
778 |
-
public function __call($method, $arguments)
|
779 |
-
{
|
780 |
-
throw new \BadMethodCallException(sprintf('Unknown method "%s".', $method));
|
781 |
-
}
|
782 |
-
}
|
783 |
-
|
784 |
-
class CExtDisablingNodeVisitor implements NodeVisitorInterface
|
785 |
-
{
|
786 |
-
public function enterNode(\Twig_NodeInterface $node, Environment $env)
|
787 |
-
{
|
788 |
-
if ($node instanceof GetAttrExpression) {
|
789 |
-
$node->setAttribute('disable_c_ext', true);
|
790 |
-
}
|
791 |
-
|
792 |
-
return $node;
|
793 |
-
}
|
794 |
-
|
795 |
-
public function leaveNode(\Twig_NodeInterface $node, Environment $env)
|
796 |
-
{
|
797 |
-
return $node;
|
798 |
-
}
|
799 |
-
|
800 |
-
public function getPriority()
|
801 |
-
{
|
802 |
-
return 0;
|
803 |
-
}
|
804 |
-
}
|
805 |
-
|
806 |
-
// to be removed in 2.0
|
807 |
-
interface TemplateTestLoaderInterface extends LoaderInterface, SourceContextLoaderInterface
|
808 |
-
{
|
809 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/TemplateWrapperTest.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\Loader\ArrayLoader;
|
16 |
-
|
17 |
-
class TemplateWrapperTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
public function testHasGetBlocks()
|
20 |
-
{
|
21 |
-
$twig = new Environment(new ArrayLoader([
|
22 |
-
'index' => '{% block foo %}{% endblock %}',
|
23 |
-
'index_with_use' => '{% use "imported" %}{% block foo %}{% endblock %}',
|
24 |
-
'index_with_extends' => '{% extends "extended" %}{% block foo %}{% endblock %}',
|
25 |
-
'imported' => '{% block imported %}{% endblock %}',
|
26 |
-
'extended' => '{% block extended %}{% endblock %}',
|
27 |
-
]));
|
28 |
-
|
29 |
-
$wrapper = $twig->load('index');
|
30 |
-
$this->assertTrue($wrapper->hasBlock('foo'));
|
31 |
-
$this->assertFalse($wrapper->hasBlock('bar'));
|
32 |
-
$this->assertEquals(['foo'], $wrapper->getBlockNames());
|
33 |
-
|
34 |
-
$wrapper = $twig->load('index_with_use');
|
35 |
-
$this->assertTrue($wrapper->hasBlock('foo'));
|
36 |
-
$this->assertTrue($wrapper->hasBlock('imported'));
|
37 |
-
$this->assertEquals(['imported', 'foo'], $wrapper->getBlockNames());
|
38 |
-
|
39 |
-
$wrapper = $twig->load('index_with_extends');
|
40 |
-
$this->assertTrue($wrapper->hasBlock('foo'));
|
41 |
-
$this->assertTrue($wrapper->hasBlock('extended'));
|
42 |
-
$this->assertEquals(['foo', 'extended'], $wrapper->getBlockNames());
|
43 |
-
}
|
44 |
-
|
45 |
-
public function testRenderBlock()
|
46 |
-
{
|
47 |
-
$twig = new Environment(new ArrayLoader([
|
48 |
-
'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}',
|
49 |
-
]));
|
50 |
-
$twig->addGlobal('bar', 'BAR');
|
51 |
-
|
52 |
-
$wrapper = $twig->load('index');
|
53 |
-
$this->assertEquals('FOOBAR', $wrapper->renderBlock('foo', ['foo' => 'FOO']));
|
54 |
-
}
|
55 |
-
|
56 |
-
public function testDisplayBlock()
|
57 |
-
{
|
58 |
-
$twig = new Environment(new ArrayLoader([
|
59 |
-
'index' => '{% block foo %}{{ foo }}{{ bar }}{% endblock %}',
|
60 |
-
]));
|
61 |
-
$twig->addGlobal('bar', 'BAR');
|
62 |
-
|
63 |
-
$wrapper = $twig->load('index');
|
64 |
-
|
65 |
-
ob_start();
|
66 |
-
$wrapper->displayBlock('foo', ['foo' => 'FOO']);
|
67 |
-
|
68 |
-
$this->assertEquals('FOOBAR', ob_get_clean());
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/TokenStreamTest.php
DELETED
@@ -1,85 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Token;
|
15 |
-
use Twig\TokenStream;
|
16 |
-
|
17 |
-
class TokenStreamTest extends \PHPUnit\Framework\TestCase
|
18 |
-
{
|
19 |
-
protected static $tokens;
|
20 |
-
|
21 |
-
protected function setUp()
|
22 |
-
{
|
23 |
-
self::$tokens = [
|
24 |
-
new Token(Token::TEXT_TYPE, 1, 1),
|
25 |
-
new Token(Token::TEXT_TYPE, 2, 1),
|
26 |
-
new Token(Token::TEXT_TYPE, 3, 1),
|
27 |
-
new Token(Token::TEXT_TYPE, 4, 1),
|
28 |
-
new Token(Token::TEXT_TYPE, 5, 1),
|
29 |
-
new Token(Token::TEXT_TYPE, 6, 1),
|
30 |
-
new Token(Token::TEXT_TYPE, 7, 1),
|
31 |
-
new Token(Token::EOF_TYPE, 0, 1),
|
32 |
-
];
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @group legacy
|
37 |
-
*/
|
38 |
-
public function testLegacyConstructorSignature()
|
39 |
-
{
|
40 |
-
$stream = new TokenStream([], 'foo', '{{ foo }}');
|
41 |
-
$this->assertEquals('foo', $stream->getFilename());
|
42 |
-
$this->assertEquals('{{ foo }}', $stream->getSource());
|
43 |
-
$this->assertEquals('foo', $stream->getSourceContext()->getName());
|
44 |
-
$this->assertEquals('{{ foo }}', $stream->getSourceContext()->getCode());
|
45 |
-
}
|
46 |
-
|
47 |
-
public function testNext()
|
48 |
-
{
|
49 |
-
$stream = new TokenStream(self::$tokens);
|
50 |
-
$repr = [];
|
51 |
-
while (!$stream->isEOF()) {
|
52 |
-
$token = $stream->next();
|
53 |
-
|
54 |
-
$repr[] = $token->getValue();
|
55 |
-
}
|
56 |
-
$this->assertEquals('1, 2, 3, 4, 5, 6, 7', implode(', ', $repr), '->next() advances the pointer and returns the current token');
|
57 |
-
}
|
58 |
-
|
59 |
-
public function testEndOfTemplateNext()
|
60 |
-
{
|
61 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
62 |
-
$this->expectExceptionMessage('Unexpected end of template');
|
63 |
-
|
64 |
-
$stream = new TokenStream([
|
65 |
-
new Token(Token::BLOCK_START_TYPE, 1, 1),
|
66 |
-
]);
|
67 |
-
while (!$stream->isEOF()) {
|
68 |
-
$stream->next();
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
public function testEndOfTemplateLook()
|
73 |
-
{
|
74 |
-
$this->expectException('\Twig\Error\SyntaxError');
|
75 |
-
$this->expectExceptionMessage('Unexpected end of template');
|
76 |
-
|
77 |
-
$stream = new TokenStream([
|
78 |
-
new Token(Token::BLOCK_START_TYPE, 1, 1),
|
79 |
-
]);
|
80 |
-
while (!$stream->isEOF()) {
|
81 |
-
$stream->look();
|
82 |
-
$stream->next();
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/Util/DeprecationCollectorTest.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests\Util;
|
4 |
-
|
5 |
-
/*
|
6 |
-
* This file is part of Twig.
|
7 |
-
*
|
8 |
-
* (c) Fabien Potencier
|
9 |
-
*
|
10 |
-
* For the full copyright and license information, please view the LICENSE
|
11 |
-
* file that was distributed with this source code.
|
12 |
-
*/
|
13 |
-
|
14 |
-
use Twig\Environment;
|
15 |
-
use Twig\TwigFunction;
|
16 |
-
use Twig\Util\DeprecationCollector;
|
17 |
-
|
18 |
-
class DeprecationCollectorTest extends \PHPUnit\Framework\TestCase
|
19 |
-
{
|
20 |
-
/**
|
21 |
-
* @requires PHP 5.3
|
22 |
-
*/
|
23 |
-
public function testCollect()
|
24 |
-
{
|
25 |
-
$twig = new Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
26 |
-
$twig->addFunction(new TwigFunction('deprec', [$this, 'deprec'], ['deprecated' => true]));
|
27 |
-
|
28 |
-
$collector = new DeprecationCollector($twig);
|
29 |
-
$deprecations = $collector->collect(new Twig_Tests_Util_Iterator());
|
30 |
-
|
31 |
-
$this->assertEquals(['Twig Function "deprec" is deprecated in deprec.twig at line 1.'], $deprecations);
|
32 |
-
}
|
33 |
-
|
34 |
-
public function deprec()
|
35 |
-
{
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
class Twig_Tests_Util_Iterator implements \IteratorAggregate
|
40 |
-
{
|
41 |
-
public function getIterator()
|
42 |
-
{
|
43 |
-
return new \ArrayIterator([
|
44 |
-
'ok.twig' => '{{ foo }}',
|
45 |
-
'deprec.twig' => '{{ deprec("foo") }}',
|
46 |
-
]);
|
47 |
-
}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/twig/twig/tests/escapingTest.php
DELETED
@@ -1,327 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace Twig\Tests;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* This class is adapted from code coming from Zend Framework.
|
7 |
-
*
|
8 |
-
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (https://www.zend.com)
|
9 |
-
* @license https://framework.zend.com/license/new-bsd New BSD License
|
10 |
-
*/
|
11 |
-
class Twig_Test_EscapingTest extends \PHPUnit\Framework\TestCase
|
12 |
-
{
|
13 |
-
/**
|
14 |
-
* All character encodings supported by htmlspecialchars().
|
15 |
-
*/
|
16 |
-
protected $htmlSpecialChars = [
|
17 |
-
'\'' => ''',
|
18 |
-
'"' => '"',
|
19 |
-
'<' => '<',
|
20 |
-
'>' => '>',
|
21 |
-
'&' => '&',
|
22 |
-
];
|
23 |
-
|
24 |
-
protected $htmlAttrSpecialChars = [
|
25 |
-
'\'' => ''',
|
26 |
-
/* Characters beyond ASCII value 255 to unicode escape */
|
27 |
-
'Ā' => 'Ā',
|
28 |
-
'😀' => '😀',
|
29 |
-
/* Immune chars excluded */
|
30 |
-
',' => ',',
|
31 |
-
'.' => '.',
|
32 |
-
'-' => '-',
|
33 |
-
'_' => '_',
|
34 |
-
/* Basic alnums excluded */
|
35 |
-
'a' => 'a',
|
36 |
-
'A' => 'A',
|
37 |
-
'z' => 'z',
|
38 |
-
'Z' => 'Z',
|
39 |
-
'0' => '0',
|
40 |
-
'9' => '9',
|
41 |
-
/* Basic control characters and null */
|
42 |
-
"\r" => '
',
|
43 |
-
"\n" => '
',
|
44 |
-
"\t" => '	',
|
45 |
-
"\0" => '�', // should use Unicode replacement char
|
46 |
-
/* Encode chars as named entities where possible */
|
47 |
-
'<' => '<',
|
48 |
-
'>' => '>',
|
49 |
-
'&' => '&',
|
50 |
-
'"' => '"',
|
51 |
-
/* Encode spaces for quoteless attribute protection */
|
52 |
-
' ' => ' ',
|
53 |
-
];
|
54 |
-
|
55 |
-
protected $jsSpecialChars = [
|
56 |
-
/* HTML special chars - escape without exception to hex */
|
57 |
-
'<' => '\\u003C',
|
58 |
-
'>' => '\\u003E',
|
59 |
-
'\'' => '\\u0027',
|
60 |
-
'"' => '\\u0022',
|
61 |
-
'&' => '\\u0026',
|
62 |
-
'/' => '\\/',
|
63 |
-
/* Characters beyond ASCII value 255 to unicode escape */
|
64 |
-
'Ā' => '\\u0100',
|
65 |
-
'😀' => '\\uD83D\\uDE00',
|
66 |
-
/* Immune chars excluded */
|
67 |
-
',' => ',',
|
68 |
-
'.' => '.',
|
69 |
-
'_' => '_',
|
70 |
-
/* Basic alnums excluded */
|
71 |
-
'a' => 'a',
|
72 |
-
'A' => 'A',
|
73 |
-
'z' => 'z',
|
74 |
-
'Z' => 'Z',
|
75 |
-
'0' => '0',
|
76 |
-
'9' => '9',
|
77 |
-
/* Basic control characters and null */
|
78 |
-
"\r" => '\r',
|
79 |
-
"\n" => '\n',
|
80 |
-
"\x08" => '\b',
|
81 |
-
"\t" => '\t',
|
82 |
-
"\x0C" => '\f',
|
83 |
-
"\0" => '\\u0000',
|
84 |
-
/* Encode spaces for quoteless attribute protection */
|
85 |
-
' ' => '\\u0020',
|
86 |
-
];
|
87 |
-
|
88 |
-
protected $urlSpecialChars = [
|
89 |
-
/* HTML special chars - escape without exception to percent encoding */
|
90 |
-
'<' => '%3C',
|
91 |
-
'>' => '%3E',
|
92 |
-
'\'' => '%27',
|
93 |
-
'"' => '%22',
|
94 |
-
'&' => '%26',
|
95 |
-
/* Characters beyond ASCII value 255 to hex sequence */
|
96 |
-
'Ā' => '%C4%80',
|
97 |
-
/* Punctuation and unreserved check */
|
98 |
-
',' => '%2C',
|
99 |
-
'.' => '.',
|
100 |
-
'_' => '_',
|
101 |
-
'-' => '-',
|
102 |
-
':' => '%3A',
|
103 |
-
';' => '%3B',
|
104 |
-
'!' => '%21',
|
105 |
-
/* Basic alnums excluded */
|
106 |
-
'a' => 'a',
|
107 |
-
'A' => 'A',
|
108 |
-
'z' => 'z',
|
109 |
-
'Z' => 'Z',
|
110 |
-
'0' => '0',
|
111 |
-
'9' => '9',
|
112 |
-
/* Basic control characters and null */
|
113 |
-
"\r" => '%0D',
|
114 |
-
"\n" => '%0A',
|
115 |
-
"\t" => '%09',
|
116 |
-
"\0" => '%00',
|
117 |
-
/* PHP quirks from the past */
|
118 |
-
' ' => '%20',
|
119 |
-
'~' => '~',
|
120 |
-
'+' => '%2B',
|
121 |
-
];
|
122 |
-
|
123 |
-
protected $cssSpecialChars = [
|
124 |
-
/* HTML special chars - escape without exception to hex */
|
125 |
-
'<' => '\\3C ',
|
126 |
-
'>' => '\\3E ',
|
127 |
-
'\'' => '\\27 ',
|
128 |
-
'"' => '\\22 ',
|
129 |
-
'&' => '\\26 ',
|
130 |
-
/* Characters beyond ASCII value 255 to unicode escape */
|
131 |
-
'Ā' => '\\100 ',
|
132 |
-
/* Immune chars excluded */
|
133 |
-
',' => '\\2C ',
|
134 |
-
'.' => '\\2E ',
|
135 |
-
'_' => '\\5F ',
|
136 |
-
/* Basic alnums excluded */
|
137 |
-
'a' => 'a',
|
138 |
-
'A' => 'A',
|
139 |
-
'z' => 'z',
|
140 |
-
'Z' => 'Z',
|
141 |
-
'0' => '0',
|
142 |
-
'9' => '9',
|
143 |
-
/* Basic control characters and null */
|
144 |
-
"\r" => '\\D ',
|
145 |
-
"\n" => '\\A ',
|
146 |
-
"\t" => '\\9 ',
|
147 |
-
"\0" => '\\0 ',
|
148 |
-
/* Encode spaces for quoteless attribute protection */
|
149 |
-
' ' => '\\20 ',
|
150 |
-
];
|
151 |
-
|
152 |
-
protected $env;
|
153 |
-
|
154 |
-
protected function setUp()
|
155 |
-
{
|
156 |
-
$this->env = new \Twig\Environment($this->createMock('\Twig\Loader\LoaderInterface'));
|
157 |
-
}
|
158 |
-
|
159 |
-
public function testHtmlEscapingConvertsSpecialChars()
|
160 |
-
{
|
161 |
-
foreach ($this->htmlSpecialChars as $key => $value) {
|
162 |
-
$this->assertEquals($value, twig_escape_filter($this->env, $key, 'html'), 'Failed to escape: '.$key);
|
163 |
-
}
|
164 |
-
}
|
165 |
-
|
166 |
-
public function testHtmlAttributeEscapingConvertsSpecialChars()
|
167 |
-
{
|
168 |
-
foreach ($this->htmlAttrSpecialChars as $key => $value) {
|
169 |
-
$this->assertEquals($value, twig_escape_filter($this->env, $key, 'html_attr'), 'Failed to escape: '.$key);
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
public function testJavascriptEscapingConvertsSpecialChars()
|
174 |
-
{
|
175 |
-
foreach ($this->jsSpecialChars as $key => $value) {
|
176 |
-
$this->assertEquals($value, twig_escape_filter($this->env, $key, 'js'), 'Failed to escape: '.$key);
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
public function testJavascriptEscapingReturnsStringIfZeroLength()
|
181 |
-
{
|
182 |
-
$this->assertEquals('', twig_escape_filter($this->env, '', 'js'));
|
183 |
-
}
|
184 |
-
|
185 |
-
public function testJavascriptEscapingReturnsStringIfContainsOnlyDigits()
|
186 |
-
{
|
187 |
-
$this->assertEquals('123', twig_escape_filter($this->env, '123', 'js'));
|
188 |
-
}
|
189 |
-
|
190 |
-
public function testCssEscapingConvertsSpecialChars()
|
191 |
-
{
|
192 |
-
foreach ($this->cssSpecialChars as $key => $value) {
|
193 |
-
$this->assertEquals($value, twig_escape_filter($this->env, $key, 'css'), 'Failed to escape: '.$key);
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
public function testCssEscapingReturnsStringIfZeroLength()
|
198 |
-
{
|
199 |
-
$this->assertEquals('', twig_escape_filter($this->env, '', 'css'));
|
200 |
-
}
|
201 |
-
|
202 |
-
public function testCssEscapingReturnsStringIfContainsOnlyDigits()
|
203 |
-
{
|
204 |
-
$this->assertEquals('123', twig_escape_filter($this->env, '123', 'css'));
|
205 |
-
}
|
206 |
-
|
207 |
-
public function testUrlEscapingConvertsSpecialChars()
|
208 |
-
{
|
209 |
-
foreach ($this->urlSpecialChars as $key => $value) {
|
210 |
-
$this->assertEquals($value, twig_escape_filter($this->env, $key, 'url'), 'Failed to escape: '.$key);
|
211 |
-
}
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Range tests to confirm escaped range of characters is within OWASP recommendation.
|
216 |
-
*/
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Only testing the first few 2 ranges on this prot. function as that's all these
|
220 |
-
* other range tests require.
|
221 |
-
*/
|
222 |
-
public function testUnicodeCodepointConversionToUtf8()
|
223 |
-
{
|
224 |
-
$expected = ' ~ޙ';
|
225 |
-
$codepoints = [0x20, 0x7e, 0x799];
|
226 |
-
$result = '';
|
227 |
-
foreach ($codepoints as $value) {
|
228 |
-
$result .= $this->codepointToUtf8($value);
|
229 |
-
}
|
230 |
-
$this->assertEquals($expected, $result);
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Convert a Unicode Codepoint to a literal UTF-8 character.
|
235 |
-
*
|
236 |
-
* @param int $codepoint Unicode codepoint in hex notation
|
237 |
-
*
|
238 |
-
* @return string UTF-8 literal string
|
239 |
-
*/
|
240 |
-
protected function codepointToUtf8($codepoint)
|
241 |
-
{
|
242 |
-
if ($codepoint < 0x80) {
|
243 |
-
return \chr($codepoint);
|
244 |
-
}
|
245 |
-
if ($codepoint < 0x800) {
|
246 |
-
return \chr($codepoint >> 6 & 0x3f | 0xc0)
|
247 |
-
.\chr($codepoint & 0x3f | 0x80);
|
248 |
-
}
|
249 |
-
if ($codepoint < 0x10000) {
|
250 |
-
return \chr($codepoint >> 12 & 0x0f | 0xe0)
|
251 |
-
.\chr($codepoint >> 6 & 0x3f | 0x80)
|
252 |
-
.\chr($codepoint & 0x3f | 0x80);
|
253 |
-
}
|
254 |
-
if ($codepoint < 0x110000) {
|
255 |
-
return \chr($codepoint >> 18 & 0x07 | 0xf0)
|
256 |
-
.\chr($codepoint >> 12 & 0x3f | 0x80)
|
257 |
-
.\chr($codepoint >> 6 & 0x3f | 0x80)
|
258 |
-
.\chr($codepoint & 0x3f | 0x80);
|
259 |
-
}
|
260 |
-
throw new \Exception('Codepoint requested outside of Unicode range.');
|
261 |
-
}
|
262 |
-
|
263 |
-
public function testJavascriptEscapingEscapesOwaspRecommendedRanges()
|
264 |
-
{
|
265 |
-
$immune = [',', '.', '_']; // Exceptions to escaping ranges
|
266 |
-
for ($chr = 0; $chr < 0xFF; ++$chr) {
|
267 |
-
if ($chr >= 0x30 && $chr <= 0x39
|
268 |
-
|| $chr >= 0x41 && $chr <= 0x5A
|
269 |
-
|| $chr >= 0x61 && $chr <= 0x7A) {
|
270 |
-
$literal = $this->codepointToUtf8($chr);
|
271 |
-
$this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js'));
|
272 |
-
} else {
|
273 |
-
$literal = $this->codepointToUtf8($chr);
|
274 |
-
if (\in_array($literal, $immune)) {
|
275 |
-
$this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'js'));
|
276 |
-
} else {
|
277 |
-
$this->assertNotEquals(
|
278 |
-
$literal,
|
279 |
-
twig_escape_filter($this->env, $literal, 'js'),
|
280 |
-
"$literal should be escaped!");
|
281 |
-
}
|
282 |
-
}
|
283 |
-
}
|
284 |
-
}
|
285 |
-
|
286 |
-
public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges()
|
287 |
-
{
|
288 |
-
$immune = [',', '.', '-', '_']; // Exceptions to escaping ranges
|
289 |
-
for ($chr = 0; $chr < 0xFF; ++$chr) {
|
290 |
-
if ($chr >= 0x30 && $chr <= 0x39
|
291 |
-
|| $chr >= 0x41 && $chr <= 0x5A
|
292 |
-
|| $chr >= 0x61 && $chr <= 0x7A) {
|
293 |
-
$literal = $this->codepointToUtf8($chr);
|
294 |
-
$this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'html_attr'));
|
295 |
-
} else {
|
296 |
-
$literal = $this->codepointToUtf8($chr);
|
297 |
-
if (\in_array($literal, $immune)) {
|
298 |
-
$this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'html_attr'));
|
299 |
-
} else {
|
300 |
-
$this->assertNotEquals(
|
301 |
-
$literal,
|
302 |
-
twig_escape_filter($this->env, $literal, 'html_attr'),
|
303 |
-
"$literal should be escaped!");
|
304 |
-
}
|
305 |
-
}
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
public function testCssEscapingEscapesOwaspRecommendedRanges()
|
310 |
-
{
|
311 |
-
// CSS has no exceptions to escaping ranges
|
312 |
-
for ($chr = 0; $chr < 0xFF; ++$chr) {
|
313 |
-
if ($chr >= 0x30 && $chr <= 0x39
|
314 |
-
|| $chr >= 0x41 && $chr <= 0x5A
|
315 |
-
|| $chr >= 0x61 && $chr <= 0x7A) {
|
316 |
-
$literal = $this->codepointToUtf8($chr);
|
317 |
-
$this->assertEquals($literal, twig_escape_filter($this->env, $literal, 'css'));
|
318 |
-
} else {
|
319 |
-
$literal = $this->codepointToUtf8($chr);
|
320 |
-
$this->assertNotEquals(
|
321 |
-
$literal,
|
322 |
-
twig_escape_filter($this->env, $literal, 'css'),
|
323 |
-
"$literal should be escaped!");
|
324 |
-
}
|
325 |
-
}
|
326 |
-
}
|
327 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|