jrbasso/MeioUpload — pull request #96 by simkimsia (2012-03-24 09:55:01+00:00)
Title: the MeioUpload version 4.0 did not work so well when i wrote unit tests for the models which use MeioUpload version 4.0

There are 3 basic issues:

1) the use of $this->settings in uploadCheckDir is definitely wrong. So I changed that to $options as expected.

2) in unit tests, the current working directory need not necessarily be WWW_ROOT. However, in uploadCheckDir, it is assumed to be the case because the code is_dir is used. So I added code which will first check if the current working directory is indeed WWW_ROOT. If not, then chdir to the assumed directory

3) in _copyFileFromTemp, there is a check on the source file whethere it is an uploaded file using the is_uploaded_file.

In unit tests, this check will surely fail. Hence I have extracted this check into a standalone entry in the $validate array.

By default, this validation is turned on. Its index is HttpPost. The validation function is uploadCheckHttpPost.

With the above changes, cake test cases can be used on Models that have MeioUpload as one of its behaviors.

In those test cases, we need a separate line of code which will turn off the validation for HttpPost.

eg a model called Image which actsAs MeioUpload under the fieldName filename

$this->Image->validate['filename'] = array(
'HttpPost' => array(
'check' => false
)
);