[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/_test/tests/inc/ -> auth_random.test.php (source)

   1  <?php
   2  
   3  /**
   4   * Tests the random generator functions
   5   */
   6  class auth_random_test extends DokuWikiTest {
   7      function testRandomRange() {
   8          $rand = auth_random(300, 2000);
   9          $this->assertTrue($rand <= 2000, 'The generated number was above the limit');
  10          $this->assertTrue($rand >= 300, 'The generate number was too low');
  11      }
  12  
  13      function testLargeRandoms() {
  14          $min = (1 << 30);
  15          $max = $min + (1 << 33) + 17;
  16          $rand = auth_random($min, $max);
  17          $this->assertTrue($rand >= $min, 'The generated number was too low');
  18          $this->assertTrue($rand <= $max, 'The generated number was too high');
  19      }
  20  }