<?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/http/Bs_HttpClient.class.php');require_once($APP['path']['core'] . 'net/Bs_Url.class.php');class Bs_HttpClient_PhpUnit extends Bs_TestCase {var $_APP;var $_Bs_HttpClient;var $_Bs_Url;var $host = 'http://developer.blueshoes.org/';function Bs_HttpClient_PhpUnit($name) {$this->Bs_TestCase($name);$this->_APP           = &$GLOBALS['APP'];$this->_Bs_HttpClient = new Bs_HttpClient();$this->_Bs_Url        = &$GLOBALS['Bs_Url'];}
function __Bs_HttpClient_fetchPage_1() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' not found in fetched webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_2() {$url = $this->host . 'ecg/pageBasic.html';$page = $this->_Bs_HttpClient->fetchPage($url);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' not found in fetched webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_3() {$url = $this->host . 'this/does/not/exist_456465.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 404;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');}
function __Bs_HttpClient_fetchPage_4() {$url = $this->host . 'ecg/301_movedPermanently.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$this->_Bs_HttpClient->followRedirect = 0;$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 301;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');}
function __Bs_HttpClient_fetchPage_4_1() {$url = $this->host . 'ecg/301_movedPermanently.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode after redirect');}
function __Bs_HttpClient_fetchPage_5() {$url = $this->host . 'ecg/302_movedTemporarily.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$this->_Bs_HttpClient->followRedirect = 0;$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 302;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');}
function __Bs_HttpClient_fetchPage_5_1() {$url = $this->host . 'ecg/302_movedTemporarily.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');}
function __Bs_HttpClient_fetchPage_6() {$url = $this->host . 'ecg/pageNeedBasicAuthentication.html';$page = $this->_Bs_HttpClient->fetchPage($url);$expected = 401;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');echo "i know that this fails, the server is not configured the way it should. the code is fine.";}
function __Bs_HttpClient_fetchPage_6_1() {$url = $this->host . 'ecg/pageNeedBasicAuthentication.html';$this->_Bs_HttpClient->setAuthenticationBasic('bill', 'gates');$page = $this->_Bs_HttpClient->fetchPage($url);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');}
function __Bs_HttpClient_fetchPage_7() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$this->_Bs_HttpClient->addHeaders['If-Modified-Since'] = 'Sat, 29 Oct 1994 19:43:31 GMT';$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' not found in fetched webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_7_2() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$this->_Bs_HttpClient->addHeaders['If-Modified-Since'] = 'Sat, 29 Oct 2015 19:43:31 GMT';$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' not found in fetched webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_7_3() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$this->_Bs_HttpClient->addHeaders['If-Modified-Since'] = 'Wed, 25 Apr 2001 06:43:31 GMT';$page = $this->_Bs_HttpClient->fetchPage($path, $host);$expected = 304; $actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode, i bet you need to update this test code because someone modified ecg/pageBasic.html please update this method.');$expected = FALSE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' found in fetched webpage: '{$url}' but we expected to get no body.");}
function __Bs_HttpClient_fetchPage_8() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host, NULL, NULL, 'HEAD');$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = FALSE;$actual = (bool)strpos($page, 'page title');$this->assertEquals($expected, $actual, "string 'page title' found in fetched webpage: '{$url}' but we expected to get no body.");}
function __Bs_HttpClient_fetchPage_9() {$url = $this->host . 'ecg/formBasic.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path, $host, NULL, NULL, 'POST');$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'this is a webform.');$this->assertEquals($expected, $actual, "string 'this is a webform.' not found in fetched webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_9_2() {$url = $this->host . 'ecg/formBasic.php';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$postData = array('step'=>'2', 'user'=>'username', 'pass'=>'password');$page = $this->_Bs_HttpClient->fetchPage($path, $host, NULL, $postData, 'POST');$expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'unexpected responsecode');$expected = TRUE;$actual = (bool)strpos($page, 'username was: username');$this->assertEquals($expected, $actual, "string 'username was: username' not found in fetched (posted) webpage: '{$url}'.");}
function __Bs_HttpClient_fetchPage_10() {$url = $this->host . 'ecg/pageBasic.html';$t = @parse_url($url);$host = $t['host'];$path = $t['path'];$expected = TRUE;$actual   = $this->_Bs_HttpClient->connect($host);$this->assertEquals($expected, $actual, 'connect failed');$page = $this->_Bs_HttpClient->fetchPage($path); $expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'fetch 1: unexpected responsecode');$url = $this->host . 'ecg/301_movedPermanently.php';$t = @parse_url($url);$path2 = $t['path'];$page = $this->_Bs_HttpClient->fetchPage($path2); $expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'fetch 2: unexpected responsecode');$page = $this->_Bs_HttpClient->fetchPage($path); $expected = 200;$actual = $this->_Bs_HttpClient->responseCode;$this->assertEquals($expected, $actual, 'fetch 3: unexpected responsecode');$this->_Bs_HttpClient->disconnect();}
}
?>