Skip to content
Permalink
Browse files

Add a note and more tests for Validation::isScalar()

  • Loading branch information...
chinpei215 committed Jul 26, 2017
1 parent 21415a2 commit 60e082bdda60912fb288c23a44641d544f08a42c
Showing with 9 additions and 1 deletion.
  1. +3 −0 src/Validation/Validation.php
  2. +6 −1 tests/TestCase/Validation/ValidationTest.php
@@ -1426,6 +1426,9 @@ public static function isArray($value)
/**
* Check that the input value is a scalar.
*
* This method will accept integers, floats, strings and booleans, but
* not accept arrays, objects, resources and nulls.
*
* @param mixed $value The value to check
* @return bool
*/
@@ -2886,8 +2886,13 @@ public function testIsArray()
public function testIsScalar()
{
$this->assertTrue(Validation::isScalar(1));
$this->assertTrue(Validation::isScalar(0.0));
$this->assertTrue(Validation::isScalar(''));
$this->assertTrue(Validation::isScalar(true));
$this->assertFalse(Validation::isScalar([1]));
$this->assertFalse(Validation::isScalar(new stdClass()));
$this->assertFalse(Validation::isScalar(STDOUT));
$this->assertFalse(Validation::isScalar(null));
}
/**
@@ -3009,7 +3014,7 @@ public function testNumElements()
};
$this->assertFalse(Validation::numElements(null, '==', 0));
$this->assertFalse(Validation::numElements(new \stdClass(), '==', 0));
$this->assertFalse(Validation::numElements(new stdClass(), '==', 0));
$this->assertFalse(Validation::numElements($callable, '==', 0));
$this->assertFalse(Validation::numElements(false, '==', 0));
$this->assertFalse(Validation::numElements(true, '==', 0));

0 comments on commit 60e082b

Please sign in to comment.
You can’t perform that action at this time.