diff options
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Fixtures/functions')
24 files changed, 311 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test new file mode 100644 index 00000000..16ae1e8b --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/attribute.test | |||
@@ -0,0 +1,12 @@ | |||
1 | --TEST-- | ||
2 | "attribute" function | ||
3 | --TEMPLATE-- | ||
4 | {{ attribute(obj, method) }} | ||
5 | {{ attribute(array, item) }} | ||
6 | {{ attribute(obj, "bar", ["a", "b"]) }} | ||
7 | --DATA-- | ||
8 | return array('obj' => new TwigTestFoo(), 'method' => 'foo', 'array' => array('foo' => 'bar'), 'item' => 'foo') | ||
9 | --EXPECT-- | ||
10 | foo | ||
11 | bar | ||
12 | bar_a-b | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test new file mode 100644 index 00000000..8e54059a --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/block.test | |||
@@ -0,0 +1,12 @@ | |||
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 array() | ||
11 | --EXPECT-- | ||
12 | BARBAR | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test new file mode 100644 index 00000000..63128791 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/constant.test | |||
@@ -0,0 +1,10 @@ | |||
1 | --TEST-- | ||
2 | "constant" function | ||
3 | --TEMPLATE-- | ||
4 | {{ constant('DATE_W3C') == expect ? 'true' : 'false' }} | ||
5 | {{ constant('ARRAY_AS_PROPS', object) }} | ||
6 | --DATA-- | ||
7 | return array('expect' => DATE_W3C, 'object' => new ArrayObject(array('hi'))); | ||
8 | --EXPECT-- | ||
9 | true | ||
10 | 2 | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test new file mode 100644 index 00000000..522a63b8 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/cycle.test | |||
@@ -0,0 +1,16 @@ | |||
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 array('array1' => array('odd', 'even'), 'array2' => array('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 | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test new file mode 100644 index 00000000..a4c97167 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date.test | |||
@@ -0,0 +1,27 @@ | |||
1 | --TEST-- | ||
2 | "date" function | ||
3 | --TEMPLATE-- | ||
4 | {{ date() == date('now') ? 'OK' : 'KO' }} | ||
5 | {{ date() > date('-1day') ? 'OK' : 'KO' }} | ||
6 | {{ date(date1) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} | ||
7 | {{ date(date2) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} | ||
8 | {{ date(date3) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} | ||
9 | {{ date(date4) == date('2010-10-04 13:45') ? 'OK' : 'KO' }} | ||
10 | {{ date(date5) == date('1964-01-02 03:04') ? 'OK' : 'KO' }} | ||
11 | --DATA-- | ||
12 | date_default_timezone_set('UTC'); | ||
13 | return array( | ||
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 | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test new file mode 100644 index 00000000..b9dd9e38 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/date_namedargs.test | |||
@@ -0,0 +1,11 @@ | |||
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 array('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 | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test new file mode 100644 index 00000000..f4072375 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump.test | |||
@@ -0,0 +1,16 @@ | |||
1 | --TEST-- | ||
2 | "dump" function | ||
3 | --CONDITION-- | ||
4 | !extension_loaded('xdebug') | ||
5 | --TEMPLATE-- | ||
6 | {{ dump('foo') }} | ||
7 | {{ dump('foo', 'bar') }} | ||
8 | --DATA-- | ||
9 | return array('foo' => 'foo', 'bar' => 'bar') | ||
10 | --CONFIG-- | ||
11 | return array('debug' => true, 'autoescape' => false); | ||
12 | --EXPECT-- | ||
13 | string(3) "foo" | ||
14 | |||
15 | string(3) "foo" | ||
16 | string(3) "bar" | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test new file mode 100644 index 00000000..889b7a92 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dump_array.test | |||
@@ -0,0 +1,19 @@ | |||
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 array('foo' => 'foo', 'bar' => 'bar') | ||
9 | --CONFIG-- | ||
10 | return array('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 | } | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test new file mode 100644 index 00000000..913fbc99 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/dynamic_function.test | |||
@@ -0,0 +1,10 @@ | |||
1 | --TEST-- | ||
2 | dynamic function | ||
3 | --TEMPLATE-- | ||
4 | {{ foo_path('bar') }} | ||
5 | {{ a_foo_b_bar('bar') }} | ||
6 | --DATA-- | ||
7 | return array() | ||
8 | --EXPECT-- | ||
9 | foo/bar | ||
10 | a/b/bar | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test new file mode 100644 index 00000000..b7653b4e --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/assignment.test | |||
@@ -0,0 +1,13 @@ | |||
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 array() | ||
11 | --EXPECT-- | ||
12 | FOO | ||
13 | FOOBARBAR | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test new file mode 100644 index 00000000..56f8f3b5 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/autoescaping.test | |||
@@ -0,0 +1,10 @@ | |||
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 array() | ||
9 | --EXPECT-- | ||
10 | <p>Test</p> | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test new file mode 100644 index 00000000..a434182a --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/basic.test | |||
@@ -0,0 +1,17 @@ | |||
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 array() | ||
12 | --EXPECT-- | ||
13 | FOO | ||
14 | |||
15 | FOOBAR | ||
16 | |||
17 | BAR | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test new file mode 100644 index 00000000..aba30ce3 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/expression.test | |||
@@ -0,0 +1,17 @@ | |||
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 array('foo' => 'foo.twig') | ||
12 | --EXPECT-- | ||
13 | FOO | ||
14 | |||
15 | FOOBAR | ||
16 | |||
17 | BAR | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test new file mode 100644 index 00000000..43a2ccc2 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/ignore_missing.test | |||
@@ -0,0 +1,10 @@ | |||
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 array() | ||
10 | --EXPECT-- | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test new file mode 100644 index 00000000..4d2f6cf1 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing.test | |||
@@ -0,0 +1,8 @@ | |||
1 | --TEST-- | ||
2 | "include" function | ||
3 | --TEMPLATE-- | ||
4 | {{ include("foo.twig") }} | ||
5 | --DATA-- | ||
6 | return array(); | ||
7 | --EXCEPTION-- | ||
8 | Twig_Error_Loader: Template "foo.twig" is not defined in "index.twig" at line 2. | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test new file mode 100644 index 00000000..78fddc7a --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/missing_nested.test | |||
@@ -0,0 +1,16 @@ | |||
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 array(); | ||
15 | --EXCEPTION-- | ||
16 | Twig_Error_Loader: Template "foo.twig" is not defined in "base.twig" at line 3. | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test new file mode 100644 index 00000000..788a2ab0 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox.test | |||
@@ -0,0 +1,10 @@ | |||
1 | --TEST-- | ||
2 | "include" tag sandboxed | ||
3 | --TEMPLATE-- | ||
4 | {{ include("foo.twig", sandboxed = true) }} | ||
5 | --TEMPLATE(foo.twig)-- | ||
6 | {{ foo|e }} | ||
7 | --DATA-- | ||
8 | return array() | ||
9 | --EXCEPTION-- | ||
10 | Twig_Sandbox_SecurityError: Filter "e" is not allowed in "index.twig" at line 2. | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test new file mode 100644 index 00000000..18d405a0 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/template_instance.test | |||
@@ -0,0 +1,10 @@ | |||
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 array('foo' => $twig->loadTemplate('foo.twig')) | ||
9 | --EXPECT-- | ||
10 | BAR FOO | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test new file mode 100644 index 00000000..1a810068 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/templates_as_array.test | |||
@@ -0,0 +1,12 @@ | |||
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 array() | ||
10 | --EXPECT-- | ||
11 | foo | ||
12 | foo | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test new file mode 100644 index 00000000..35611fbb --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_context.test | |||
@@ -0,0 +1,16 @@ | |||
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 array('foo' => 'bar') | ||
12 | --EXPECT-- | ||
13 | foo,global,_parent, | ||
14 | global,_parent, | ||
15 | foo,global,foo1,_parent, | ||
16 | foo1,global,_parent, | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test new file mode 100644 index 00000000..b2ace940 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/with_variables.test | |||
@@ -0,0 +1,12 @@ | |||
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 array('vars' => array('foo' => 'bar')) | ||
10 | --EXPECT-- | ||
11 | bar | ||
12 | bar | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test new file mode 100644 index 00000000..e0377c8d --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/range.test | |||
@@ -0,0 +1,8 @@ | |||
1 | --TEST-- | ||
2 | "range" function | ||
3 | --TEMPLATE-- | ||
4 | {{ range(low=0+1, high=10+0, step=2)|join(',') }} | ||
5 | --DATA-- | ||
6 | return array() | ||
7 | --EXPECT-- | ||
8 | 1,3,5,7,9 | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test new file mode 100644 index 00000000..30c3df51 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/special_chars.test | |||
@@ -0,0 +1,8 @@ | |||
1 | --TEST-- | ||
2 | "§" custom function | ||
3 | --TEMPLATE-- | ||
4 | {{ §('foo') }} | ||
5 | --DATA-- | ||
6 | return array() | ||
7 | --EXPECT-- | ||
8 | §foo§ | ||
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test new file mode 100644 index 00000000..41428da1 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/template_from_string.test | |||
@@ -0,0 +1,11 @@ | |||
1 | --TEST-- | ||
2 | "template_from_string" function | ||
3 | --TEMPLATE-- | ||
4 | {% include template_from_string(template) %} | ||
5 | |||
6 | {% include template_from_string("Hello {{ name }}") %} | ||
7 | --DATA-- | ||
8 | return array('name' => 'Fabien', 'template' => "Hello {{ name }}") | ||
9 | --EXPECT-- | ||
10 | Hello Fabien | ||
11 | Hello Fabien | ||