Merge branch 'dev' into feature/implicit-iterator

This commit is contained in:
Justin Hileman
2010-07-11 22:35:38 -04:00
12 changed files with 185 additions and 14 deletions
+56
View File
@@ -0,0 +1,56 @@
<?php
require_once '../Mustache.php';
class MustacheObjectSectionTest extends PHPUnit_Framework_TestCase {
public function testBasicObject() {
$alpha = new Alpha();
$this->assertEquals('Foo', $alpha->render('{{#foo}}{{name}}{{/foo}}'));
}
public function testObjectWithGet() {
$beta = new Beta();
$this->assertEquals('Foo', $beta->render('{{#foo}}{{name}}{{/foo}}'));
}
public function testSectionObjectWithGet() {
$gamma = new Gamma();
$this->assertEquals('Foo', $gamma->render('{{#bar}}{{#foo}}{{name}}{{/foo}}{{/bar}}'));
}
}
class Alpha extends Mustache {
public $foo;
public function __construct() {
$this->foo = new StdClass();
$this->foo->name = 'Foo';
$this->foo->number = 1;
}
}
class Beta extends Mustache {
protected $_data = array();
public function __construct() {
$this->_data['foo'] = new StdClass();
$this->_data['foo']->name = 'Foo';
$this->_data['foo']->number = 1;
}
public function __isset($name) {
return array_key_exists($name, $this->_data);
}
public function __get($name) {
return $this->_data[$name];
}
}
class Gamma extends Mustache {
public $bar;
public function __construct() {
$this->bar = new Beta();
}
}
+17 -13
View File
@@ -262,26 +262,30 @@ class MustacheTest extends PHPUnit_Framework_TestCase {
foreach ($children as $file) {
if (!$file->isFile()) continue;
$filename = $file->getPathInfo();
$filename = $file->getPathname();
$info = pathinfo($filename);
switch($info['extension']) {
case 'php':
$class = $info['filename'];
include_once($filename);
break;
if (isset($info['extension'])) {
switch($info['extension']) {
case 'php':
$class = $info['filename'];
include_once($filename);
break;
case 'mustache':
$template = file_get_contents($filename);
break;
case 'mustache':
$template = file_get_contents($filename);
break;
case 'txt':
$output = file_get_contents($filename);
break;
case 'txt':
$output = file_get_contents($filename);
break;
}
}
}
$ret[$example] = array($class, $template, $output);
if (!empty($class)) {
$ret[$example] = array($class, $template, $output);
}
}
$files->next();