From b8b156d3cca8e7983b52aafff079822c413fb0ae Mon Sep 17 00:00:00 2001 From: Justin Hileman Date: Tue, 25 Mar 2014 19:35:56 -0700 Subject: [PATCH] Refactor to remove strict callables test duplication. --- .../Functional/StrictCallablesTest.php | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php b/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php index 2925217..479e038 100644 --- a/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php +++ b/test/Mustache/Test/FiveThree/Functional/StrictCallablesTest.php @@ -18,9 +18,9 @@ class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Fra /** * @dataProvider callables */ - public function testStrictCallablesDisabled($name, $section, $expected) + public function testStrictCallables($strict, $name, $section, $expected) { - $mustache = new Mustache_Engine(array('strict_callables' => false)); + $mustache = new Mustache_Engine(array('strict_callables' => $strict)); $tpl = $mustache->loadTemplate('{{# section }}{{ name }}{{/ section }}'); $data = new StdClass; @@ -39,16 +39,19 @@ class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Fra return array( // Interpolation lambdas array( + false, array($this, 'instanceName'), $lambda, 'YOSHI', ), array( + false, array(__CLASS__, 'staticName'), $lambda, 'YOSHI', ), array( + false, function () { return 'Yoshi'; }, $lambda, 'YOSHI', @@ -56,64 +59,47 @@ class Mustache_Test_FiveThree_Functional_StrictCallablesTest extends PHPUnit_Fra // Section lambdas array( + false, 'Yoshi', array($this, 'instanceCallable'), 'YOSHI', ), array( + false, 'Yoshi', array(__CLASS__, 'staticCallable'), 'YOSHI', ), array( + false, 'Yoshi', $lambda, 'YOSHI', ), - ); - } - /** - * @dataProvider strictCallables - */ - public function testStrictCallablesEnabled($name, $section, $expected) - { - $mustache = new Mustache_Engine(array('strict_callables' => true)); - $tpl = $mustache->loadTemplate('{{# section }}{{ name }}{{/ section }}'); - - $data = new StdClass; - $data->name = $name; - $data->section = $section; - - $this->assertEquals($expected, $tpl->render($data)); - } - - public function strictCallables() - { - $lambda = function ($tpl, $mustache) { - return strtoupper($mustache->render($tpl)); - }; - - return array( - // Interpolation lambdas + // Strict interpolation lambdas array( + true, function () { return 'Yoshi'; }, $lambda, 'YOSHI', ), - // Section lambdas + // Strict section lambdas array( + true, 'Yoshi', array($this, 'instanceCallable'), 'YoshiYoshi', ), array( + true, 'Yoshi', array(__CLASS__, 'staticCallable'), 'YoshiYoshi', ), array( + true, 'Yoshi', function ($tpl, $mustache) { return strtoupper($mustache->render($tpl));