소스 검색

Add a test to discourage people from implementing support for __call.

Pull in the test from https://gist.github.com/655784

This should discourage reports like #16, #19 and #55, and #76.
Conor McDermottroe 14 년 전
부모
커밋
1ab066c718
1개의 변경된 파일24개의 추가작업 그리고 0개의 파일을 삭제
  1. 24 0
      test/MustacheCallTest.php

+ 24 - 0
test/MustacheCallTest.php

@@ -0,0 +1,24 @@
+<?php
+
+require_once '../Mustache.php';
+
+class MustacheCallTest extends PHPUnit_Framework_TestCase {
+
+	public function testCallEatsContext() {
+		$foo = new Foo();
+		$foo->name = 'Bob';
+
+		$template = '{{# foo }}{{ label }}: {{ name }}{{/ foo }}';
+		$data = array('label' => 'name', 'foo' => $foo);
+		$m = new Mustache($template, $data);
+
+		$this->assertEquals('name: Bob', $m->render());
+	}
+}
+
+class Foo {
+	public $name;
+	public function __call($method, $args) {
+		return 'unknown value';
+	}
+}