josegonzalez/upload — pull request #115 by joshuapaling (2013-05-02 08:29:18+00:00)
Title: Fixes issue #97 - invalid param for imagepng()

In _resizePhp(), I've converted the 0-100 thumbnailQuality to it's corresponding 0-9 value for use with imagepng().

I've tested it thoroughly, but haven't written Unit Tests... I did look into this, but I'm not sure if it can be done properly without refactoring code and breaking _resizePhp() into smaller testable private methods or something.

What you'd really want to do is set up a test case asserting that imagepng() gets called once with third parameter between 0 and 9. But since imagepng() is an in-built method of PHP, you can't do that, unless you wrote a wrapper function for it, right?

It looks like most of the code & options in _resizePhp() isn't explicitly tested at the moment, anyway. Correct?

I don't have a lot of experience in unit testing, so I'm happy to be proven wrong, and I'm happy to write tests and amend this pull request if anyone has a suggestion of how to do it nicely.

Signed-off-by: Joshua Paling