Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Apr 8, 2022
1 parent 47b9222 commit 14bed92
Show file tree
Hide file tree
Showing 25 changed files with 122 additions and 79 deletions.
2 changes: 1 addition & 1 deletion plugins/calendar/configuration_validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$_CONF_VALIDATE['calendar']['hour_mode'] = array(
'rule' => array('inList', array('12', '24'), true)
);
$_CONF_VALIDATE['calendar']['event_types'] = array('stringOrEmpty');
$_CONF_VALIDATE['calendar']['event_types'] = array('rule' => 'stringOrEmpty');
$_CONF_VALIDATE['calendar']['notification'] = array('rule' => 'boolean');
$_CONF_VALIDATE['calendar']['delete_event'] = array('rule' => 'boolean');
$_CONF_VALIDATE['calendar']['aftersave'] = array(
Expand Down
5 changes: 5 additions & 0 deletions system/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"phpmailer/phpmailer": "^6.5",
"psr/container": "^1.0"
},
"autoload": {
"psr-4": {
"Geeklog\\Test\\": "../tests/system/classes/"
}
},
"repositories": [
{
"type": "composer",
Expand Down
2 changes: 1 addition & 1 deletion system/vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
2 changes: 1 addition & 1 deletion system/vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_files.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
2 changes: 1 addition & 1 deletion system/vendor/composer/autoload_namespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
3 changes: 2 additions & 1 deletion system/vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand All @@ -23,4 +23,5 @@
'Illuminate\\Container\\' => array($vendorDir . '/illuminate/container'),
'Illuminate\\Config\\' => array($vendorDir . '/illuminate/config'),
'IPLib\\' => array($vendorDir . '/mlocati/ip-lib/src'),
'Geeklog\\Test\\' => array($baseDir . '/../tests/system/classes'),
);
31 changes: 4 additions & 27 deletions system/vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,19 @@ public static function getLoader()
require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInite72621cdbb7ab1eae4754470aabe0609', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInite72621cdbb7ab1eae4754470aabe0609', 'loadClassLoader'));

$includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInite72621cdbb7ab1eae4754470aabe0609::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}

$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}

$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
require __DIR__ . '/autoload_static.php';
\Composer\Autoload\ComposerStaticInite72621cdbb7ab1eae4754470aabe0609::getInitializer($loader)();

$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInite72621cdbb7ab1eae4754470aabe0609::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
$includeFiles = \Composer\Autoload\ComposerStaticInite72621cdbb7ab1eae4754470aabe0609::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequiree72621cdbb7ab1eae4754470aabe0609($fileIdentifier, $file);
}
Expand Down
8 changes: 8 additions & 0 deletions system/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class ComposerStaticInite72621cdbb7ab1eae4754470aabe0609
'Illuminate\\Config\\' => 18,
'IPLib\\' => 6,
),
'G' =>
array (
'Geeklog\\Test\\' => 13,
),
);

public static $prefixDirsPsr4 = array (
Expand Down Expand Up @@ -121,6 +125,10 @@ class ComposerStaticInite72621cdbb7ab1eae4754470aabe0609
array (
0 => __DIR__ . '/..' . '/mlocati/ip-lib/src',
),
'Geeklog\\Test\\' =>
array (
0 => __DIR__ . '/../..' . '/../tests/system/classes',
),
);

public static $prefixesPsr0 = array (
Expand Down
2 changes: 1 addition & 1 deletion system/vendor/composer/include_paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// include_paths.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
7 changes: 7 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ function COM_isEnableDeveloperModeLog($type)

}

if (!is_callable('COM_strftime')) {
function COM_strftime($format, $timestamp = null)
{
return strftime($format, $timestamp);
}
}

// To disable your site quickly, simply set this flag to false
$_CONF['site_enabled'] = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
<?php

use \PHPUnit\Framework\TestCase;
namespace Geeklog\Test;

use Calendar;
use CalendarDay;
use PHPUnit\Framework\TestCase;
use TimeZoneConfig;

/**
* Simple tests for calendarClassTest
*/
class calendarClass extends TestCase
class CalendarClassTest extends TestCase
{
/**
* @var Calendar
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?php

use \PHPUnit\Framework\TestCase;
namespace Geeklog\Test;

use CalendarDay;
use PHPUnit\Framework\TestCase;

/**
* Simple tests for the CalendarDay class
*/
class calendarDayClass extends TestCase
class CalendarDayClassTest extends TestCase
{
private $cd;

Expand Down
5 changes: 4 additions & 1 deletion tests/system/classes/ContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

namespace Geeklog\Test;

use Geeklog\Container\Container;
use PHPMailer\PHPMailer\PHPMailer;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerExceptionInterface;
use StdClass;

class ContainerTest extends TestCase
{
Expand All @@ -14,7 +17,7 @@ class ContainerTest extends TestCase

protected function setUp(): void
{
$this->container = new Geeklog\Container\Container();
$this->container = new Container();
$this->container->set('foo', 1);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?php

use \PHPUnit\Framework\TestCase;
namespace Geeklog\Test;

use downloader;
use PHPUnit\Framework\TestCase;

/**
* Simple tests for the downloader class
* Obviously, we can't really test the download functionality. So test at least
* the getter / setter methods.
*/
class downloaderClass extends TestCase
class DownloaderClassTest extends TestCase
{
/**
* @var downloader
Expand Down
19 changes: 11 additions & 8 deletions tests/system/classes/IpClassTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php

use \PHPUnit\Framework\TestCase;
namespace Geeklog\Test;

use Geeklog\IP;
use PHPUnit\Framework\TestCase;

class IpClassTest extends TestCase
{
Expand All @@ -20,7 +23,7 @@ public function testMatchCIDR()
$CIDR = '204.0.113.1/18';

foreach ($data as $ip => $expected) {
$got = \Geeklog\IP::matchCIDR($ip, $CIDR);
$got = IP::matchCIDR($ip, $CIDR);
$this->assertEquals(
$expected,
$got,
Expand All @@ -43,7 +46,7 @@ public function testMatchCIDRIPv6()
$CIDR = '2001:4860:4860::8888/32';

foreach ($data as $ip => $expected) {
$got = \Geeklog\IP::matchCIDR($ip, $CIDR);
$got = IP::matchCIDR($ip, $CIDR);
$this->assertEquals(
$expected,
$got,
Expand All @@ -67,7 +70,7 @@ public function testMatchRange()
$ipToCheck = '100.0.113.0';

foreach ($data as $range => $expected) {
$got = \Geeklog\IP::matchRange($ipToCheck, $range);
$got = IP::matchRange($ipToCheck, $range);
$this->assertEquals(
$expected,
$got,
Expand All @@ -82,7 +85,7 @@ public function testMatchRange()
$ipToCheck = '2001:4860:4860:0000:0000:0000:1000:8888';

foreach ($data as $range => $expected) {
$got = \Geeklog\IP::matchRange($ipToCheck, $range);
$got = IP::matchRange($ipToCheck, $range);
$this->assertEquals(
$expected,
$got,
Expand All @@ -105,7 +108,7 @@ public function testIsValidIP()
];

foreach ($data as $ip => $expected) {
$got = \Geeklog\IP::isValidIP($ip);
$got = IP::isValidIP($ip);
$this->assertEquals(
$expected,
$got,
Expand All @@ -129,7 +132,7 @@ public function testIsValidIPv4()
];

foreach ($data as $ip => $expected) {
$got = \Geeklog\IP::isValidIPv4($ip);
$got = IP::isValidIPv4($ip);
$this->assertEquals(
$expected,
$got,
Expand All @@ -151,7 +154,7 @@ public function testIsValidIPv6()
];

foreach ($data as $ip => $expected) {
$got = \Geeklog\IP::isValidIPv6($ip);
$got = IP::isValidIPv6($ip);
$this->assertEquals(
$expected,
$got,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

namespace Geeklog\Test;

use config;
use Geeklog\ConfigInterface;
use PHPUnit\Framework\TestCase as TestCase;
use Tst;

/**
* There is now a dependency between the entries for dropdown menus in
Expand All @@ -10,7 +14,7 @@
* These tests ensure that all selection list entries match their equivalent
* in the list of to-be-validated entries.
*/
class langConfValidation extends TestCase
class LangConfValidationTest extends TestCase
{
/**
* @var config
Expand All @@ -19,7 +23,7 @@ class langConfValidation extends TestCase

protected function setUp(): void
{
global $_CONF, $_CONF_VALIDATE, $_USER;
global $_CONF, $_CONF_VALIDATE, $_USER, $_DB_dbms;

// set dummy values for the $_CONF options used in the language files
$_CONF = array();
Expand Down Expand Up @@ -101,7 +105,7 @@ protected function setUp(): void
*/
protected function checkForMissingEntries($type, $lang = '')
{
global $_CONF_VALIDATE, $LANG_configselects;
global $_CONF_VALIDATE, $LANG_configselects, $LANG_VALIDATION;

// loop through validation rules
foreach ($_CONF_VALIDATE[$type] as $key => $val) {
Expand Down Expand Up @@ -131,7 +135,7 @@ protected function checkForMissingEntries($type, $lang = '')
$this->assertEquals(count($ref), count($values));
foreach ($values as $v) {
$this->assertTrue(
(array_search($v, $ref) !== false),
(in_array($v, $ref)),
"$lang: '$key' missing '$v'"
);
}
Expand Down Expand Up @@ -186,7 +190,7 @@ public function testLinksPluginEnglish() {
*/
public function testCoreLanguages()
{
global $_CONF, $_CONF_VALIDATE, $LANG32, $_DB_mysqldump_path, $LANG_configselects;
global $_CONF, $_CONF_VALIDATE, $LANG32, $_DB_dbms, $_DB_mysqldump_path, $LANG_configselects;

$basePath = Tst::$root . 'language/';

Expand All @@ -198,10 +202,11 @@ public function testCoreLanguages()

public function testCalendarPluginLanguages()
{
global $_CONF, $_CONF_VALIDATE, $_USER, $_DB_mysqldump_path, $LANG_configselects;
global $_CONF, $_CONF_VALIDATE, $_USER, $_DB_dbms, $_DB_mysqldump_path, $LANG32, $LANG_configselects;

$basePath = Tst::$root . 'plugins/calendar/';

include Tst::$root . 'language/english.php';
include $basePath . 'configuration_validation.php';

foreach (glob($basePath . 'language/*.php') as $file) {
Expand Down Expand Up @@ -268,10 +273,11 @@ public function testStaticPagesPluginLanguages()

public function testXMLSitemapPluginLanguages()
{
global $_CONF, $_CONF_VALIDATE, $_DB_mysqldump_path, $LANG_configselects;
global $_CONF, $_CONF_VALIDATE, $_DB_dbms, $_DB_mysqldump_path, $LANG_configselects, $LANG_VALIDATION;

$basePath = Tst::$root . 'plugins/xmlsitemap/';

include Tst::$root . 'language/english.php';
include $basePath . 'configuration_validation.php';

foreach (glob($basePath . 'language/*.php') as $file) {
Expand Down

0 comments on commit 14bed92

Please sign in to comment.