nextcloud/tests/lib/httphelper.php

48 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* Copyright (c) 2014 Lukas Reschke <lukas@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
class TestHTTPHelper extends \Test\TestCase {
2014-11-27 20:19:14 +03:00
/** @var \OCP\IConfig*/
private $config;
/** @var \OC\HTTPHelper */
private $httpHelperMock;
protected function setUp() {
parent::setUp();
2014-11-27 20:19:14 +03:00
$this->config = $this->getMockBuilder('\OCP\IConfig')
->disableOriginalConstructor()->getMock();
2015-03-16 13:28:23 +03:00
$clientService = $this->getMock('\OCP\Http\Client\IClientService');
$this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper')
2015-03-16 13:28:23 +03:00
->setConstructorArgs(array($this->config, $clientService))
->setMethods(array('getHeaders'))
->getMock();
}
public function isHttpTestData() {
return array(
array('http://wwww.owncloud.org/enterprise/', true),
array('https://wwww.owncloud.org/enterprise/', true),
array('HTTPS://WWW.OWNCLOUD.ORG', true),
array('HTTP://WWW.OWNCLOUD.ORG', true),
array('FILE://WWW.OWNCLOUD.ORG', false),
array('file://www.owncloud.org', false),
array('FTP://WWW.OWNCLOUD.ORG', false),
array('ftp://www.owncloud.org', false),
);
}
/**
* @dataProvider isHttpTestData
*/
public function testIsHTTP($url, $expected) {
$this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url));
}
}