MustacheCallTest.php 513 B

123456789101112131415161718192021222324
  1. <?php
  2. require_once '../Mustache.php';
  3. class MustacheCallTest extends PHPUnit_Framework_TestCase {
  4. public function testCallEatsContext() {
  5. $foo = new ClassWithCall();
  6. $foo->name = 'Bob';
  7. $template = '{{# foo }}{{ label }}: {{ name }}{{/ foo }}';
  8. $data = array('label' => 'name', 'foo' => $foo);
  9. $m = new Mustache($template, $data);
  10. $this->assertEquals('name: Bob', $m->render());
  11. }
  12. }
  13. class ClassWithCall {
  14. public $name;
  15. public function __call($method, $args) {
  16. return 'unknown value';
  17. }
  18. }