This is a fork of a 2001-ish era PHP app from MySociety in the UK, repurposed for Australia. This is the software running on https://openaustralia.org.au
OpenAustralia.org.au is a website run by the non-partisan charity, OpenAustralia Foundation, which makes Australian government and parliamentary information easily accessible to the public through tools such as searching Hansard (parliamentary debates) and tracking politicians' voting records. The site aims to increase transparency and civic engagement in Australian democracy. It provides platforms to easily follow what MPs and Senators say and do, and tracks their registers of interests.
Everything elected politicians say in Australia's Senate and Parliament is recorded in Australia's Official Hansard. This documentation is obtained using scapers (see https://github.com/openaustralia/openaustralia-parser/ ) and displayed on openaustralia.org.au.
Data is also provided for public use at http://data.openaustralia.org.au/
TheyVoteForYou.org.au is one of the users of this data.
Use mise install to install php.
You may need to:
sudo apt update
sudo apt install plocate
# If you have many millions of files, the indexer may take a while.
# You can either wait or kill the indexer holding up apt install (which will complete the install),
# add exclusions to /etc/updatedb.conf and rerun.
sudo apt install re2c bison autoconf build-essential libxml2-dev libssl-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libonig-dev libzip-dev
sudo apt-get install libgd-devcomposer installmake lint-ci | grep -v "No syntax errors detected in" # ignore all the "its ok" messages
make phpcs-ci
composer validateUse phpcbf to fix formatting that GitHub Actions complains about, eg:
./vendor/bin/phpcbf www/includes/easyparliament/alert.php www/includes/easyparliament/user.phpUnit tests run without a database:
make test
./vendor/bin/phpunit tests/To run tests with database integration, start MySQL first:
make docker-runThis starts both the webserver and MySQL container. Wait a few seconds for MySQL to be ready, then run:
make test-allTo run all tests inside Docker with automatic database setup:
make test-dockerThis will:
- Start the MySQL container
- Load the database schema
- Run all tests with database integration
No need to manually start containers or set environment variables.
To generate code coverage reports (requires Xdebug or PCOV):
make docker-run
make test-coverageOr run coverage inside Docker (no host PHP extensions needed):
make test-coverage-dockerCoverage reports are generated in coverage/clover.xml (for SonarCloud) and coverage/html/ (browsable HTML).
When running tests with the database:
- Host:
127.0.0.1(ormysqlinside Docker) - User:
twfyuser - Password:
twfypass - Database:
twfy
These are configured in phpunit.xml via environment variables (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME).
Tests are split into two types:
- Unit tests (no database required): Tests logic, parsing, and conditional logic. Located in
tests/*Test.php. - Integration tests (database required): Tests database queries and interactions. Located in
tests/*IntegrationTest.php.
Integration tests automatically skip if the database is not available, so the test suite will still pass in CI environments.
To stop the Docker containers:
docker compose down