httphelper.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. class TestHTTPHelper extends \Test\TestCase {
  9. /** @var \OCP\IConfig*/
  10. private $config;
  11. /** @var \OC\HTTPHelper */
  12. private $httpHelperMock;
  13. protected function setUp() {
  14. parent::setUp();
  15. $this->config = $this->getMockBuilder('\OCP\IConfig')
  16. ->disableOriginalConstructor()->getMock();
  17. $clientService = $this->getMock('\OCP\Http\Client\IClientService');
  18. $this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
  19. ->setConstructorArgs(array($this->config, $clientService))
  20. ->setMethods(array('getHeaders'))
  21. ->getMock();
  22. }
  23. public function isHttpTestData() {
  24. return array(
  25. array('http://wwww.owncloud.org/enterprise/', true),
  26. array('https://wwww.owncloud.org/enterprise/', true),
  27. array('HTTPS://WWW.OWNCLOUD.ORG', true),
  28. array('HTTP://WWW.OWNCLOUD.ORG', true),
  29. array('FILE://WWW.OWNCLOUD.ORG', false),
  30. array('file://www.owncloud.org', false),
  31. array('FTP://WWW.OWNCLOUD.ORG', false),
  32. array('ftp://www.owncloud.org', false),
  33. );
  34. }
  35. /**
  36. * @dataProvider isHttpTestData
  37. */
  38. public function testIsHTTP($url, $expected) {
  39. $this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
  40. }
  41. }