UserAgentTest.php 921 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Faker\Test\Provider;
  3. use Faker\Provider\UserAgent;
  4. use PHPUnit\Framework\TestCase;
  5. class UserAgentTest extends TestCase
  6. {
  7. public function testRandomUserAgent()
  8. {
  9. $this->assertNotNull(UserAgent::userAgent());
  10. }
  11. public function testFirefoxUserAgent()
  12. {
  13. $this->stringContains(' Firefox/', UserAgent::firefox());
  14. }
  15. public function testSafariUserAgent()
  16. {
  17. $this->stringContains('Safari/', UserAgent::safari());
  18. }
  19. public function testInternetExplorerUserAgent()
  20. {
  21. $this->assertStringStartsWith('Mozilla/5.0 (compatible; MSIE ', UserAgent::internetExplorer());
  22. }
  23. public function testOperaUserAgent()
  24. {
  25. $this->assertStringStartsWith('Opera/', UserAgent::opera());
  26. }
  27. public function testChromeUserAgent()
  28. {
  29. $this->stringContains('(KHTML, like Gecko) Chrome/', UserAgent::chrome());
  30. }
  31. }