Browse files

Remove some uses of PEAR::isError where an exception will now be throw

  • Loading branch information...
1 parent 311d1b9 commit a28f24d6eb302f62678ead4f12b12f655f8118b7 @CloCkWeRX CloCkWeRX committed Jan 10, 2012
Showing with 19 additions and 14 deletions.
  1. +1 −5 HTTP/Download2.php
  2. +18 −9 tests/HTTP_Download2Test.php
View
6 HTTP/Download2.php
@@ -283,11 +283,7 @@ function setParams($params)
);
}
- $e = call_user_func_array(array(&$this, $method), (array) $value);
-
- if (PEAR::isError($e)) {
- return $e;
- }
+ call_user_func_array(array(&$this, $method), (array) $value);
}
return true;
}
View
27 tests/HTTP_Download2Test.php
@@ -26,7 +26,7 @@ function testHTTP_Download2()
function testsetFile()
{
$h = new HTTP_Download2;
- $this->assertFalse(PEAR::isError($h->setFile(dirname(__FILE__) . '/data.txt')), '$h->setFile("data.txt")');
+ $h->setFile(dirname(__FILE__) . '/data.txt');
$this->assertEquals(realpath(dirname(__FILE__) . '/data.txt'), $h->file, '$h->file == "data.txt');
$this->assertTrue(PEAR::isError($h->setFile('nonexistant', false)), '$h->setFile("nonexistant")');
unset($h);
@@ -43,7 +43,8 @@ function testsetData()
function testsetResource()
{
$h = new HTTP_Download2;
- $this->assertFalse(PEAR::isError($h->setResource($f = fopen(dirname(__FILE__) . '/data.txt', 'r'))), '$h->setResource(fopen("data.txt","r"))');
+ $h->setResource($f = fopen(dirname(__FILE__) . '/data.txt', 'r'));
+
$this->assertEquals($f, $h->handle, '$h->handle == $f');
fclose($f); $f = -1;
$this->assertTrue(PEAR::isError($h->setResource($f)), '$h->setResource($f = -1)');
@@ -53,10 +54,11 @@ function testsetResource()
function testsetGzip()
{
$h = new HTTP_Download2;
- $this->assertFalse(PEAR::isError($h->setGzip(false)), '$h->setGzip(false)');
+ $h->setGzip(false);
$this->assertFalse($h->gzip, '$h->gzip');
if (PEAR::loadExtension('zlib')) {
- $this->assertFalse(PEAR::isError($h->setGzip(true)), '$h->setGzip(true) without ext/zlib');
+ $h->setGzip(true);
+
$this->assertTrue($h->gzip, '$h->gzip');
} else {
$this->assertTrue(PEAR::isError($h->setGzip(true)), '$h->setGzip(true) with ext/zlib');
@@ -68,7 +70,8 @@ function testsetGzip()
function testsetContentType()
{
$h = new HTTP_Download2;
- $this->assertFalse(PEAR::isError($h->setContentType('text/html;charset=iso-8859-1')), '$h->setContentType("text/html;charset=iso-8859-1")');
+ $h->setContentType('text/html;charset=iso-8859-1'));
+
$this->assertTrue(PEAR::isError($h->setContentType('##++***!§§§§?°°^^}][{')), '$h->setContentType("some weird characters")');
$this->assertEquals('text/html;charset=iso-8859-1', $h->headers['Content-Type'], '$h->headers["Content-Type"] == "text/html;charset=iso-8859-1"');
unset($h);
@@ -77,11 +80,17 @@ function testsetContentType()
function testguessContentType()
{
$h = new HTTP_Download2(array('file' => dirname(__FILE__) . '/data.txt'));
- $e = $h->guessContentType();
- if (PEAR::isError($e) && $e->getCode() != HTTP_DOWNLOAD2_E_NO_EXT_MMAGIC) {
- $this->assertTrue(false, $e->getMessage());
+
+ try {
+ $h->guessContentType();
+
+ } catch (HTTP_Download2_Exception $e) {
+ if ($e->getCode() == HTTP_DOWNLOAD2_E_NO_EXT_MMAGIC) {
+ $this->markTestSkipped($e->getMessage());
+ }
+
+ $this->fail((string)$e);
}
- unset($h, $e);
}
function _send($op)

0 comments on commit a28f24d

Please sign in to comment.