MiscellaneousTest.php 1.4 KB

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