English 中文(简体)
档案库
原标题:phpunit testcase for file upload

Can anybody help me. How to write file upload phpunit testcase? I done it for insert, unique data insertion, delete etc functionality. Following are my code but its not working properly

class FileuploadTest extends PHPUnit_Framework_TestCase
{

    public $testFile = array(
        name => 2012-04-20 21.13.42.jpg ,
        tmp_name => C:wamp	mpphp8D20.tmp ,
        type => image/jpeg ,
        size =>1472190,
        error =>0
    );


public function testFileupload()
    {   

        $testUpload = new Fileupload;
        $testUpload->image = new CUploadedFile($this->testFile[ name ],$this->testFile[ tmp_name ],$this->testFile[ type ],$this->testFile[ size ],$this->testFile[ error ]);
        $this->assertFalse($testUpload->validate());

        $errors= $testUpload->errors;
        $this->assertEmpty($errors);
    }

}
最佳回答

根据您的评论,测试是什么,$testUpload->validate()正在恢复,你正在试图打assert<>。 如果是假的,检验显然会失败。

如果$this->assertFalse ($testUpload->validate());正在失效,这意味着$testUpload被正确地初步采用,从而确认回报。

在你检验过程中,你必须利用你来做下一个说法。

$this->assertTrue($testUpload->validate());

你们需要更多地了解单位测试。 网上有许多文章,简单搜索将回去。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...