|
|
|
|
@ -243,126 +243,6 @@ class Test_Helper extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
// Url generator methods
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test absolute URL construction
|
|
|
|
|
* @dataProvider provideDocRootURLs
|
|
|
|
|
*/
|
|
|
|
|
function testMakeAbsoluteURLDocRoot($url, $expectedResult) {
|
|
|
|
|
\OC::$WEBROOT = '';
|
|
|
|
|
$result = \OC_Helper::makeURLAbsolute($url);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test absolute URL construction
|
|
|
|
|
* @dataProvider provideSubDirURLs
|
|
|
|
|
*/
|
|
|
|
|
function testMakeAbsoluteURLSubDir($url, $expectedResult) {
|
|
|
|
|
\OC::$WEBROOT = '/owncloud';
|
|
|
|
|
$result = \OC_Helper::makeURLAbsolute($url);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function provideDocRootURLs() {
|
|
|
|
|
return array(
|
|
|
|
|
array('index.php', 'http://localhost/index.php'),
|
|
|
|
|
array('/index.php', 'http://localhost/index.php'),
|
|
|
|
|
array('/apps/index.php', 'http://localhost/apps/index.php'),
|
|
|
|
|
array('apps/index.php', 'http://localhost/apps/index.php'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function provideSubDirURLs() {
|
|
|
|
|
return array(
|
|
|
|
|
array('index.php', 'http://localhost/owncloud/index.php'),
|
|
|
|
|
array('/index.php', 'http://localhost/owncloud/index.php'),
|
|
|
|
|
array('/apps/index.php', 'http://localhost/owncloud/apps/index.php'),
|
|
|
|
|
array('apps/index.php', 'http://localhost/owncloud/apps/index.php'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test linkToAbsolute URL construction
|
|
|
|
|
* @dataProvider provideDocRootAppAbsoluteUrlParts
|
|
|
|
|
*/
|
|
|
|
|
public function testLinkToAbsoluteDocRoot($app, $file, $args, $expectedResult) {
|
|
|
|
|
\OC::$WEBROOT = '';
|
|
|
|
|
$result = \OC_Helper::linkToAbsolute($app, $file, $args);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test linkToAbsolute URL construction in sub directory
|
|
|
|
|
* @dataProvider provideSubDirAppAbsoluteUrlParts
|
|
|
|
|
*/
|
|
|
|
|
public function testLinkToAbsoluteSubDir($app, $file, $args, $expectedResult) {
|
|
|
|
|
\OC::$WEBROOT = '/owncloud';
|
|
|
|
|
$result = \OC_Helper::linkToAbsolute($app, $file, $args);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expectedResult, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function provideDocRootAppAbsoluteUrlParts() {
|
|
|
|
|
return array(
|
|
|
|
|
array('files', 'ajax/list.php', array(), 'http://localhost/index.php/apps/files/ajax/list.php'),
|
|
|
|
|
array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
|
|
|
|
|
array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/index.php?trut=trat&dut=dat'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function provideSubDirAppAbsoluteUrlParts() {
|
|
|
|
|
return array(
|
|
|
|
|
array('files', 'ajax/list.php', array(), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php'),
|
|
|
|
|
array('files', 'ajax/list.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php/apps/files/ajax/list.php?trut=trat&dut=dat'),
|
|
|
|
|
array('', 'index.php', array('trut' => 'trat', 'dut' => 'dat'), 'http://localhost/owncloud/index.php?trut=trat&dut=dat'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test linkToRemoteBase URL construction
|
|
|
|
|
*/
|
|
|
|
|
public function testLinkToRemoteBase() {
|
|
|
|
|
\OC::$WEBROOT = '';
|
|
|
|
|
$result = \OC_Helper::linkToRemoteBase('webdav');
|
|
|
|
|
$this->assertEquals('/remote.php/webdav', $result);
|
|
|
|
|
|
|
|
|
|
\OC::$WEBROOT = '/owncloud';
|
|
|
|
|
$result = \OC_Helper::linkToRemoteBase('webdav');
|
|
|
|
|
$this->assertEquals('/owncloud/remote.php/webdav', $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test linkToRemote URL construction
|
|
|
|
|
*/
|
|
|
|
|
public function testLinkToRemote() {
|
|
|
|
|
\OC::$WEBROOT = '';
|
|
|
|
|
$result = \OC_Helper::linkToRemote('webdav');
|
|
|
|
|
$this->assertEquals('http://localhost/remote.php/webdav/', $result);
|
|
|
|
|
$result = \OC_Helper::linkToRemote('webdav', false);
|
|
|
|
|
$this->assertEquals('http://localhost/remote.php/webdav', $result);
|
|
|
|
|
|
|
|
|
|
\OC::$WEBROOT = '/owncloud';
|
|
|
|
|
$result = \OC_Helper::linkToRemote('webdav');
|
|
|
|
|
$this->assertEquals('http://localhost/owncloud/remote.php/webdav/', $result);
|
|
|
|
|
$result = \OC_Helper::linkToRemote('webdav', false);
|
|
|
|
|
$this->assertEquals('http://localhost/owncloud/remote.php/webdav', $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @small
|
|
|
|
|
* test linkToPublic URL construction
|
|
|
|
|
|