-
Notifications
You must be signed in to change notification settings - Fork 3
PHP 5.2
This project aims to be compatible with PHP 5.2 as long as WordPress is. However, using it with PHP 5.2 means that you will have to do some extra work to load it in your bootstrap.
Probably the easiest thing for you to do is have Composer generate a PHP 5.2-compatible autoloader for you. Then all you have to do is switch from including autoload.php
to autoload_52.php
in your PHPUnit boostrap file:
require_once( dirname( __FILE__ ) . '/../../../vendor/autoload_52.php' );
This isn't natively supported by Composer though, so to do this you'll need to:
composer require --dev xrstf/composer-php52
Then, you'll need to tell Composer that it needs to generate the 5.2 autoloader along with the normal one, by adding this to your composer.json
file:
"scripts": {
"post-install-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-update-cmd": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
],
"post-autoload-dump": [
"xrstf\\Composer52\\Generator::onPostInstallCmd"
]
},
Then, to regenerate the autoloaders, just run:
composer dump-autoload
The alternative is for you to manually include the files in your PHPUnit bootstrap. This is subject to breakage in the future, when new files are added. But if you feel that you must do it this way, you would include these files before you load WordPress:
$wpppb_dir = dirname( __FILE__ ) . '/../../../vendor/jdgrimes/wp-plugin-phpunit-bootstrap/src/WPPPB/';
require_once( $wpppb_dir . 'Loader.php' );
require_once( $wpppb_dir . 'Util/GetOpt.php' );
And these files after:
require_once( $wpppb_dir . 'TestCase/Uninstall.php' );
require_once( $wpppb_dir . 'TestCase/Uninstall.php' );
require_once( $wpppb_dir . 'Constraint/NoRowsWithPrefix.php' );
require_once( $wpppb_dir . 'Constraint/TableExists.php' );
require_once( $wpppb_dir . 'Constraint/TableNotExists.php' );