aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Wells <brucekwells@gmail.com>2020-09-16 04:27:43 +0300
committerGitHub <noreply@github.com>2020-09-16 04:27:43 +0300
commitd9eb39e38d090eaf00904a37d04aef6db4ceadac (patch)
tree2c54b277157e0ba0e82adba86e3fe4989959f433
parent8aa6674831c7c2329d06b8dc9db7801cb4997695 (diff)
Improved unit tests (#74)V2.1.4
* 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 <javier@marinros.com>
-rw-r--r--tests/MathTest.php20
1 files changed, 10 insertions, 10 deletions
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();