diff options
Diffstat (limited to 'vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test')
-rw-r--r-- | vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test b/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test new file mode 100644 index 00000000..a776d032 --- /dev/null +++ b/vendor/twig/twig/test/Twig/Tests/Fixtures/tests/empty.test | |||
@@ -0,0 +1,45 @@ | |||
1 | --TEST-- | ||
2 | "empty" test | ||
3 | --TEMPLATE-- | ||
4 | {{ foo is empty ? 'ok' : 'ko' }} | ||
5 | {{ bar is empty ? 'ok' : 'ko' }} | ||
6 | {{ foobar is empty ? 'ok' : 'ko' }} | ||
7 | {{ array is empty ? 'ok' : 'ko' }} | ||
8 | {{ zero is empty ? 'ok' : 'ko' }} | ||
9 | {{ string is empty ? 'ok' : 'ko' }} | ||
10 | {{ countable_empty is empty ? 'ok' : 'ko' }} | ||
11 | {{ countable_not_empty is empty ? 'ok' : 'ko' }} | ||
12 | {{ markup_empty is empty ? 'ok' : 'ko' }} | ||
13 | {{ markup_not_empty is empty ? 'ok' : 'ko' }} | ||
14 | --DATA-- | ||
15 | |||
16 | class CountableStub implements Countable | ||
17 | { | ||
18 | private $items; | ||
19 | |||
20 | public function __construct(array $items) | ||
21 | { | ||
22 | $this->items = $items; | ||
23 | } | ||
24 | |||
25 | public function count() | ||
26 | { | ||
27 | return count($this->items); | ||
28 | } | ||
29 | } | ||
30 | return array( | ||
31 | 'foo' => '', 'bar' => null, 'foobar' => false, 'array' => array(), 'zero' => 0, 'string' => '0', | ||
32 | 'countable_empty' => new CountableStub(array()), 'countable_not_empty' => new CountableStub(array(1, 2)), | ||
33 | 'markup_empty' => new Twig_Markup('', 'UTF-8'), 'markup_not_empty' => new Twig_Markup('test', 'UTF-8'), | ||
34 | ); | ||
35 | --EXPECT-- | ||
36 | ok | ||
37 | ok | ||
38 | ok | ||
39 | ok | ||
40 | ko | ||
41 | ko | ||
42 | ok | ||
43 | ko | ||
44 | ok | ||
45 | ko | ||