Ejemplo n.º 1
0
 public function test_string()
 {
     $count = 2000;
     $buckets = array_combine(str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), array_fill(0, 62, 0));
     for ($i = 1; $i <= $count; $i++) {
         $len = mt_rand(2, 256);
         $str = PHPRandom::getString($len);
         $this->assertEquals($len, strlen($str));
         $this->assertEquals(true, isset($buckets[$str[0]]));
         $buckets[$str[0]]++;
     }
     $distribution = 0;
     foreach ($buckets as $key => $value) {
         if ($value > $count / 62 * 0.5) {
             $distribution++;
         }
         if ($value < $count / 62 * 1.5) {
             $distribution++;
         }
     }
     $this->assertGreaterThan(62, $distribution);
 }