Update to proposed PSR-1 coding standard.

* 4 space (no tab) indent
 * K&R-style braces
This commit is contained in:
Justin Hileman
2012-05-01 22:03:39 -07:00
parent be5cfb3e9e
commit 2448992cc8
57 changed files with 3283 additions and 3009 deletions
@@ -13,128 +13,140 @@
* @group mustache_injection
* @group functional
*/
class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_TestCase {
class Mustache_Test_Functional_MustacheInjectionTest extends PHPUnit_Framework_TestCase
{
private $mustache;
private $mustache;
public function setUp() {
$this->mustache = new Mustache_Engine;
}
public function setUp()
{
$this->mustache = new Mustache_Engine;
}
// interpolation
// interpolation
public function testInterpolationInjection() {
$tpl = $this->mustache->loadTemplate('{{ a }}');
public function testInterpolationInjection()
{
$tpl = $this->mustache->loadTemplate('{{ a }}');
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$this->assertEquals('{{ b }}', $tpl->render($data));
}
$this->assertEquals('{{ b }}', $tpl->render($data));
}
public function testUnescapedInterpolationInjection() {
$tpl = $this->mustache->loadTemplate('{{{ a }}}');
public function testUnescapedInterpolationInjection()
{
$tpl = $this->mustache->loadTemplate('{{{ a }}}');
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$this->assertEquals('{{ b }}', $tpl->render($data));
}
$this->assertEquals('{{ b }}', $tpl->render($data));
}
// sections
// sections
public function testSectionInjection() {
$tpl = $this->mustache->loadTemplate('{{# a }}{{ b }}{{/ a }}');
public function testSectionInjection()
{
$tpl = $this->mustache->loadTemplate('{{# a }}{{ b }}{{/ a }}');
$data = array(
'a' => true,
'b' => '{{ c }}',
'c' => 'FAIL'
);
$data = array(
'a' => true,
'b' => '{{ c }}',
'c' => 'FAIL'
);
$this->assertEquals('{{ c }}', $tpl->render($data));
}
$this->assertEquals('{{ c }}', $tpl->render($data));
}
public function testUnescapedSectionInjection() {
$tpl = $this->mustache->loadTemplate('{{# a }}{{{ b }}}{{/ a }}');
public function testUnescapedSectionInjection()
{
$tpl = $this->mustache->loadTemplate('{{# a }}{{{ b }}}{{/ a }}');
$data = array(
'a' => true,
'b' => '{{ c }}',
'c' => 'FAIL'
);
$data = array(
'a' => true,
'b' => '{{ c }}',
'c' => 'FAIL'
);
$this->assertEquals('{{ c }}', $tpl->render($data));
}
$this->assertEquals('{{ c }}', $tpl->render($data));
}
// partials
// partials
public function testPartialInjection() {
$tpl = $this->mustache->loadTemplate('{{> partial }}');
$this->mustache->setPartials(array(
'partial' => '{{ a }}',
));
public function testPartialInjection()
{
$tpl = $this->mustache->loadTemplate('{{> partial }}');
$this->mustache->setPartials(array(
'partial' => '{{ a }}',
));
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$this->assertEquals('{{ b }}', $tpl->render($data));
}
$this->assertEquals('{{ b }}', $tpl->render($data));
}
public function testPartialUnescapedInjection() {
$tpl = $this->mustache->loadTemplate('{{> partial }}');
$this->mustache->setPartials(array(
'partial' => '{{{ a }}}',
));
public function testPartialUnescapedInjection()
{
$tpl = $this->mustache->loadTemplate('{{> partial }}');
$this->mustache->setPartials(array(
'partial' => '{{{ a }}}',
));
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$data = array(
'a' => '{{ b }}',
'b' => 'FAIL'
);
$this->assertEquals('{{ b }}', $tpl->render($data));
}
$this->assertEquals('{{ b }}', $tpl->render($data));
}
// lambdas
// lambdas
public function testLambdaInterpolationInjection() {
$tpl = $this->mustache->loadTemplate('{{ a }}');
public function testLambdaInterpolationInjection()
{
$tpl = $this->mustache->loadTemplate('{{ a }}');
$data = array(
'a' => array($this, 'lambdaInterpolationCallback'),
'b' => '{{ c }}',
'c' => 'FAIL'
);
$data = array(
'a' => array($this, 'lambdaInterpolationCallback'),
'b' => '{{ c }}',
'c' => 'FAIL'
);
$this->assertEquals('{{ c }}', $tpl->render($data));
}
$this->assertEquals('{{ c }}', $tpl->render($data));
}
public static function lambdaInterpolationCallback() {
return '{{ b }}';
}
public static function lambdaInterpolationCallback()
{
return '{{ b }}';
}
public function testLambdaSectionInjection() {
$tpl = $this->mustache->loadTemplate('{{# a }}b{{/ a }}');
public function testLambdaSectionInjection()
{
$tpl = $this->mustache->loadTemplate('{{# a }}b{{/ a }}');
$data = array(
'a' => array($this, 'lambdaSectionCallback'),
'b' => '{{ c }}',
'c' => 'FAIL'
);
$data = array(
'a' => array($this, 'lambdaSectionCallback'),
'b' => '{{ c }}',
'c' => 'FAIL'
);
$this->assertEquals('{{ c }}', $tpl->render($data));
}
$this->assertEquals('{{ c }}', $tpl->render($data));
}
public static function lambdaSectionCallback($text) {
return '{{ ' . $text . ' }}';
}
public static function lambdaSectionCallback($text)
{
return '{{ ' . $text . ' }}';
}
}