Watimage Testing

Reading time ~5 minutes

To run phpunit tests just run phpunit from Watimage root path. But first ensure you have installed composer dependencies; tests need the composer autoload.php file in order to work properly:

composer install
phpunit
# PHPUnit 4.8.6 by Sebastian Bergmann and contributors.
# ...........................................................
# Time: 34.53 seconds, Memory: 80.25Mb
# OK (59 tests, 182 assertions)

If you do not have phpunit installed system-wide just do:

composer install
./vendor/bin/phpunit
# PHPUnit 4.8.6 by Sebastian Bergmann and contributors.
# ...........................................................
# Time: 34.53 seconds, Memory: 80.25Mb
# OK (59 tests, 182 assertions)

The testVignetteMethod requires a bit more than other methods to finish. For that reason I’ve added it to a phpunit @group named slow to easily skip it:

phpunit --exclude-group slow
# PHPUnit 4.8.6 by Sebastian Bergmann and contributors.
# .........................................................
# Time: 16.18 seconds, Memory: 77.00Mb
# OK (57 tests, 180 assertions)

You can also skip that and other effect tests using the whole effects group:

phpunit --exclude-group effects
# PHPUnit 4.8.6 by Sebastian Bergmann and contributors.
# ..........................................
# Time: 6.95 seconds, Memory: 31.00Mb
# OK (42 tests, 149 assertions)

“Visual” tests

Inside tests/visual you’ll find a script to visually check that all images are generated properly.

To run them just cd into the visual tests folders and run the run_them_all.php script:

composer install
cd tests/visual
php run_them_all.php

It will generate a bunch of files in tests/visual/results where you can check (by yourself) if everything is running as expected.

← Go back to Watimage Usage

About the header image

For the header image the following code has been executed:

$image = new Image('freeparty-original.jpg');
$image
    ->resize('crop', 1920, 500)
    ->generate()
;

Both the image and the original can be found under gh-pages branch, inside images folder.