Coding standards fixes.

This commit is contained in:
Justin Hileman
2012-08-02 10:36:07 -07:00
parent 345a0c45f7
commit 277288137b
6 changed files with 35 additions and 23 deletions
+2 -1
View File
@@ -244,7 +244,8 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
}
}
class MustacheStub extends Mustache_Engine {
class MustacheStub extends Mustache_Engine
{
public $source;
public $template;
public function loadTemplate($source)
@@ -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);
@@ -116,7 +116,7 @@ class Mustache_Test_Functional_ExamplesTest extends PHPUnit_Framework_TestCase
*
* @param string $path
*
* @return array $partials
* @return array $partials
*/
private function loadPartials($path)
{
@@ -49,7 +49,6 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
$this->assertEquals('{{ b }}', $tpl->render($data));
}
// sections
public function testSectionInjection()
@@ -78,7 +77,6 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
$this->assertEquals('{{ c }}', $tpl->render($data));
}
// partials
public function testPartialInjection()
@@ -111,7 +109,6 @@ class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_T
$this->assertEquals('{{ b }}', $tpl->render($data));
}
// lambdas
public function testLambdaInterpolationInjection()
+2 -1
View File
@@ -1,6 +1,7 @@
<?php
class Partials {
class Partials
{
public $page = array(
'title' => 'Page Title',
'subtitle' => 'Page Subtitle',