Skip to content

OSS PHP Frameworks Unit Testing: zf2

ptarjan edited this page Oct 16, 2013 · 5 revisions

Zend Framework 2 is an open source framework for developing web applications

Source Download

Download the latest master branch from Github

Official Testing Documentation

We did not find official documentation for running the zf2 source code unit tests, although there was documentation on how to create PHPUnit unit tests for zf2-based applications. However, setting up the testing of the zf2 source code was straightforward.

Initial Setup

In order to run the zf2 unit tests successfully, make sure you have HHVM, Composer and other basic packages ready to go.

Some initial configuration is required for zf2, particularly around dependencies.

Dependencies

We used composer to install the dependencies. In the root zf2 directory, you will find the composer.json file that will be used to download the required dependencies to run the unit tests.

hhvm [path-to-composer-phar]/composer.phar install --dev

Running the Tests

We used our phpunit binary to run the unit tests. To run the zf2 unit tests, use the following command from within the tests directory (e.g., zf2/tests):

`hhvm [path-to-vendor-parent]/vendor/bin/phpunit`

PHPUnit was installed in the zf2/vendor directory when we downloaded the composer-based dependencies. It might have been better to use that version of PHPUnit instead of our version since it is possible (although unlikely) that optional packages that the our version may not have contained could be included there. However, in this case, it did not seem to hinder the running of the tests.

Fatals

Internationalization

We were greeted right away with the fact that HHVM does not implement the internationalization (intl) extension.

HipHop Fatal error: Class undefined: NumberFormatter in /data/users/joelm/php-open-source-projects/zf2/tests/ZendTest/I18n/Filter/NumberFormatTest.php on line 72

We knew right away that we needed to implement part or all of this extension to get zf2 running correctly.

Failures and Errors

After getting through the fatals, there were errors and failures in functionality.

Timezone

This warning occurs when running the zf2 unit tests.

HipHop Strict Warning: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /data/users/joelm/php-open-source-projects/zf2/tests/ZendTest/Feed/Reader/Entry/RssTest.php on line 1874

HHVM does not have a proper php.ini file to set the timezone settings, which is an overall issue we would like to fix moving forward.

Call To Action

Implement internationalization and move on to determine other fatals and failures.

Clone this wiki locally