Hello Matteo,

Looks like the only way is to wrap the functions, on a second look
Sebastian Bergmann's php-test-helpers is only for user created
functions.

kind regards,

Leigh

On Dec 13, 9:21 am, leigh <[email protected]> wrote:
> Hello Matteo,
>
> It's not supported because of PHP and if you wrap them you can
> override them.  If you want to get full stubbing/mocking of functions
> usehttps://github.com/sebastianbergmann/php-test-helpersI've not
> used it yet. Google testing file uploads with phpUnit or simpleTest
> will bring up solutions, It would be good to have a section on the
> manual which says best practice.
>
> Hi Miles,
>
> Instead of returning true Matteo could replace them with other
> functions that allow you to mimic it. This is making the assumption
> that he sets up a real file in his test maybe in the before setup and
> then delete it in the teardown.
>
>  function isUploadedFile($filename) {
>    return file_exists($filename);}
>
> protected function MoveUploadedFile($filename, $destination) {
>    return copy($filename,  $destination);
>
> }
>
> On Dec 12, 1:35 pm, Miles J <[email protected]> wrote:
>
>
>
>
>
>
>
> > That doesn't actually test if files are uploaded and image
> > transformations worked.
>
> > On Dec 12, 7:12 am, Matteo Landi <[email protected]> wrote:
>
> > > On Mon, Dec 12, 2011 at 4:46 AM, leigh <[email protected]> wrote:
> > > > Hi Matteo,
>
> > > > Wrap move_uploaded_file and is_uploaded_file inside the controller
>
> > > > function moveUploadedFIle($filename, $destination) {
> > > >  return move_uploaded_file($filename, $destination);
> > > > }
>
> > > > function moveUploadedFIle($filename, $destination) {
> > > >  return is_uploaded_file($filename, $destination);
> > > > }
>
> > > > Then inside your testController override them.
>
> > > > class TestPostsController extends postsController {
>
> > > >  protected function isUploadedFile($filename) {
> > > >   return true;
> > > >  }
> > > >  protected function moveUploadedFile($filename, $destination) {
> > > >   return true;
> > > >  }
>
> > > You are assuming that my controllers tests extend controllers and not,
> > > as usual, CakeControllerTest. However, do I really need to do
> > > something similar to test image uploading? Is this supported or not?
>
> > > Matteo
>
> > > --http://www.matteolandi.net/

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to