MyShaarli/tests/Url/GetUrlSchemeTest.php
Guillaume Virlet ef591e7ee2 Url: introduce global helper functions for cleanup and scheme detection
Relates to #314 & #326

Additions:
 - add global `cleanup_url()` and `get_url_scheme()` functions

Modifications:
 - replace `Url` usage in `index.php` by calls to global functions
 - fix `Url` tests not being run: PHPUnit expects a single test class per file
   - move classes to separate files
2015-09-08 22:00:37 +02:00

31 lines
891 B
PHP

<?php
/**
* Unitary tests for get_url_scheme()
*/
require_once 'application/Url.php';
class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
{
/**
* Get empty scheme string for empty Url
*/
public function testGetUrlSchemeEmpty()
{
$this->assertEquals('', get_url_scheme(''));
}
/**
* Get normal scheme of Url
*/
public function testGetUrlScheme()
{
$this->assertEquals('http', get_url_scheme('http://domain.tld:3000'));
$this->assertEquals('https', get_url_scheme('https://domain.tld:3000'));
$this->assertEquals('http', get_url_scheme('domain.tld'));
$this->assertEquals('ssh', get_url_scheme('ssh://domain.tld'));
$this->assertEquals('ftp', get_url_scheme('ftp://domain.tld'));
$this->assertEquals('git', get_url_scheme('git://domain.tld/push?pull=clone#checkout'));
}
}