CallTest.php 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2014 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @group magic_methods
  12. * @group functional
  13. */
  14. class Mustache_Test_Functional_CallTest extends PHPUnit_Framework_TestCase
  15. {
  16. public function testCallEatsContext()
  17. {
  18. $m = new Mustache_Engine();
  19. $tpl = $m->loadTemplate('{{# foo }}{{ label }}: {{ name }}{{/ foo }}');
  20. $foo = new Mustache_Test_Functional_ClassWithCall();
  21. $foo->name = 'Bob';
  22. $data = array('label' => 'name', 'foo' => $foo);
  23. $this->assertEquals('name: Bob', $tpl->render($data));
  24. }
  25. }
  26. class Mustache_Test_Functional_ClassWithCall
  27. {
  28. public $name;
  29. public function __call($method, $args)
  30. {
  31. return 'unknown value';
  32. }
  33. }