From 30d23077c8cabfb35358d6934687ceea828429d5 Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Fri, 14 Oct 2011 13:25:07 -0700 Subject: [PATCH] Use strict equality for unknown pragma check. Yay PHP! Also, update tests. --- Mustache.php | 2 +- test/MustacheTest.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Mustache.php b/Mustache.php index 7d909df..1477db3 100644 --- a/Mustache.php +++ b/Mustache.php @@ -133,7 +133,7 @@ class Mustache { if (isset($options['pragmas'])) { foreach ($options['pragmas'] as $pragma_name => $pragma_value) { - if (!in_array($pragma_name, $this->_pragmasImplemented)) { + if (!in_array($pragma_name, $this->_pragmasImplemented, true)) { throw new MustacheException('Unknown pragma: ' . $pragma_name, MustacheException::UNKNOWN_PRAGMA); } } diff --git a/test/MustacheTest.php b/test/MustacheTest.php index 1a06b46..0c0bb13 100644 --- a/test/MustacheTest.php +++ b/test/MustacheTest.php @@ -94,21 +94,21 @@ class MustacheTest extends PHPUnit_Framework_TestCase { array( 'charset' => 'UTF-8', 'delimiters' => '<< >>', - 'pragmas' => array(Mustache::PRAGMA_UNESCAPED) + 'pragmas' => array(Mustache::PRAGMA_UNESCAPED => true) ), 'UTF-8', array('<<', '>>'), - array(Mustache::PRAGMA_UNESCAPED), + array(Mustache::PRAGMA_UNESCAPED => true), ), array( array( 'charset' => 'cp866', 'delimiters' => array('[[[[', ']]]]'), - 'pragmas' => array(Mustache::PRAGMA_UNESCAPED) + 'pragmas' => array(Mustache::PRAGMA_UNESCAPED => true) ), 'cp866', array('[[[[', ']]]]'), - array(Mustache::PRAGMA_UNESCAPED), + array(Mustache::PRAGMA_UNESCAPED => true), ), ); } @@ -117,7 +117,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase { * @expectedException MustacheException */ public function testConstructorInvalidPragmaOptionsThrowExceptions() { - $mustache = new Mustache(null, null, null, array('pragmas' => array('banana phone'))); + $mustache = new Mustache(null, null, null, array('pragmas' => array('banana phone' => true))); } /** @@ -195,7 +195,7 @@ class MustacheTest extends PHPUnit_Framework_TestCase { $this->assertEquals('Charlie Chaplin', $m->render(null, array('first_name' => 'Charlie', 'last_name' => 'Chaplin'))); $this->assertEquals('Zappa, Frank', $m->render('{{last_name}}, {{first_name}}', array('first_name' => 'Frank', 'last_name' => 'Zappa'))); } - + /** * @group interpolation * @dataProvider interpolationData