From d9eb39e38d090eaf00904a37d04aef6db4ceadac Mon Sep 17 00:00:00 2001 From: Bruce Wells Date: Tue, 15 Sep 2020 21:27:43 -0400 Subject: Improved unit tests (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Variable fixes (#67) * Reproduce if throws UnknownOperatorException * Fix variable detection * Adding IncorrectNumberOfFunctionParametersException * Removing tabs * Better exception message text * Handler for not found variables (#68) * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Release prep (#69) * String comparison unit tests * getVars and getFunctions sanity checks * Add dynamic variable documentation * Better setVar error message (#70) Additional unit tests Readme update * Improved support for null variables (#72) * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Better support for null variables * Better support for null variables * Better support for null variables * Allow null values in `setVar` method (#73) * Added handler to define not found variables Added support for string variables Fixed strings and ints comparison error * Check if variables have scalar types (int, float, string and bool) Better $onVarNotFound logic * Better support for null variables * Better support for null variables * Better support for null variables * Allow null values in `setVar` method * Better unit testing Co-authored-by: Javier MarĂ­n --- tests/MathTest.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/MathTest.php b/tests/MathTest.php index c519c5c..4ea0cb0 100644 --- a/tests/MathTest.php +++ b/tests/MathTest.php @@ -45,7 +45,7 @@ class MathTest extends TestCase * * Most tests can go in here. The idea is that each expression will be evaluated by MathExecutor and by PHP with eval. * The results should be the same. If they are not, then the test fails. No need to add extra test unless you are doing - * something more complete and not a simple mathmatical expression. + * something more complex and not a simple mathmatical expression. */ public function providerExpressions() { @@ -501,25 +501,25 @@ class MathTest extends TestCase $calculator->setVar('boolTrue', true); $calculator->setVar('boolFalse', false); $calculator->setVar('int', 1); + $calculator->setVar('null', null); $calculator->setVar('float', 1.1); $calculator->setVar('string', 'string'); - $this->assertEquals(7, count($calculator->getVars())); + $this->assertEquals(8, count($calculator->getVars())); + $this->assertEquals(true, $calculator->getVar('boolTrue')); + $this->assertEquals(false, $calculator->getVar('boolFalse')); + $this->assertEquals(1, $calculator->getVar('int')); + $this->assertEquals(null, $calculator->getVar('null')); + $this->assertEquals(1.1, $calculator->getVar('float')); + $this->assertEquals('string', $calculator->getVar('string')); } - public function testSetVarsDoesNoAcceptObject() + public function testSetVarsDoesNotAcceptObject() { $calculator = new MathExecutor(); $this->expectException(MathExecutorException::class); $calculator->setVar('object', $this); } - public function testSetVarsDoesNotAcceptNull() - { - $calculator = new MathExecutor(); - $this->expectException(MathExecutorException::class); - $calculator->setVar('null', null); - } - public function testSetVarsDoesNotAcceptResource() { $calculator = new MathExecutor(); -- cgit v1.2.3