Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated unit tests

git-svn-id: http://svn.php.net/repository/pear/packages/HTTP_Download/trunk@304424 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 1b6840239011dc9079add6d43dc0ec28dbdf3a47 1 parent 044a7ca
@CloCkWeRX CloCkWeRX authored
Showing with 14 additions and 18 deletions.
  1. +14 −18 tests/{testcase.php → HTTP_DownloadTest.php}
View
32 tests/testcase.php → tests/HTTP_DownloadTest.php
@@ -1,15 +1,10 @@
<?php
-require_once 'PHPUnit.php';
+require_once 'PHPUnit/Framework.php';
require_once 'HTTP/Download.php';
require_once 'HTTP/Request.php';
-class HTTP_DownloadTest extends PHPUnit_TestCase {
-
- function HTTP_DownloadTest($name)
- {
- $this->PHPUnit_TestCase($name);
- }
+class HTTP_DownloadTest extends PHPUnit_Framework_TestCase {
function setUp()
{
@@ -30,8 +25,8 @@ function testHTTP_Download()
function testsetFile()
{
$h = &new HTTP_Download;
- $this->assertFalse(PEAR::isError($h->setFile('data.txt')), '$h->setFile("data.txt")');
- $this->assertEquals(realpath('data.txt'), $h->file, '$h->file == "data.txt');
+ $this->assertFalse(PEAR::isError($h->setFile(dirname(__FILE__) . '/data.txt')), '$h->setFile("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);
}
@@ -47,7 +42,7 @@ function testsetData()
function testsetResource()
{
$h = &new HTTP_Download;
- $this->assertFalse(PEAR::isError($h->setResource($f = fopen('data.txt', 'r'))), '$h->setResource(fopen("data.txt","r"))');
+ $this->assertFalse(PEAR::isError($h->setResource($f = fopen(dirname(__FILE__) . '/data.txt', 'r'))), '$h->setResource(fopen("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)');
@@ -80,7 +75,7 @@ function testsetContentType()
function testguessContentType()
{
- $h = &new HTTP_Download(array('file' => 'data.txt'));
+ $h = &new HTTP_Download(array('file' => dirname(__FILE__) . '/data.txt'));
$e = $h->guessContentType();
if (PEAR::isError($e) && $e->getCode() != HTTP_DOWNLOAD_E_NO_EXT_MMAGIC) {
$this->assertTrue(false, $e->getMessage());
@@ -90,8 +85,11 @@ function testguessContentType()
function _send($op)
{
+ if (!file_get_contents($this->testScript)) {
+ $this->markTestSkipped($this->testScript . " is not available");
+ }
$complete = str_repeat('1234567890',10);
-
+
$r = &new HTTP_Request($this->testScript);
foreach (array('file', 'resource', 'data') as $what) {
$r->reset($this->testScript);
@@ -208,6 +206,10 @@ function teststaticSend()
function testsendArchive()
{
+ if (!file_get_contents($this->testScript)) {
+ $this->markTestSkipped($this->testScript . " is not available");
+ }
+
$r = &new HTTP_Request($this->testScript);
foreach (array('tar', 'tgz', 'zip', 'bz2') as $type) {
$r->addQueryString('type', $type);
@@ -223,9 +225,3 @@ function testsendArchive()
}
}
-
-$suite = &new PHPUnit_TestSuite('HTTP_DownloadTest');
-$result = &PHPUnit::run($suite);
-echo $result->toString();
-
-?>
Please sign in to comment.
Something went wrong with that request. Please try again.