Segregate 5.3+ tests, exclude them from phpunit config.
This commit is contained in:
@@ -21,34 +21,6 @@ class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework
|
||||
$this->mustache = new Mustache_Mustache;
|
||||
}
|
||||
|
||||
public function testAnonymousFunctionSectionCallback() {
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||
$this->markTestSkipped('Unable to test anonymous function section callbacks in PHP < 5.3');
|
||||
return;
|
||||
}
|
||||
|
||||
$tpl = $this->mustache->loadTemplate('{{#wrapper}}{{name}}{{/wrapper}}');
|
||||
|
||||
$foo = new Mustache_Test_Functional_Foo;
|
||||
$foo->name = 'Mario';
|
||||
$foo->wrapper = function($text) {
|
||||
return sprintf('<div class="anonymous">%s</div>', $text);
|
||||
};
|
||||
|
||||
$this->assertEquals(sprintf('<div class="anonymous">%s</div>', $foo->name), $tpl->render($foo));
|
||||
}
|
||||
|
||||
public function testSectionCallback() {
|
||||
$one = $this->mustache->loadTemplate('{{name}}');
|
||||
$two = $this->mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||
|
||||
$foo = new Mustache_Test_Functional_Foo;
|
||||
$foo->name = 'Luigi';
|
||||
|
||||
$this->assertEquals($foo->name, $one->render($foo));
|
||||
$this->assertEquals(sprintf('<em>%s</em>', $foo->name), $two->render($foo));
|
||||
}
|
||||
|
||||
public function testRuntimeSectionCallback() {
|
||||
$tpl = $this->mustache->loadTemplate('{{#doublewrap}}{{name}}{{/doublewrap}}');
|
||||
|
||||
@@ -80,19 +52,6 @@ class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework
|
||||
$this->assertEquals($data['name'], $tpl->render($data));
|
||||
}
|
||||
|
||||
public function testViewArrayAnonymousSectionCallback() {
|
||||
$tpl = $this->mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||
|
||||
$data = array(
|
||||
'name' => 'Bob',
|
||||
'wrap' => function($text) {
|
||||
return sprintf('[[%s]]', $text);
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertEquals(sprintf('[[%s]]', $data['name']), $tpl->render($data));
|
||||
}
|
||||
|
||||
public function testMonsters() {
|
||||
$tpl = $this->mustache->loadTemplate('{{#title}}{{title}} {{/title}}{{name}}');
|
||||
|
||||
@@ -111,13 +70,6 @@ class Mustache_Test_Functional_HigherOrderSectionsTest extends PHPUnit_Framework
|
||||
class Mustache_Test_Functional_Foo {
|
||||
public $name = 'Justin';
|
||||
public $lorem = 'Lorem ipsum dolor sit amet,';
|
||||
public $wrap;
|
||||
|
||||
public function __construct() {
|
||||
$this->wrap = function($text) {
|
||||
return sprintf('<em>%s</em>', $text);
|
||||
};
|
||||
}
|
||||
|
||||
public function wrapWithEm($text) {
|
||||
return sprintf('<em>%s</em>', $text);
|
||||
|
||||
@@ -110,9 +110,7 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
|
||||
$tpl = $this->mustache->loadTemplate('{{ a }}');
|
||||
|
||||
$data = array(
|
||||
'a' => function() {
|
||||
return '{{ b }}';
|
||||
},
|
||||
'a' => array($this, 'lambdaInterpolationCallback'),
|
||||
'b' => '{{ c }}',
|
||||
'c' => 'FAIL'
|
||||
);
|
||||
@@ -120,17 +118,23 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
|
||||
$this->assertEquals('{{ c }}', $tpl->render($data));
|
||||
}
|
||||
|
||||
public static function lambdaInterpolationCallback() {
|
||||
return '{{ b }}';
|
||||
}
|
||||
|
||||
public function testLambdaSectionInjection() {
|
||||
$tpl = $this->mustache->loadTemplate('{{# a }}b{{/ a }}');
|
||||
|
||||
$data = array(
|
||||
'a' => function ($text) {
|
||||
return '{{ ' . $text . ' }}';
|
||||
},
|
||||
'a' => array($this, 'lambdaSectionCallback'),
|
||||
'b' => '{{ c }}',
|
||||
'c' => 'FAIL'
|
||||
);
|
||||
|
||||
$this->assertEquals('{{ c }}', $tpl->render($data));
|
||||
}
|
||||
|
||||
public static function lambdaSectionCallback($text) {
|
||||
return '{{ ' . $text . ' }}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,41 +86,6 @@ class Mustache_Test_Functional_MustacheSpecTest extends PHPUnit_Framework_TestCa
|
||||
return $this->loadSpec('inverted');
|
||||
}
|
||||
|
||||
/**
|
||||
* @group lambdas
|
||||
* @dataProvider loadLambdasSpec
|
||||
*/
|
||||
public function testLambdasSpec($desc, $source, $partials, $data, $expected) {
|
||||
$template = self::loadTemplate($source, $partials);
|
||||
$this->assertEquals($expected, $template($this->prepareLambdasSpec($data)), $desc);
|
||||
}
|
||||
|
||||
public function loadLambdasSpec() {
|
||||
return $this->loadSpec('~lambdas');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and lambdafy any 'lambda' values found in the $data array.
|
||||
*/
|
||||
private function prepareLambdasSpec($data) {
|
||||
foreach ($data as $key => $val) {
|
||||
if ($key === 'lambda') {
|
||||
if (!isset($val['php'])) {
|
||||
$this->markTestSkipped(sprintf('PHP lambda test not implemented for this test.'));
|
||||
}
|
||||
|
||||
$func = $val['php'];
|
||||
$data[$key] = function($text = null) use ($func) {
|
||||
return eval($func);
|
||||
};
|
||||
} else if (is_array($val)) {
|
||||
$data[$key] = $this->prepareLambdasSpec($val);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @group partials
|
||||
* @dataProvider loadPartialsSpec
|
||||
|
||||
Reference in New Issue
Block a user