improvements to test suite to allow it to run from a clean repository
commit7da2b7a44df9373aaf93e6baaca0ce73581a7753
authoracmoore <acmoore>
Tue, 3 Aug 2010 20:17:55 +0000 (3 20:17 +0000)
committeracmoore <acmoore>
Tue, 3 Aug 2010 20:17:55 +0000 (3 20:17 +0000)
tree617151481b8ddb24136614c7256d8a05f83a2f7a
parent05796fdfe870e413f26973d6ed55d2e79fdfa556
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.
Tests/BaseHarness.class.php [new file with mode: 0644]
Tests/InstallerTest.php [new file with mode: 0644]
Tests/OptionsTest.php [new file with mode: 0644]
library/classes/Installer.class.php [new file with mode: 0644]