PHPUnit test harness & sample test

This commit is contained in:
xisi 2014-01-17 09:16:11 -05:00
parent a36a0c5b79
commit bb80fdb337
4 changed files with 46 additions and 0 deletions

3
.gitignore vendored
View File

@ -20,3 +20,6 @@ public/include/config/global.inc.sha.php
.buildpath
.project
.settings
# Unit testing
tests/phpunit/*

17
tests/README.md Normal file
View File

@ -0,0 +1,17 @@
How to run these tests
======================
* Download and install phpunit (http://phpunit.de/manual/3.7/en/installation.html)
* `phpunit tests/unit`
How to add tests
================
* Add unit tests to the matching folder/file.php or create a new one
* Add any new suites to the phpunit.xml file
* Below is the suite entry for the sample test in unit/config/SampleTest.php
`<testsuite name="SampleTest">
<directory>unit/config</directory>
</testsuite>`

5
tests/phpunit.xml Normal file
View File

@ -0,0 +1,5 @@
<testsuites>
<testsuite name="SampleTest">
<directory>unit/config</directory>
</testsuite>
</testsuites>

View File

@ -0,0 +1,21 @@
<?php
// these are ONLY here because we're checking config options
// these should NOT be in a normal unit test
define('SECURITY', 'so we can check config options');
define("BASEPATH", "./");
require_once(BASEPATH.'public/include/config/global.inc.dist.php');
require_once("PHPUnit/Autoload.php");
class TestDistConfig extends PHPUnit_Framework_Testcase {
/**
* Test to make sure SALT is sane
*/
function testSalt() {
$this->assertNotEmpty(SALT);
$this->assertGreaterThan(1, strlen(SALT));
}
}
?>