TextTest.php 1.3 KB

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