PHPUnit test harness & sample test
This commit is contained in:
parent
a36a0c5b79
commit
bb80fdb337
3
.gitignore
vendored
3
.gitignore
vendored
@ -20,3 +20,6 @@ public/include/config/global.inc.sha.php
|
||||
.buildpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
# Unit testing
|
||||
tests/phpunit/*
|
||||
|
||||
17
tests/README.md
Normal file
17
tests/README.md
Normal 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
5
tests/phpunit.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<testsuites>
|
||||
<testsuite name="SampleTest">
|
||||
<directory>unit/config</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
21
tests/unit/config/SampleTest.php
Normal file
21
tests/unit/config/SampleTest.php
Normal 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));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user