From 265cff175eb1c0be4b59d937286059532361820f Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Tue, 15 Jan 2019 18:36:10 -0500 Subject: [PATCH] Fixed function parameter order Corrected $places default value for addFunction to match TokenFactory Added function order test and put expected order first in assertEquals If else blocks in calculator Updated docs --- tests/MathTest.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/MathTest.php b/tests/MathTest.php index 8eb7827..81f0230 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -138,7 +138,11 @@ class MathTest extends \PHPUnit_Framework_TestCase { $calculator = new MathExecutor(); - $calculator->addFunction('concat', function ($arg1, $arg2) {return $arg1.$arg2;}); + $calculator->addFunction('concat', function ($arg1, $arg2) + { + return $arg1.$arg2; + } + ); $this->assertEquals('testing', $calculator->execute('concat("test","ing")')); $this->assertEquals('testing', $calculator->execute("concat('test','ing')")); } @@ -147,19 +151,19 @@ class MathTest extends \PHPUnit_Framework_TestCase { $calculator = new MathExecutor(); $calculator->addFunction('round', function ($arg) {return round($arg);}); - /** @var float $phpResult */ - eval('$phpResult = round(100/30);'); - $this->assertEquals($phpResult, $calculator->execute('round(100/30)')); + $this->assertEquals(round(100/30), $calculator->execute('round(100/30)')); } public function testQuotes() { $calculator = new MathExecutor(); $testString = "some, long. arg; with: different-separators!"; - $calculator->addFunction('test', function ($arg) use ($testString) { - $this->assertEquals($testString, $arg); - return 0;} - ); + $calculator->addFunction('test', function ($arg) use ($testString) + { + $this->assertEquals($testString, $arg); + return 0; + } + ); $calculator->execute('test("' . $testString . '")'); // single quotes $calculator->execute("test('" . $testString . "')"); // double quotes }