選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
1.3KB

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