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. 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. }