mirror of
https://github.com/fzaninotto/Faker.git
synced 2025-03-25 17:59:47 +01:00
parent
470033ae8e
commit
d022072b5a
@ -102,15 +102,15 @@ class Base
|
||||
/**
|
||||
* Returns a random number between $from and $to
|
||||
*
|
||||
* @param integer $from
|
||||
* @param integer $to
|
||||
* @param integer $from default to 0
|
||||
* @param integer $to defaults to 32 bit max integer, ie 2147483647
|
||||
* @example 79907610
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function numberBetween($from = null, $to = null)
|
||||
public static function numberBetween($from = 0, $to = 2147483647)
|
||||
{
|
||||
return mt_rand($from ?: 0, $to ?: 2147483647); // 32bit compat default
|
||||
return mt_rand($from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,11 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertGreaterThanOrEqual(BaseProvider::numberBetween($min, $max), $max);
|
||||
}
|
||||
|
||||
public function testNumberBetweenAcceptsZeroAsMax()
|
||||
{
|
||||
$this->assertEquals(0, BaseProvider::numberBetween(0, 0));
|
||||
}
|
||||
|
||||
public function testRandomFloat()
|
||||
{
|
||||
$min = 4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user