basic test stuff
This commit is contained in:
parent
56f995c86f
commit
d57aed4049
23
tests/bootstrap.php
Normal file
23
tests/bootstrap.php
Normal 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
11
tests/config.php
Normal 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);
|
||||||
|
|
||||||
|
?>
|
||||||
@ -1,5 +1,10 @@
|
|||||||
|
<phpunit bootstrap="bootstrap.php">
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="SampleTest">
|
<testsuite name="SampleTest">
|
||||||
<directory>unit/config</directory>
|
<directory>unit/config</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
<testsuite name="SecurityRegress">
|
||||||
|
<directory>unit/securityregress/SecurityRegress.php</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
</phpunit>
|
||||||
@ -2,17 +2,12 @@
|
|||||||
|
|
||||||
// these are ONLY here because we're checking config options
|
// these are ONLY here because we're checking config options
|
||||||
// these should NOT be in a normal unit test
|
// 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 {
|
class TestDistConfig extends PHPUnit_Framework_Testcase {
|
||||||
/**
|
/**
|
||||||
* Test to make sure SALT is sane
|
* Test to make sure SALT is sane
|
||||||
*/
|
*/
|
||||||
function testSalt() {
|
function testSaltLength() {
|
||||||
$this->assertNotEmpty(SALT);
|
$this->assertNotEmpty(SALT);
|
||||||
$this->assertGreaterThan(1, strlen(SALT));
|
$this->assertGreaterThan(1, strlen(SALT));
|
||||||
}
|
}
|
||||||
|
|||||||
13
tests/unit/securityregress/SecurityRegress.php
Normal file
13
tests/unit/securityregress/SecurityRegress.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class TestSecurityRegress extends PHPUnit_Framework_Testcase {
|
||||||
|
/**
|
||||||
|
* CSRFToken tests
|
||||||
|
*/
|
||||||
|
function testCSRFTokenSuccess() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user