<?php/********************************************************************************************
* BlueShoes Framework; This file is part of the php application framework.
* NOTE: This code is stripped (obfuscated). To get the clean documented code goto 
*       www.blueshoes.org and register for the free open source *DEVELOPER* version or 
*       buy the commercial version.
*       
*       In case you've already got the developer version, then this is one of the few 
*       packages/classes that is only available to *PAYING* customers.
*       To get it go to www.blueshoes.org and buy a commercial version.
* 
* @copyright www.blueshoes.org
* @author    Samuel Blume <sam at blueshoes dot org>
* @author    Andrej Arn <andrej at blueshoes dot org>
*/?><?php
require_once($APP['path']['core'] . 'net/Bs_Url.class.php');class Bs_Url_PhpUnit extends Bs_TestCase {var $_Bs_Url;function Bs_Url_PhpUnit($name) {$this->Bs_TestCase($name);$this->_Bs_Url        = &$GLOBALS['Bs_Url'];}
function __Bs_Url_realUrl() {$expected = 'http://www.domain.com/foo/file.htm';$url      = 'http://www.domain.com/foo/bar/../file.htm';$actual   = $this->_Bs_Url->realUrl($url);$this->assertEquals($expected, $actual, $url);$expected = 'http://www.domain.com/foo/bar/file.htm';$url      = 'http://www.domain.com/foo/bar/./file.htm';$actual   = $this->_Bs_Url->realUrl($url);$this->assertEquals($expected, $actual, $url);$expected = '/foo/bar/file.htm';$url      = '/foo/bar/./file.htm';$actual   = $this->_Bs_Url->realUrl($url);$this->assertEquals($expected, $actual, $url);$expected = 'foo/bar/file.htm';$url      = 'foo//bar/.//file.htm';$actual   = $this->_Bs_Url->realUrl($url);$this->assertEquals($expected, $actual, $url);}
function __Bs_Url_checkSyntax() {$expected = TRUE;$url = 'http://www.domain.com';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = TRUE;$url = 'scheme://user:pass@host:port/path?query#fragment';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = TRUE;$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = FALSE;$url = 'my@email.com';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = FALSE;$url = 'mailto:this.is.my@super.cool.email.to';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = TRUE;$url = 'mailto://this.is.my@super.cool.email.to';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);$expected = FALSE;$url = 'someshit';$actual = $this->_Bs_Url->checkSyntax($url);$this->assertEquals($expected, $actual, $url);}
function __Bs_Url_parseUrlExtended() {$expected = array('scheme'=>'https', 'host'=> 'order.blue-shoes.com', 'port'=>81, 
'user'=> 'bill', 'pass'=> 'gates', 'path'=> '/forms/form.php', 
'query'=> 'lang=fr&sid=456456', 'fragment'=>'address', 
'domain'=>'blue-shoes.com', 'directory'=>'/forms/', 'file'=>'form.php', 
'extension'=>'php');$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$actual = $this->_Bs_Url->parseUrlExtended($url);$this->assertEquals($expected, $actual, $url);$expected = array('scheme'=>'http', 'host'=> 'order.blue-shoes.com', 
'path'=> '/forms/', 
'domain'=>'blue-shoes.com', 'directory'=>'/forms/');$url = 'http://order.blue-shoes.com/forms/';$actual = $this->_Bs_Url->parseUrlExtended($url);$this->assertEquals($expected, $actual, $url);}
function __Bs_Url_getUrlJunk() {$expected = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$actual = $this->_Bs_Url->getUrlJunk('suPhopqF', $url);$this->assertEquals($expected, $actual, 'test 1, source was: ' . $url);$expected = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$actual = $this->_Bs_Url->getUrlJunk('1', $url);$this->assertEquals($expected, $actual, 'test 2, source was: ' . $url);$expected = 'https://order.blue-shoes.com/forms/form.php';$url = 'https://order.blue-shoes.com/forms/form.php';$actual = $this->_Bs_Url->getUrlJunk('suPhopqF', $url);$this->assertEquals($expected, $actual, 'stest 3, ource was: ' . $url);$expected = 'http://bill@order.blue-shoes.com/forms/form.php#address';$url = 'http://bill@order.blue-shoes.com:80/forms/form.php#address';$actual = $this->_Bs_Url->getUrlJunk('suPhOpqF', $url);$this->assertEquals($expected, $actual, 'test 4, source was: ' . $url);}
function __Bs_Url_explodeIp() {$ip = '127.0.';  $expected = FALSE;$actual = $this->_Bs_Url->explodeIp($ip);$this->assertEquals($expected, $actual);$ip = FALSE;  $expected = FALSE;$actual = $this->_Bs_Url->explodeIp($ip);$this->assertEquals($expected, $actual);$ip = '127.0.0.1';  $expected = array('127', '000', '000', '001');$actual = $this->_Bs_Url->explodeIp($ip, TRUE);$this->assertEquals($expected, $actual);$ip = '127.0.0.1';  $expected = array('127', '0', '0', '1');$actual = $this->_Bs_Url->explodeIp($ip);$this->assertEquals($expected, $actual);}
function __Bs_Url_glueUrl() {$expected = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$actual = $this->_Bs_Url->glueUrl(parse_url($expected));$this->assertEquals($expected, $actual, '');}
function __Bs_Url_getDomain4url() {$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$expected = 'com';$actual = $this->_Bs_Url->getDomain4url($url, 1);$this->assertEquals($expected, $actual, "with param: '1' and url: '{$url}'");$expected = 'blue-shoes.com';$actual = $this->_Bs_Url->getDomain4url($url);$this->assertEquals($expected, $actual, "with param: 'none' and url: '{$url}'");$expected = 'blue-shoes.com';$actual = $this->_Bs_Url->getDomain4url($url, 2);$this->assertEquals($expected, $actual, "with param: '2' and url: '{$url}'");$expected = 'order.blue-shoes.com';$actual = $this->_Bs_Url->getDomain4url($url, -1);$this->assertEquals($expected, $actual, "with param: '-1' and url: '{$url}'");$expected = 'order.blue-shoes.com';$actual = $this->_Bs_Url->getDomain4url($url, 3);$this->assertEquals($expected, $actual, "with param: '3' and url: '{$url}'");}
function __Bs_Url_getDirectory4url() {$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$expected = '/forms/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'ftp://order.blue-shoes.com/forms/dir/another-dir/form.php?lang=fr&sid=456456#address';$expected = '/forms/dir/another-dir/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://www.blue-shoes.com:81/file.html';$expected = '/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://www.blue-shoes.com:81/file';$expected = '/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://www.blue-shoes.com/dir/file';$expected = '/dir/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81/unknown';$expected = '/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81/';$expected = '/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81';$expected = '/';$actual = $this->_Bs_Url->getDirectory4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");}
function __Bs_Url_getFile4url() {$url = 'https://bill:gates@order.blue-shoes.com:81/forms/form.php?lang=fr&sid=456456#address';$expected = 'form.php';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81/forms/';$expected = '';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81/file.html';$expected = 'file.html';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com:81/unknown';$expected = 'unknown';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com/';$expected = '';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'http://blue-shoes.com';$expected = '';$actual = $this->_Bs_Url->getFile4url($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");}
function __Bs_Url_hashArrayToQueryString() {$expected = '&in[a][color]=green&in[a][message]=hello+world';$hash['in']['a']['color']   = 'green';$hash['in']['a']['message'] = 'hello world';$actual = $this->_Bs_Url->hashArrayToQueryString($hash);$this->assertEquals($expected, $actual, '');$expected = '&0=foo&1=bar';$hash = array('foo', 'bar');$actual = $this->_Bs_Url->hashArrayToQueryString($hash);$this->assertEquals($expected, $actual, '');$expected = '&aPoorMansNamespace[in][a][color]=green&aPoorMansNamespace[in][a][message]=hello+world';unset($hash);$hash['in']['a']['color']   = 'green';$hash['in']['a']['message'] = 'hello world';$key = 'aPoorMansNamespace';$actual = $this->_Bs_Url->hashArrayToQueryString($hash, $key);$this->assertEquals($expected, $actual, '');$expected = '';$hash = 'lalala';$actual = $this->_Bs_Url->hashArrayToQueryString($hash);$this->assertEquals($expected, $actual, '');}
function __Bs_Url_similar() {$urlOne = '/';$urlTwo = '';$expected = TRUE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/this/is/url/one/';$urlTwo = '/la/lo/li/lala/l/';$expected = FALSE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/url/with/same/end/directory/';$urlTwo = '/another/thing/lala/lolo/directory';$expected = TRUE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/url/with/same/end/directory/';$urlTwo = '/another/thing/lala/lolo/directory/adf';$expected = TRUE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/url/with/same/end/directory/';$urlTwo = '/another/thing/lala/lolo/directory/adf.html';$expected = TRUE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/url/with/same/end/directory/';$urlTwo = '/another/thing/lala/lolo/directory.html';$expected = FALSE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");$urlOne = '/url/with/typo/';$urlTwo = 'url/wit/typpo';$expected = TRUE;$actual = $this->_Bs_Url->similar($urlOne, $urlTwo);$this->assertEquals($expected, $actual, "url one: '{$urlOne}'  url two: '{$urlTwo}'");}
function __Bs_Url_getLastDir() {$url = '/some/thing/';$expected = 'thing';$actual = $this->_Bs_Url->getLastDir($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = '/some/thing';$expected = array('thing', 'some');$actual = $this->_Bs_Url->getLastDir($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");$url = 'some/thing.html';$expected = 'some';$actual = $this->_Bs_Url->getLastDir($url);$this->assertEquals($expected, $actual, "url was: '{$url}'");}
function __Bs_Url_crossUrlDecode() {$string   = '%20';$expected = ' ';$actual = $this->_Bs_Url->crossUrlDecode($string);$this->assertEquals($expected, $actual, "string was: '{$string}'");}
}
?>