#!/www/server/bin/php -qC
<?php

# Tests for url.class, currently only constructor's parser

# Create object and parse url
$url = new it_url('HTTP://falcon:joshua@www.Relog.CH:80/default.asp');

is(
	$url->url,
	'http://www.relog.ch/',
	'$url->url'
);

is(
	$url->protocol,
	'http',
	'$url->protocol'
);

is(
	$url->hostname,
	'relog.ch',
	'$url->hostname'
);

is(
	$url->realhostname,
	'www.relog.ch',
	'$url->realhostname'
);

is(
	$url->port,
	80,
	'$url->port'
);

is(
	$url->path,
	'',
	'$url->path'
);

is(
	$url->user,
	'falcon',
	'$url->user'
);

is(
	$url->pass,
	'joshua',
	'$url->pass'
);

# and now check for path
$url = new it_url('HTTP://falcon:joshua@www.Relog.CH:80/foo/bar.html');

is(
	$url->path,
	'foo/bar.html',
	'$url->path'
);

$_SERVER['HTTP_HOST'] = "gna.ch";
is(
	it_url::absolute("/"),
	'http://gna.ch:/',
	'it_url::absolute basic'
);

$_SERVER['SERVER_PORT'] = 42;
is(
	it_url::absolute("/port"),
	'http://gna.ch:42/port',
	'it_url::absolute with non-standard port'
);

$_SERVER['HTTPS'] = true;
$_SERVER['SERVER_PORT'] = 443;
is(
	it_url::absolute("/https"),
	'https://gna.ch/https',
	'it_url::absolute for https'
);

?>