Skip to content

Commit

Permalink
Fixing unit tests broken by HttpUtilsConstants
Browse files Browse the repository at this point in the history
  • Loading branch information
isofarro committed Aug 25, 2009
1 parent 6435b1b commit 507a4e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
3 changes: 2 additions & 1 deletion CanonicalLink.php
Expand Up @@ -92,7 +92,8 @@ protected function _checkNonHttpRedirect($url, $response) {
$url = $this->_getMetaRefreshUrl($response->getBody());
break;
default:
echo "Domain: {$domain}\n";
echo '§';
//echo "Domain: {$domain}\n";
//print_r($response);
$url = NULL;
break;
Expand Down
3 changes: 2 additions & 1 deletion HttpClient.php
Expand Up @@ -48,7 +48,8 @@ public function getUrl($url, $useCache=true) {
}
}

//echo "^GET: {$url}\n";
echo '^';
//echo "GET: {$url}\n";
$request = new HttpRequest($url);
$response = $this->doRequest($request);
//print_r($response);
Expand Down
42 changes: 24 additions & 18 deletions tests/HttpUtilsConstantsTest.php
Expand Up @@ -3,16 +3,24 @@
require_once dirname(dirname(__FILE__)) . '/HttpUtils.php';

class HttpUtilsConstantsTest extends PHPUnit_Framework_TestCase {

function tearDown() {
$dirs = array('/tmp/unit-test-cache/', '/tmp/unit-test-data/');
foreach($dirs as $dir) {
if (!empty($dir) && is_dir($dir)) {
rmdir($dir);
var $dirs = array('/tmp/unit-test-cache/', '/tmp/unit-test-data/');

function setUp() {
foreach($this->dirs as $dir) {
if (!empty($dir) && !is_dir($dir)) {
mkdir($dir);
}
}
}

function tearDown() {
//foreach($this->dirs as $dir) {
// if (!empty($dir) && is_dir($dir)) {
// rmdir($dir);
// }
//}
}

public function testDefaultCacheDir() {
$cacheDir = HttpUtilsConstants::getBaseCacheDir();

Expand All @@ -36,12 +44,11 @@ public function testDefaultDataDir() {
public function testCustomCacheDir() {
$dir = '/tmp/unit-test-cache/';

$this->assertFalse(is_dir($dir));

$result = HttpUtilsConstants::setBaseCacheDir($dir);
$this->assertFalse($result);

mkdir($dir);
//$this->assertFalse(is_dir($dir));
//$result = HttpUtilsConstants::setBaseCacheDir($dir);
//$this->assertFalse($result);
//mkdir($dir);

$this->assertTrue(is_dir($dir));

$result = HttpUtilsConstants::setBaseCacheDir($dir);
Expand All @@ -56,12 +63,11 @@ public function testCustomCacheDir() {
public function testCustomDataDir() {
$dir = '/tmp/unit-test-data/';

$this->assertFalse(is_dir($dir));

$result = HttpUtilsConstants::setBaseDataDir($dir);
$this->assertFalse($result);

mkdir($dir);
//$this->assertFalse(is_dir($dir));
//$result = HttpUtilsConstants::setBaseDataDir($dir);
//$this->assertFalse($result);
//mkdir($dir);

$this->assertTrue(is_dir($dir));

$result = HttpUtilsConstants::setBaseDataDir($dir);
Expand Down

0 comments on commit 507a4e0

Please sign in to comment.