summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2015-12-31 14:44:17 +0100
committerNicolas Grekas <nicolas.grekas@gmail.com>2015-12-31 14:44:17 +0100
commitf27e710b70ea957b1d081b733441947f24b8c10c (patch)
treea7f4fe32a47d2206ffd41277b915b6571cc83666
parentd762ee5b099a29044603cd4649851e81aa66cb47 (diff)
downloadrandom_compat-f27e710b70ea957b1d081b733441947f24b8c10c.zip
random_compat-f27e710b70ea957b1d081b733441947f24b8c10c.tar.gz
random_compat-f27e710b70ea957b1d081b733441947f24b8c10c.tar.bz2
Add RandomIntTest::testRandomRange
-rw-r--r--.travis.yml30
-rw-r--r--tests/unit/RandomIntTest.php11
2 files changed, 24 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml
index 43ec127..eee4a11 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,26 +1,22 @@
language: php
-php:
-
-- "7.0"
-- "5.6"
-- "5.5"
-- "5.4"
-- "5.3"
-- "hhvm"
-
-
sudo: false
+php:
+ - "7.0"
+ - "5.6"
+ - "5.5"
+ - "5.4"
+ - "5.3"
+ - "hhvm"
+
matrix:
fast_finish: true
allow_failures:
- - php: "hhvm"
+ - php: "hhvm"
install:
+ - composer self-update
+ - composer update
-- composer install
-- composer self-update
-- composer update
-- chmod +x ./phpunit.sh
-
-script: ./phpunit.sh travis
+script:
+ - ./phpunit.sh
diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php
index f9fc3c3..6b94a99 100644
--- a/tests/unit/RandomIntTest.php
+++ b/tests/unit/RandomIntTest.php
@@ -49,4 +49,15 @@ class RandomIntTest extends PHPUnit_Framework_TestCase
$this->assertTrue($ex instanceof Exception);
}
}
+
+ public function testRandomRange()
+ {
+ $try = 64;
+ $maxLen = strlen(~PHP_INT_MAX);
+ do {
+ $rand = random_int(~PHP_INT_MAX, PHP_INT_MAX);
+ } while (strlen($rand) !== $maxLen && $try--);
+
+ $this->assertGreaterThan(0, $try);
+ }
}