mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
support PHPunit 6.0+ and older 5.7 for PHP 5.6
This commit is contained in:
parent
7e416b12f4
commit
191d6aec45
@ -39,7 +39,7 @@ before_script:
|
||||
yes "" | pecl install apcu;
|
||||
echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini;
|
||||
phpenv config-rm xdebug.ini;
|
||||
composer require 'phpunit/phpunit';
|
||||
composer require 'phpunit/phpunit:~6.3';
|
||||
;;
|
||||
"hhvm")
|
||||
;;
|
||||
|
@ -17,7 +17,7 @@ namespace EGroupware\Api\Mail;
|
||||
require_once realpath(__DIR__.'/../../loader/common.php'); // autoloader & check_load_extension
|
||||
|
||||
use EGroupware\Api;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
use EGroupware\Api\Mail\Credentials;
|
||||
|
||||
@ -27,7 +27,7 @@ use EGroupware\Api\Mail\Credentials;
|
||||
* Only testing en&decryption of mail passwords so far.
|
||||
* Further tests would need database.
|
||||
*/
|
||||
class CredentialsTest extends PHPUnit_Framework_TestCase
|
||||
class CredentialsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test new 16.1 AES password encryption with OpenSSL
|
||||
|
@ -16,8 +16,7 @@ require_once realpath(__DIR__.'/../common.php'); // autoloader & check_load_exte
|
||||
// We're testing security.php
|
||||
require_once realpath(__DIR__.'/../security.php');
|
||||
|
||||
use EGroupware\Api;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use PHPUnit\Framework\TestCase as TestCase;
|
||||
|
||||
|
||||
class SecurityTest extends TestCase {
|
||||
@ -38,13 +37,13 @@ class SecurityTest extends TestCase {
|
||||
// Must remember to clear this, or other tests may break
|
||||
unset($GLOBALS['egw']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test some strings for bad stuff
|
||||
*
|
||||
*
|
||||
* @param String $pattern String to check
|
||||
* @param boolean $should_fail If we expect this string to fail
|
||||
*
|
||||
*
|
||||
* @dataProvider patternProvider
|
||||
*/
|
||||
public function testPatterns($pattern, $should_fail)
|
||||
@ -129,6 +128,7 @@ class SecurityTest extends TestCase {
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
unset($e);
|
||||
return false;
|
||||
}
|
||||
$replace = array(
|
||||
@ -175,6 +175,7 @@ class SecurityTest extends TestCase {
|
||||
{
|
||||
if (PHP_VERSION >= 7)
|
||||
{
|
||||
$matches = null;
|
||||
if (preg_match_all('/([^ ]+) Object\(/', array2string($r), $matches))
|
||||
{
|
||||
foreach($matches[1] as $class)
|
||||
|
@ -17,7 +17,7 @@ namespace EGroupware\Api;
|
||||
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
||||
|
||||
use EGroupware\Api;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use PHPUnit\Framework\TestCase as TestCase;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
|
@ -13,8 +13,7 @@ namespace EGroupware\Api;
|
||||
|
||||
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
||||
|
||||
use EGroupware\Api;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use PHPUnit\Framework\TestCase as TestCase;
|
||||
|
||||
/**
|
||||
* Testing the Egroupware extension of DateTime
|
||||
@ -80,8 +79,8 @@ class DateTimeTest extends TestCase {
|
||||
$ts = DateTime::to(array('full' => '20091027', 'hour' => 10, 'minute' => 0),'ts');
|
||||
$this->assertEquals(DateTime::user2server($ts,''), DateTime::server2user(DateTime::user2server($ts),''));
|
||||
|
||||
$ts = DateTime::to(array('full' => '20090627', 'hour' => 10, 'minute' => 0),'ts');
|
||||
$this->assertEquals(DateTime::user2server($ts,''), DateTime::server2user(DateTime::user2server($ts),''));
|
||||
$ts2 = DateTime::to(array('full' => '20090627', 'hour' => 10, 'minute' => 0),'ts');
|
||||
$this->assertEquals(DateTime::user2server($ts2,''), DateTime::server2user(DateTime::user2server($ts),''));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,8 +99,8 @@ class DateTimeTest extends TestCase {
|
||||
|
||||
// Set user to Cape Verde (UTC+1)
|
||||
DateTime::setUserPrefs('Atlantic/Cape_Verde');
|
||||
$ts = DateTime::to(array('full' => '20091027', 'hour' => 10, 'minute' => 0),'ts');
|
||||
$this->assertEquals('2009-10-27 11:00:00', DateTime::user2server($ts,'Y-m-d H:i:s'));
|
||||
$ts2 = DateTime::to(array('full' => '20091027', 'hour' => 10, 'minute' => 0),'ts');
|
||||
$this->assertEquals('2009-10-27 11:00:00', DateTime::user2server($ts2,'Y-m-d H:i:s'));
|
||||
|
||||
date_default_timezone_set($server_tz);
|
||||
}
|
||||
|
@ -14,9 +14,6 @@ namespace EGroupware\Api;
|
||||
|
||||
require_once realpath(__DIR__.'/../Etemplate/test/WidgetBaseTest.php');
|
||||
|
||||
use EGroupware\Api;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
|
||||
/**
|
||||
* Test the main class of Etemplate
|
||||
*
|
||||
@ -34,11 +31,11 @@ class EtemplateTest extends Etemplate\WidgetBaseTest {
|
||||
protected $content = array('value' => 'test content');
|
||||
protected $sel_options = array(array('value' => 0, 'label' => 'label'));
|
||||
protected $readonlys = array('value' => true);
|
||||
|
||||
|
||||
/**
|
||||
* Test reading xml files
|
||||
*
|
||||
* This really just tests that the files can be found and executed.
|
||||
* This really just tests that the files can be found and executed.
|
||||
*/
|
||||
public function testRead()
|
||||
{
|
||||
@ -136,7 +133,7 @@ class EtemplateTest extends Etemplate\WidgetBaseTest {
|
||||
$etemplate->read(static::TEST_TEMPLATE);
|
||||
|
||||
$this->readonlys['value'] = false;
|
||||
|
||||
|
||||
$result = $this->mockedRoundTrip($etemplate, $this->content, $this->sel_options, $this->readonlys);
|
||||
|
||||
$this->assertEquals($this->content, $result);
|
||||
@ -188,18 +185,18 @@ class EtemplateTest extends Etemplate\WidgetBaseTest {
|
||||
// Now try with widget
|
||||
$this->readonlys['value'] = false;
|
||||
|
||||
$result = $this->mockedRoundTrip($etemplate, $this->content, $this->sel_options, $this->readonlys, $preserve);
|
||||
$result2 = $this->mockedRoundTrip($etemplate, $this->content, $this->sel_options, $this->readonlys, $preserve);
|
||||
|
||||
// The only input widget is readonly, expect preserve + content back
|
||||
$this->assertArraySubset($this->content, $result);
|
||||
$this->assertArraySubset($preserve, $result);
|
||||
$this->assertArraySubset($this->content, $result2);
|
||||
$this->assertArraySubset($preserve, $result2);
|
||||
}
|
||||
|
||||
public function testReadonlyPreserve()
|
||||
{
|
||||
$etemplate = new Etemplate();
|
||||
$etemplate->read(static::TEST_TEMPLATE);
|
||||
|
||||
|
||||
$this->readonlys['value'] = true;
|
||||
$preserve['value'] = 'preserved_value';
|
||||
|
||||
@ -209,10 +206,9 @@ class EtemplateTest extends Etemplate\WidgetBaseTest {
|
||||
$this->assertEquals($preserve['value'], $result['value']);
|
||||
|
||||
$this->readonlys['value'] = false;
|
||||
$result = $this->mockedRoundTrip($etemplate, $this->content, $this->sel_options, $this->readonlys, $preserve);
|
||||
$result2 = $this->mockedRoundTrip($etemplate, $this->content, $this->sel_options, $this->readonlys, $preserve);
|
||||
|
||||
// The only input widget is editable, expect content back, not preserve
|
||||
$this->assertEquals($this->content['value'], $result['value']);
|
||||
|
||||
$this->assertEquals($this->content['value'], $result2['value']);
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ namespace EGroupware\Api;
|
||||
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
||||
|
||||
use EGroupware\Api\Framework;
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use PHPUnit\Framework\TestCase as TestCase;
|
||||
|
||||
/**
|
||||
* Tests for IncludeMgr
|
||||
*
|
||||
*
|
||||
*/
|
||||
class IncludeMgrTest extends TestCase
|
||||
{
|
||||
|
@ -16,8 +16,8 @@ namespace EGroupware\Api;
|
||||
|
||||
require_once realpath(__DIR__.'/../loader/common.php'); // autoloader & check_load_extension
|
||||
|
||||
use PHPUnit_Framework_TestCase as TestCase;
|
||||
use PHPUnit_Framework_ExpectationFailedException as PHPUnitException;
|
||||
use PHPUnit\Framework\TestCase as TestCase;
|
||||
use PHPUnit\Framework\ExpectationFailedException as PHPUnitException;
|
||||
use EGroupware\Api;
|
||||
|
||||
/**
|
||||
@ -167,7 +167,7 @@ abstract class LoggedInTest extends TestCase
|
||||
|
||||
$GLOBALS['egw'] = new Api\Egw(array_keys($GLOBALS['egw_domain']));
|
||||
}
|
||||
|
||||
|
||||
// Disable asyc while we test
|
||||
$GLOBALS['egw_info']['server']['asyncservice'] = 'off';
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @package
|
||||
* @package
|
||||
* @copyright (c) 2017 Nathan Gray
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
*/
|
||||
@ -15,6 +15,13 @@
|
||||
// autoloader & check_load_extension
|
||||
require_once realpath(__DIR__.'/../api/src/loader/common.php');
|
||||
|
||||
// backward compatibility with PHPunit 5.7
|
||||
if (!class_exists('\PHPUnit\Framework\TestCase') && class_exists('\PHPUnit_Framework_TestCase'))
|
||||
{
|
||||
class_alias('\PHPUnit_Framework_TestCase', '\PHPUnit\Framework\TestCase');
|
||||
class_alias('\PHPUnit_Framework_ExpectationFailedException', '\PHPUnit\Framework\ExpectationFailedException');
|
||||
}
|
||||
|
||||
// Needed to let Cache work
|
||||
$GLOBALS['egw_info']['server']['temp_dir'] = '/tmp';
|
||||
$GLOBALS['egw_info']['server']['install_id'] = 'PHPUnit test';
|
Loading…
Reference in New Issue
Block a user