Testing Zend_File is really no problem.
Simply look at the actual existing testbed within trunk.
Every codeline is tested and also the uploadprogress can be tested even if
it uses APC.
There is no need of refactoring just for testing purposes.
The difference is within the understanding, what people want to test:
It brings nothing to test the upload itself, as this mainly involves how the
webserver and the client works.
But tests should aim to see if the code works as expected, not if the server
works as expected.
That's the difference. And looking into Zend's own testbed you will see how
this has been archived.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com
----- Original Message -----
From: "till" <[email protected]>
To: <[email protected]>
Sent: Wednesday, March 18, 2009 12:47 PM
Subject: [fw-general] Zend_Test & Zend_File
Giorgio,
since you hijacked my thread, I opened another one for you. :D
On Tue, Mar 17, 2009 at 9:26 PM, Matthew Weier O'Phinney
<[email protected]> wrote:
-- Giorgio Sironi <[email protected]> wrote
(on Tuesday, 17 March 2009, 09:04 PM +0100):
2009/3/17 Matthew Weier O'Phinney <[email protected]>
-- till <[email protected]> wrote
> In general, is Zend_Test ready for "production" yet? I think I pretty
> much run into everything that's still being worked on -- e.g.
> Zend_Session (static issues), cookie-related, etc.. So far, I'm
> pondering to write "regular" unit tests which would involve getting
> the pages through a http client and then parsing them with DOM
> methods.
It's production ready -- I've been using it a ton. The principal issues
lie in the framework itself. For instance, we need to add cookie support
in the response object, and Zend_Session needs to be refactored to make
it easier to test against.
In my opinion Zend_File (used for uploading) is another component that
needs
refactoring because without patches it cannot be tested.
This, like session management, is an area that's really hard to test,
period, due to how PHP works. The only reasonable solution for use with
Zend_Test_PHPUnit_ControllerTestCase I can come up with is to utilize a
different file upload adapter -- which is problematic without a solution
for dependency injection.
I think the common mis-understanding is that people try to test the
server configuration, but the idea would be not to test "PHP" or the
server configuration here. There's test elsewhere for this. Instead
you should mock the upload process. E.g. the most simple thing to
"fake" an upload progress meter is a while(1) {} loop which sets the
appropriate variables.
I think you can pretty much override anything in userland -- $_FILES, etc..
On the other hand, I've enjoyed using Zend_Test for integration testing
of rss
feeds and ajax requests.
Yeah, me too. I really like the assertQuery() stuff -- been using it
on another project TDD style and it's just awesome to write stories
like that and then build until the test is "green". On the other hand,
the other code base is not as complex as my current.
So I guess that's why it's easier. ;-)
Till