You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TextTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Provider\en_US\Text;
  4. use Faker\Generator;
  5. class TextTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testTextMaxLength()
  8. {
  9. $generator = new Generator();
  10. $generator->addProvider(new Text($generator));
  11. $generator->seed(0);
  12. $lengths = array(10, 20, 50, 70, 90, 120, 150, 200, 500);
  13. foreach ($lengths as $length) {
  14. $this->assertLessThan($length, $generator->realText($length));
  15. }
  16. }
  17. /**
  18. * @expectedException \InvalidArgumentException
  19. */
  20. public function testTextMaxIndex()
  21. {
  22. $generator = new Generator();
  23. $generator->addProvider(new Text($generator));
  24. $generator->seed(0);
  25. $generator->realText(200, 11);
  26. }
  27. /**
  28. * @expectedException \InvalidArgumentException
  29. */
  30. public function testTextMinIndex()
  31. {
  32. $generator = new Generator();
  33. $generator->addProvider(new Text($generator));
  34. $generator->seed(0);
  35. $generator->realText(200, 0);
  36. }
  37. /**
  38. * @expectedException \InvalidArgumentException
  39. */
  40. public function testTextMinLength()
  41. {
  42. $generator = new Generator();
  43. $generator->addProvider(new Text($generator));
  44. $generator->seed(0);
  45. $generator->realText(9);
  46. }
  47. }