File: length.test

package info (click to toggle)
php-twig 3.20.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,940 kB
  • sloc: php: 23,320; makefile: 110; sh: 43
file content (42 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
"length" filter
--TEMPLATE--
{{ array|length }}
{{ string|length }}
{{ number|length }}
{{ to_string_able|length }}
{{ countable|length }}
{{ iterator_aggregate|length }}
{{ ""|length }}
{{ null|length }}
{{ magic|length }}
{{ non_countable|length }}
{{ simple_xml_element|length }}
{{ iterator|length }}
--DATA--
return [
    'array' => [1, 4],
    'string' => 'foo',
    'number' => 1000,
    'to_string_able' => new Twig\Tests\ToStringStub('foobar'),
    'countable' => new Twig\Tests\CountableStub(42),       /* also asserts we do *not* call __toString() */
    'iterator_aggregate' => new Twig\Tests\IteratorAggregateStub(['a', 'b', 'c']),   /* also asserts we do *not* call __toString() */
    'null'          => null,
    'magic'         => new Twig\Tests\MagicCallStub(),     /* used to assert we do *not* call __call */
    'non_countable' => new \StdClass(),
    'simple_xml_element' => new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><doc><elem/><elem/></doc>'),
    'iterator' => new Twig\Tests\SimpleIteratorForTesting()
]
--EXPECT--
2
3
4
6
42
3
0
0
1
1
2
7