Merge "IndexPager: Introduce constants for values of $mDefaultDirection"
[lhc/web/wiklou.git] / tests / phpunit / includes / GlobalFunctions / GlobalTest.php
index 91b531d..3acc48e 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group GlobalFunctions
+ */
 class GlobalTest extends MediaWikiTestCase {
        protected function setUp() {
                parent::setUp();
@@ -56,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
+               );
        }
 
        /**
@@ -718,5 +741,5 @@ class GlobalTest extends MediaWikiTestCase {
                        ),
                );
        }
-       /* @TODO many more! */
+       /* @todo many more! */
 }