basic test stuff

This commit is contained in:
xisi 2014-01-24 11:18:07 -05:00
parent 56f995c86f
commit d57aed4049
5 changed files with 59 additions and 12 deletions

23
tests/bootstrap.php Normal file
View File

@ -0,0 +1,23 @@
<?php
error_reporting(E_ALL);
define('SECURITY', 'so we can check config options');
// pull in our tests config
require_once('config.php');
define('REALCONFIG', BASEPATH.'include/config/global.inc.php');
define('DISTCONFIG', BASEPATH.'include/config/global.inc.dist.php');
if (!DIST_OR_REAL_CONFIG) {
require_once(DISTCONFIG);
} else {
require_once(REALCONFIG);
}
require_once(BASEPATH . 'include/autoloader.inc.php');
require_once("PHPUnit/Autoload.php");
?>

11
tests/config.php Normal file
View File

@ -0,0 +1,11 @@
<?php
// full path to mpos public directory, with trailing slash
// haven't been able to set this to __DIR__ + changing bootstrap to have the tests work, so full path seems best
define('BASEPATH', '/var/www/php-mpos-allbranches/php-mpos/public/');
// choose which config to test against, dist or real
// 0 = dist, 1 = real
define('DIST_OR_REAL_CONFIG', 1);
?>

View File

@ -1,5 +1,10 @@
<phpunit bootstrap="bootstrap.php">
<testsuites>
<testsuite name="SampleTest">
<directory>unit/config</directory>
</testsuite>
</testsuites>
<testsuite name="SampleTest">
<directory>unit/config</directory>
</testsuite>
<testsuite name="SecurityRegress">
<directory>unit/securityregress/SecurityRegress.php</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@ -2,17 +2,12 @@
// 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() {
* Test to make sure SALT is sane
*/
function testSaltLength() {
$this->assertNotEmpty(SALT);
$this->assertGreaterThan(1, strlen(SALT));
}

View File

@ -0,0 +1,13 @@
<?php
class TestSecurityRegress extends PHPUnit_Framework_Testcase {
/**
* CSRFToken tests
*/
function testCSRFTokenSuccess() {
global $config;
}
}
?>