From: Sergio Santoro Date: Wed, 23 Jul 2014 15:28:50 +0000 (+0200) Subject: GlobalTest: Add test for wfRandomString() X-Git-Tag: 1.31.0-rc.0~14184 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/Category:Foo?a=commitdiff_plain;h=6dc33107dcfe63b84eb96ff1bfc73bc191e7b612;p=lhc%2Fweb%2Fwiklou.git GlobalTest: Add test for wfRandomString() Change-Id: I8e681ed6a32a4a13603cad3cd3dc56545e16220f --- diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index 84799ff23e..3acc48e27c 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -59,13 +59,33 @@ class GlobalTest extends MediaWikiTestCase { ); } + /* + * Test cases for random functions could hypothetically fail, + * even though they shouldn't. + */ + /** * @covers ::wfRandom */ public function testRandom() { - # This could hypothetically fail, but it shouldn't ;) $this->assertFalse( - wfRandom() == wfRandom() ); + wfRandom() == wfRandom() + ); + } + + /** + * @covers ::wfRandomString + */ + public function testRandomString() { + $this->assertFalse( + wfRandomString() == wfRandomString() + ); + $this->assertEquals( + strlen( wfRandomString( 10 ) ), 10 + ); + $this->assertTrue( + preg_match( '/^[0-9a-f]+$/i', wfRandomString() ) === 1 + ); } /**