image upload testing
Posted: Mon Oct 30, 2006 11:12 pm
I have a class file which resizes the image into 3 types (thumbnail, small, big). How to test this class file?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
<?php
require_once('database.php');
require_once("pictures.php");
set_include_path("library/");
require_once 'members.php';
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'PHPUnit.php';
print("<b>TEST CASE FOR PICTURES CLASS</b>");
$pictureName=$_FILES['photo']['name'];
$tmp_filename=$_FILES['photo']['tmp_name'];
$pictureBrief=$_POST['pictureBrief'];
$pictureCaption=$_POST['pictureCaption'];
$pictureDate=$_POST['pictureDate'];
$picturePrice=$_POST['picturePrice'];
$archiveFlag=$_POST['archiveFlag'];
$eventId=$_POST['eventId'];
$photographerId=$_POST['photographerId'];
$storyId=$_POST['storyId'];
$publicFlag=$_POST['publicFlag'];
$enableFlag=$_POST['enableFlag'];
$officebeatFlag=$_POST['officebeatFlag'];
$pictureBigPath="big/";
$pictureThumbNailPath="thumbnail/";
$pictureSmallImagePath="small/";
//$new=new pictures;
//$new->AddPicture($pictureName, $tmp_filename, $pictureBrief, $pictureCaption, $pictureDate, $picturePrice, $pictureThumbNailPath, $pictureSmallImagePath, $pictureBigPath, $archiveFlag, $enableFlag, $eventId, $photographerId, $storyId, $publicFlag, $officebeatFlag, '','pictures');
//$new->UpdatePicture($pictureName, $tmp_filename, $pictureBrief, $pictureCaption, $pictureDate, $picturePrice, $pictureThumbNailPath, $pictureSmallImagePath, $pictureBigPath, $archiveFlag, $enableFlag, $eventId, $photographerId, $storyId, $publicFlag, $officebeatFlag, '3','pictures');
//$new->DeletePicture('1','pictures');
class PicutresTest extends PHPUnit_TestCase {
public function cleanup()
{
$qdel=mysql_query("SELECT * FROM pictures");
if(mysql_num_rows($qdel)>0)
{
$del=mysql_query("TRUNCATE pictures");
}
}
public function testing_AddPicture()
{
//$this->cleanup();
//$new=new pictures;
//echo $pictureName;
//$new->AddPicture($pictureName, $tmp_filename, $pictureBrief, $pictureCaption, $pictureDate, $picturePrice, $pictureThumbNailPath, $pictureSmallImagePath, $pictureBigPath, $archiveFlag, $enableFlag, $eventId, $photographerId, $storyId, $publicFlag, $officebeatFlag, '','pictures');
//$expected='insert';
//$this->assertEquals($expected, $actual, "COULD NOT INSERT");
}
}
$suite = new PHPUnit_TestSuite('PicutresTest');
$result = PHPUnit::run($suite);
print $result->toHTML();
?>
<table width="0%" height="140" border="1" align="center">
<tr>
<td height="0" colspan="2">
<form action="" method="post" enctype="multipart/form-data" name="form1">
<table width="75%" border="1" align="center">
<tr>
<td width="50%">brief</td>
<td width="50%"><input type="text" name="pictureBrief"></td>
</tr>
<tr>
<td>caption</td>
<td><input type="text" name="pictureCaption"></td>
</tr>
<tr>
<td>date</td>
<td><input type="text" name="pictureDate"></td>
</tr>
<tr>
<td>price</td>
<td><input type="text" name="picturePrice"></td>
</tr>
<tr>
<td>flag</td>
<td><input type="checkbox" name="archiveFlag" value="true"></td>
</tr>
<tr>
<td>eventid</td>
<td><input type="text" name="eventId"></td>
</tr>
<tr>
<td>photographerid</td>
<td><input type="text" name="photographerId"></td>
</tr>
<tr>
<td>storyid</td>
<td><input type="text" name="storyId"></td>
</tr>
<tr>
<td>public</td>
<td><input type="checkbox" name="publicFlag" value="true"></td>
</tr>
<tr>
<td>office</td>
<td><input type="checkbox" name="officebeatFlag" value="true"></td>
</tr>
<tr>
<td>Enable</td>
<td><input type="checkbox" name="enableFlag" value="true"></td>
</tr>
<tr>
<td height="25" colspan="2"><div align="center">
<input type="file" name="photo">
</div></td>
</tr>
<tr>
<td align='center' height="23" colspan="2"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form></td>
</tr>
</table>Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]