Coding standards fixes.
This commit is contained in:
@@ -13,15 +13,17 @@
|
||||
* @group lambdas
|
||||
* @group functional
|
||||
*/
|
||||
class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $mustache;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp()
|
||||
{
|
||||
$this->mustache = new Mustache_Engine;
|
||||
}
|
||||
|
||||
public function testAnonymousFunctionSectionCallback() {
|
||||
public function testAnonymousFunctionSectionCallback()
|
||||
{
|
||||
$tpl = $this->mustache->loadTemplate('{{#wrapper}}{{name}}{{/wrapper}}');
|
||||
|
||||
$foo = new Mustache_Test_FiveThree_Functional_Foo;
|
||||
@@ -33,7 +35,8 @@ class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit
|
||||
$this->assertEquals(sprintf('<div class="anonymous">%s</div>', $foo->name), $tpl->render($foo));
|
||||
}
|
||||
|
||||
public function testSectionCallback() {
|
||||
public function testSectionCallback()
|
||||
{
|
||||
$one = $this->mustache->loadTemplate('{{name}}');
|
||||
$two = $this->mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||
|
||||
@@ -44,7 +47,8 @@ class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit
|
||||
$this->assertEquals(sprintf('<em>%s</em>', $foo->name), $two->render($foo));
|
||||
}
|
||||
|
||||
public function testViewArrayAnonymousSectionCallback() {
|
||||
public function testViewArrayAnonymousSectionCallback()
|
||||
{
|
||||
$tpl = $this->mustache->loadTemplate('{{#wrap}}{{name}}{{/wrap}}');
|
||||
|
||||
$data = array(
|
||||
@@ -58,12 +62,14 @@ class Mustache_Test_FiveThree_Functional_HigherOrderSectionsTest extends PHPUnit
|
||||
}
|
||||
}
|
||||
|
||||
class Mustache_Test_FiveThree_Functional_Foo {
|
||||
class Mustache_Test_FiveThree_Functional_Foo
|
||||
{
|
||||
public $name = 'Justin';
|
||||
public $lorem = 'Lorem ipsum dolor sit amet,';
|
||||
public $wrap;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->wrap = function($text) {
|
||||
return sprintf('<em>%s</em>', $text);
|
||||
};
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
* @group mustache-spec
|
||||
* @group functional
|
||||
*/
|
||||
class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private static $mustache;
|
||||
|
||||
public static function setUpBeforeClass() {
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$mustache = new Mustache_Engine;
|
||||
}
|
||||
|
||||
@@ -27,7 +28,8 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framew
|
||||
* For some reason data providers can't mark tests skipped, so this test exists
|
||||
* simply to provide a 'skipped' test if the `spec` submodule isn't initialized.
|
||||
*/
|
||||
public function testSpecInitialized() {
|
||||
public function testSpecInitialized()
|
||||
{
|
||||
if (!file_exists(dirname(__FILE__).'/../../../../../vendor/spec/specs/')) {
|
||||
$this->markTestSkipped('Mustache spec submodule not initialized: run "git submodule update --init"');
|
||||
}
|
||||
@@ -37,19 +39,22 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framew
|
||||
* @group lambdas
|
||||
* @dataProvider loadLambdasSpec
|
||||
*/
|
||||
public function testLambdasSpec($desc, $source, $partials, $data, $expected) {
|
||||
public function testLambdasSpec($desc, $source, $partials, $data, $expected)
|
||||
{
|
||||
$template = self::loadTemplate($source, $partials);
|
||||
$this->assertEquals($expected, $template($this->prepareLambdasSpec($data)), $desc);
|
||||
}
|
||||
|
||||
public function loadLambdasSpec() {
|
||||
public function loadLambdasSpec()
|
||||
{
|
||||
return $this->loadSpec('~lambdas');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and lambdafy any 'lambda' values found in the $data array.
|
||||
*/
|
||||
private function prepareLambdasSpec($data) {
|
||||
private function prepareLambdasSpec($data)
|
||||
{
|
||||
foreach ($data as $key => $val) {
|
||||
if ($key === 'lambda') {
|
||||
if (!isset($val['php'])) {
|
||||
@@ -76,7 +81,8 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framew
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
private function loadSpec($name) {
|
||||
private function loadSpec($name)
|
||||
{
|
||||
$filename = dirname(__FILE__) . '/../../../../../vendor/spec/specs/' . $name . '.yml';
|
||||
if (!file_exists($filename)) {
|
||||
return array();
|
||||
@@ -106,7 +112,8 @@ class Mustache_Test_FiveThree_Functional_MustacheSpecTest extends PHPUnit_Framew
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function loadTemplate($source, $partials) {
|
||||
private static function loadTemplate($source, $partials)
|
||||
{
|
||||
self::$mustache->setPartials($partials);
|
||||
|
||||
return self::$mustache->loadTemplate($source);
|
||||
|
||||
Reference in New Issue
Block a user