RandomLibTest.php 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. App::uses('RandomLib', 'Tools.Lib');
  3. class RandomLibTest extends CakeTestCase {
  4. public function testInt() {
  5. $is = RandomLib::int(2, 200);
  6. pr($is);
  7. $this->assertTrue($is >= 2 && $is <= 200);
  8. }
  9. public function testArrayValue() {
  10. $array = array(
  11. 'x',
  12. 'y',
  13. 'z',
  14. );
  15. $is = RandomLib::arrayValue($array, null, null, true);
  16. pr($is);
  17. $this->assertTrue(in_array($is, $array));
  18. # non-numerical indexes
  19. $array = array(
  20. 'e' => 'x',
  21. 'f' => 'y',
  22. 'g' => 'z',
  23. );
  24. $is = RandomLib::arrayValue($array);
  25. pr($is);
  26. $this->assertTrue(in_array($is, $array));
  27. }
  28. public function testPronounceablePwd() {
  29. $is = RandomLib::pronounceablePwd(6);
  30. pr($is);
  31. $this->assertTrue(strlen($is) === 6);
  32. $is = RandomLib::pronounceablePwd(11);
  33. pr($is);
  34. $this->assertTrue(strlen($is) === 11);
  35. }
  36. //TOOD: other tests
  37. }