empty.test 829B

12345678910111213141516171819202122232425262728293031323334353637
  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. --DATA--
  13. class CountableStub implements Countable
  14. {
  15. private $items;
  16. public function __construct(array $items)
  17. {
  18. $this->items = $items;
  19. }
  20. public function count()
  21. {
  22. return count($this->items);
  23. }
  24. }
  25. 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)));
  26. --EXPECT--
  27. ok
  28. ok
  29. ok
  30. ok
  31. ko
  32. ko
  33. ok
  34. ko