12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- --TEST--
- "empty" test
- --TEMPLATE--
- {{ foo is empty ? 'ok' : 'ko' }}
- {{ bar is empty ? 'ok' : 'ko' }}
- {{ foobar is empty ? 'ok' : 'ko' }}
- {{ array is empty ? 'ok' : 'ko' }}
- {{ zero is empty ? 'ok' : 'ko' }}
- {{ string is empty ? 'ok' : 'ko' }}
- {{ countable_empty is empty ? 'ok' : 'ko' }}
- {{ countable_not_empty is empty ? 'ok' : 'ko' }}
- {{ markup_empty is empty ? 'ok' : 'ko' }}
- {{ markup_not_empty is empty ? 'ok' : 'ko' }}
- --DATA--
-
- class CountableStub implements Countable
- {
- private $items;
-
- public function __construct(array $items)
- {
- $this->items = $items;
- }
-
- public function count()
- {
- return count($this->items);
- }
- }
- return array(
- 'foo' => '', 'bar' => null, 'foobar' => false, 'array' => array(), 'zero' => 0, 'string' => '0',
- 'countable_empty' => new CountableStub(array()), 'countable_not_empty' => new CountableStub(array(1, 2)),
- 'markup_empty' => new Twig_Markup('', 'UTF-8'), 'markup_not_empty' => new Twig_Markup('test', 'UTF-8'),
- );
- --EXPECT--
- ok
- ok
- ok
- ok
- ko
- ko
- ok
- ko
- ok
- ko
|