We always appreciate contributions to PHP ActiveRecord, but we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us by commenting on issues.
PHP ActiveRecord has a full set of unit tests, which are run by PHPUnit.
In order to run these unit tests, you need to install the required packages using Composer:
composer installAfter that you can run the tests by invoking the local PHPUnit
To run all the tests, simply use:
composer testwhich runs:
vendor/bin/phpunitOr run a single test file:
composer test dateTimewhich runs:
vendor/bin/phpunit test/DateTimeTest.phpOr run a single test within a file:
composer test dateTime setIsoDatewhich runs:
vendor/bin/phpunit --filter setIsoDate test/DateTimeTest.phpYou might notice that some tests are marked as skipped. To obtain more information about skipped
tests, pass the --verbose flag to PHPUnit:
vendor/bin/phpunit --verboseFor Docker users, a docker-compose.yml has been provided in the project root that will provide:
- mysql
- postgres
- memcached
Simply run:
docker-compose up -dThen, the necessary services will be available and the tests should pass (although you may need to install PHP memcache extensions in a separate step, see below).
When you're done, you can take it down with:
docker-compose downIf you're a Windows user, finding the correct memcache drivers can be a bit tricky, as the PECL repo seems to be in disrepair. You can find them here:
https://github.com/nono303/PHP-memcache-dll/tree/master
Download the .dll that matches your version of PHP, install it into your /ext dir, and add this line to your php.ini:
extension=memcacheIf Docker is not available to you, or you would simply not use it, you will have to do your best to install the various services on your own.
- Install
memcachedand the PHP memcached extension (e.g.,brew install php56-memcache memcachedon macOS) - Install the PDO drivers for PostgreSQL (e.g.,
brew install php56-pdo-pgsqlon macOS) - Create a MySQL database and a PostgreSQL database. You can either create these such that they are available at the default locations of
mysql://test:test@127.0.0.1/testandpgsql://test:test@127.0.0.1/testrespectively. Alternatively, you can set thePHPAR_MYSQLandPHPAR_PGSQLenvironment variables to specify a different location for the MySQL and PostgreSQL databases.
- You can check your code with a PSR-2 style checker locally with the command:
composer style-checkand fix it with:
composer style-fix- You can check your code with the PHPStan static analysis checker with the command:
composer stancomposer style-check
composer test
composer stanwill be run for every pull request as part of the Docker-enabled continuous integration, so it would be good to run these checks locally before submitting your pull request.