improvements to test suite to allow it to run from a clean repository
Here are some improvements to the test suite to allow it to run from a
git (or cvs) repository. A testing database is created and dropped
during the run in order to avoid hitting a production database.
The patch includes a new Installer.class.php file that contains most
of the logic extracted out of setup.php so that the test suite can
build a new database and use it for testing. The Installer class is
designed to be generic enough that other installation methods (such as
setup.php or contrib/util/express.php) can use it instead of including
a lot of their own logic.
There are also three new test classes here that test some arbitrary
parts of the application. Most of this code is collected from other
example patches that were not applied, so you've probably seen them
before. They can serve as examples on how to write tests for other
libraries and functions.
The Tests/BaseHarness.class.php class is designed to be inherited by
test classes that need a clean database. It makes sure that the
database is setup.
To run the test suite, you can run the 'phpunit' command. It will
create and drop a database named "openemr_test_suite" that it uses for
testing purposes. In order to do that, it needs your mysql root
password, which you can pass in using the environment variable
"EMR_ROOT_DATABASE_PASSWORD". You can set that at the same time as you
run phpunit, so your command may look something like this:
EMR_ROOT_DATABASE_PASSWORD=mysql_root_password phpunit --verbose
Needed improvements:
I have had to sprinkle a few "require" statements around and define a
few global variables in ways that are not entirely intuitive or
desired. As the code defines fewer globals that affect remote portions
of the code, perhaps the number of these instances can be reduced.