菜谱项目

MiscellaneousTest.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Provider\Miscellaneous;
  4. class MiscellaneousTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function testBoolean()
  7. {
  8. $this->assertContains(Miscellaneous::boolean(), array(true, false));
  9. }
  10. public function testMd5()
  11. {
  12. $this->assertRegExp('/^[a-z0-9]{32}$/', Miscellaneous::md5());
  13. }
  14. public function testSha1()
  15. {
  16. $this->assertRegExp('/^[a-z0-9]{40}$/', Miscellaneous::sha1());
  17. }
  18. public function testSha256()
  19. {
  20. $this->assertRegExp('/^[a-z0-9]{64}$/', Miscellaneous::sha256());
  21. }
  22. public function testLocale()
  23. {
  24. $this->assertRegExp('/^[a-z]{2,3}_[A-Z]{2}$/', Miscellaneous::locale());
  25. }
  26. public function testCountryCode()
  27. {
  28. $this->assertRegExp('/^[A-Z]{2}$/', Miscellaneous::countryCode());
  29. }
  30. public function testCountryISOAlpha3()
  31. {
  32. $this->assertRegExp('/^[A-Z]{3}$/', Miscellaneous::countryISOAlpha3());
  33. }
  34. public function testLanguage()
  35. {
  36. $this->assertRegExp('/^[a-z]{2}$/', Miscellaneous::languageCode());
  37. }
  38. public function testCurrencyCode()
  39. {
  40. $this->assertRegExp('/^[A-Z]{3}$/', Miscellaneous::currencyCode());
  41. }
  42. public function testEmoji()
  43. {
  44. $this->assertRegExp('/^[\x{1F600}-\x{1F637}]$/u', Miscellaneous::emoji());
  45. }
  46. }