forked from extern/egroupware
Get tests to not fail if DB is missing - we skip the ones that need a DB
This commit is contained in:
parent
eeecc2eecd
commit
d83a929254
@ -302,6 +302,9 @@ class SchemaTest extends LoggedInTest {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testInsertMoreContent
|
||||||
|
*/
|
||||||
public function testDropTable()
|
public function testDropTable()
|
||||||
{
|
{
|
||||||
foreach(self::$adodb->MetaTables() as $table)
|
foreach(self::$adodb->MetaTables() as $table)
|
||||||
|
@ -22,9 +22,21 @@ use PHPUnit_Framework_TestCase as TestCase;
|
|||||||
|
|
||||||
class SecurityTest extends TestCase {
|
class SecurityTest extends TestCase {
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
// _check_script_tag uses HtmLawed, which calls GLOBALS['egw']->link()
|
||||||
|
$GLOBALS['egw'] = $this->getMockBuilder('Egw')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->setMethods(['link', 'setup'])
|
||||||
|
->getMock();
|
||||||
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
unset($GLOBALS['egw_inset_vars']);
|
unset($GLOBALS['egw_inset_vars']);
|
||||||
|
|
||||||
|
// Must remember to clear this, or other tests may break
|
||||||
|
unset($GLOBALS['egw']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,6 +117,8 @@ class SecurityTest extends TestCase {
|
|||||||
// we currently fail 44 of 140 tests, thought they seem not to apply to our use case, as we check request data
|
// we currently fail 44 of 140 tests, thought they seem not to apply to our use case, as we check request data
|
||||||
'https://html5sec.org/' => call_user_func(function() {
|
'https://html5sec.org/' => call_user_func(function() {
|
||||||
$payloads = $items = null;
|
$payloads = $items = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!($items_js = file_get_contents('https://html5sec.org/items.js')) ||
|
if (!($items_js = file_get_contents('https://html5sec.org/items.js')) ||
|
||||||
!preg_match_all("|^\s+'data'\s+:\s+'(.*)',$|m", $items_js, $items, PREG_PATTERN_ORDER) ||
|
!preg_match_all("|^\s+'data'\s+:\s+'(.*)',$|m", $items_js, $items, PREG_PATTERN_ORDER) ||
|
||||||
!($payload_js = file_get_contents('https://html5sec.org/payloads.js')) ||
|
!($payload_js = file_get_contents('https://html5sec.org/payloads.js')) ||
|
||||||
@ -112,6 +126,11 @@ class SecurityTest extends TestCase {
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$replace = array(
|
$replace = array(
|
||||||
"\\'" => "'",
|
"\\'" => "'",
|
||||||
'\\\\'=> '\\,',
|
'\\\\'=> '\\,',
|
||||||
|
@ -40,6 +40,9 @@ class DateTimeTest extends TestCase {
|
|||||||
{
|
{
|
||||||
// Reset
|
// Reset
|
||||||
DateTime::setUserPrefs(static::$usertime->getName());
|
DateTime::setUserPrefs(static::$usertime->getName());
|
||||||
|
|
||||||
|
unset($GLOBALS['egw']);
|
||||||
|
parent::tearDownAfterClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,9 +45,6 @@ abstract class LoggedInTest extends TestCase
|
|||||||
// These globals pulled from the test config (phpunit.xml)
|
// These globals pulled from the test config (phpunit.xml)
|
||||||
static::load_egw($GLOBALS['EGW_USER'],$GLOBALS['EGW_PASSWORD'], $GLOBALS['EGW_DOMAIN']);
|
static::load_egw($GLOBALS['EGW_USER'],$GLOBALS['EGW_PASSWORD'], $GLOBALS['EGW_DOMAIN']);
|
||||||
|
|
||||||
// Re-init config, since it doesn't get handled by loading Egw
|
|
||||||
Api\Config::init_static();
|
|
||||||
|
|
||||||
if($GLOBALS['egw']->db)
|
if($GLOBALS['egw']->db)
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->db->connect();
|
$GLOBALS['egw']->db->connect();
|
||||||
@ -57,11 +54,14 @@ abstract class LoggedInTest extends TestCase
|
|||||||
static::markTestSkipped('No $GLOBALS[egw]->db');
|
static::markTestSkipped('No $GLOBALS[egw]->db');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-init config, since it doesn't get handled by loading Egw
|
||||||
|
Api\Config::init_static();
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
static::markTestSkipped('Unable to connect to Egroupware');
|
static::markTestSkipped('Unable to connect to Egroupware - ' . $e->getMessage());
|
||||||
throw $e;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do some checks to make sure things we expect are there
|
// Do some checks to make sure things we expect are there
|
||||||
@ -101,7 +101,7 @@ abstract class LoggedInTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the eGW session, exits on wrong credentials
|
* Start the eGW session, skips the test if there are problems connecting
|
||||||
*
|
*
|
||||||
* @param string $user
|
* @param string $user
|
||||||
* @param string $passwd
|
* @param string $passwd
|
||||||
@ -125,13 +125,23 @@ abstract class LoggedInTest extends TestCase
|
|||||||
'flags' => array(
|
'flags' => array(
|
||||||
'currentapp' => 'api',
|
'currentapp' => 'api',
|
||||||
'noheader' => true,
|
'noheader' => true,
|
||||||
'autocreate_session_callback' => __NAMESPACE__ . '\AppTest::create_session',
|
'autocreate_session_callback' => __CLASS__ .'::create_session',
|
||||||
'no_exception_handler' => 'cli',
|
'no_exception_handler' => 'cli',
|
||||||
'noapi' => false,
|
'noapi' => false,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
include(realpath(__DIR__ . '/../../../header.inc.php'));
|
include(realpath(__DIR__ . '/../../../header.inc.php'));
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
// Something went wrong setting up egw environment - don't try
|
||||||
|
// to do the test
|
||||||
|
static::markTestSkipped($e->getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Run tests using phpunit -c doc/phpunit.xml -->
|
<!-- Run tests using phpunit -c doc/phpunit.xml -->
|
||||||
<phpunit
|
<phpunit
|
||||||
colors="true">
|
colors="true"
|
||||||
|
backupGlobals="false"
|
||||||
|
>
|
||||||
<php>
|
<php>
|
||||||
<var name="EGW_DOMAIN" value="default" />
|
<var name="EGW_DOMAIN" value="default" />
|
||||||
<var name="EGW_USER" value="demo" />
|
<var name="EGW_USER" value="demo" />
|
||||||
@ -10,10 +12,7 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="Api tests">
|
<testsuite name="Api tests">
|
||||||
<directory>../api/src/test/</directory>
|
<directory>../api/src/test/</directory>
|
||||||
<exclude>
|
<directory>../api/src/*/test/</directory>
|
||||||
<!-- This runs fine on its own, but fails in a group if there's no DB -->
|
|
||||||
<file>../api/src/Mail/test/CredentialsTest.php</file>
|
|
||||||
</exclude>
|
|
||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="Apps with test directory">
|
<testsuite name="Apps with test directory">
|
||||||
<directory>../*/test/</directory>
|
<directory>../*/test/</directory>
|
||||||
|
Loading…
Reference in New Issue
Block a user