I asked more or less the same question some months ago, and the best solution
I come up with was to populate $_FILES by hand and wrap move_uploaded_file into
a controller method, so that it can be easily mocked inside your tests.


Matteo

On Apr/26, jeremyharris wrote:
> I would take cues from the Media plugin, which uses binary data in some of 
> its testing library.
> 
> Test data: 
> https://github.com/davidpersson/media/blob/next/tests/fixtures/test_data.php
> Where test data is set up: 
> https://github.com/davidpersson/media/blob/next/tests/cases/models/behaviors/base.test.php
> TransferBehavior:  
> https://github.com/davidpersson/media/blob/next/tests/cases/models/behaviors/transfer.test.php
>  
> 
> There are even more tests and data in the MM library within the plugin: 
> https://github.com/davidpersson/media/tree/next/libs/mm/tests
> 
> I don't have any experience with MeioUpload but I imagine changing the 
> paths to the tmp folder will be possible.
> 
> I know this isn't a specific answer but it should give you some good 
> jumping off points.
> 
> -jeremy
> 
> On Thursday, April 26, 2012 7:57:40 AM UTC-7, Thiago Belem wrote:
> >
> > I'm creating a new MeioUpload/Media behavior and I wanted to make it 
> > totally covered by tests...
> >
> > Do you guys have any idea/recomendation/resource about mocking uploads on 
> > CakePHP + PHPUnit?
> >
> > I know I can't just populate $_FILES with my data and expect 
> > is_uploaded_file or move_uploaded_file functions to work.
> >  
> > I don't want to use anoter testing framework like PHPT or something that's 
> > not pure CakePHP and PHPUnit.
> >
> > Regards,
> > --
> > ***Thiago Belem*
> > Desenvolvedor
> > Rio de Janeiro - RJ - Brasil
> >
> > *Assando Sites* - Curso online de *CakePHP*
> > assando-sites.com.br <http://goo.gl/b1EEd>
> >
> > thiagobelem.net
> > [email protected]
> >
> > *Skype / gTalk **»* thiago.belem.web
> > *LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt
> >
> > 
> 
> -- 
> 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

-- 
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