Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhpUnit tests #1312

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ htdocs/xoops_data/protector/*
htdocs/xoops_data/data/secure.php
htdocs/xoops_data/data/license.php
htdocs/xoops_data/data/*key*

.ai
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class AbstractHelper
/**
* @var bool true if debug is enabled
*/
protected $debug;
public $debug;

/**
* Instantiate a XoopsModule object for the helper to use.
Expand All @@ -60,7 +60,9 @@ public function __construct($dirname = null)
if (isset($xoops)) {
$this->module = $xoops->module;
} else {
$this->module = $GLOBALS['xoopsModule'];
// $this->module = $GLOBALS['xoopsModule'];
global $xoopsModule;
$this->module = $xoopsModule;
}
} else {
// assume dirname specified, try to get a module object
Expand Down
5 changes: 2 additions & 3 deletions htdocs/kernel/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
defined('XOOPS_ROOT_PATH') || exit('Restricted access');

require_once $GLOBALS['xoops']->path('kernel/configoption.php');
require_once $GLOBALS['xoops']->path('kernel/configitem.php');

require_once __DIR__ . '/configoption.php';
require_once __DIR__ . '/configitem.php';
/**
* XOOPS configuration handling class.
* This class acts as an interface for handling general configurations of XOOPS
Expand Down
4 changes: 2 additions & 2 deletions htdocs/kernel/member.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
defined('XOOPS_ROOT_PATH') || exit('Restricted access');

require_once $GLOBALS['xoops']->path('kernel/user.php');
require_once $GLOBALS['xoops']->path('kernel/group.php');
require_once __DIR__ . '/user.php';
require_once __DIR__ . '/group.php';

/**
* XOOPS member handler class.
Expand Down
16 changes: 12 additions & 4 deletions htdocs/kernel/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,20 @@ public function loadInfo($dirname, $verbose = true)
return true;
}
global $xoopsConfig;
if (file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/language/' . $xoopsConfig['language'] . '/modinfo.php'))) {
// if (file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/language/' . $xoopsConfig['language'] . '/modinfo.php'))) {
// include_once $file;
// } elseif (file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/language/english/modinfo.php'))) {
// include_once $file;
// }

if (file_exists($file = dirname(__DIR__) . '/modules/' . $dirname . '/language/' . $xoopsConfig['language'] . '/modinfo.php')) {
include_once $file;
} elseif (file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/language/english/modinfo.php'))) {
} elseif (file_exists($file = dirname(__DIR__) . '/modules/' . $dirname . '/language/english/modinfo.php')) {
include_once $file;
}

if (!file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/xoops_version.php'))) {
// if (!file_exists($file = $GLOBALS['xoops']->path('modules/' . $dirname . '/xoops_version.php'))) {
if (!file_exists($file = dirname(__DIR__) . '/modules/' . $dirname . '/xoops_version.php')) {
if (false !== (bool)$verbose) {
echo "Module File for $dirname Not Found!";
}
Expand Down Expand Up @@ -322,7 +329,8 @@ public function search($term = '', $andor = 'AND', $limit = 0, $offset = 0, $use
if ($this->getVar('hassearch') != 1 || !isset($search['file']) || !isset($search['func']) || $search['func'] == '' || $search['file'] == '') {
return false;
}
if (file_exists($file = $GLOBALS['xoops']->path('modules/' . $this->getVar('dirname') . '/' . $search['file']))) {
// if (file_exists($file = $GLOBALS['xoops']->path('modules/' . $this->getVar('dirname') . '/' . $search['file']))) {
if (file_exists($file = dirname(__DIR__) . '/modules/' . $this->getVar('dirname') . '/' . $search['file'])) {
include_once $file;
} else {
return false;
Expand Down
1 change: 1 addition & 0 deletions htdocs/tests/Unit/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deny from all
43 changes: 43 additions & 0 deletions htdocs/tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

if (empty($_SERVER['argc'])) {
echo 'Error: This script must be run from the command line';
die(1);
}

if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
echo 'Error: This script must be run from PHP >= 5.3.0';
die(1);
}

define('CLI', true);

ini_set('memory_limit', -1);

while (ob_get_level()) {
ob_end_flush();
}


/*
<!--
1. Put your tests in a folder called "tests" (with an .htaccess "deny from all")
2. If there are any slow tests, annotate the test method with a "@group slow" PHP-doc-style comment. These tests will me ignored by default.
3. To run tests:
$ cd my-project
$ phpunit
4. To run slow tests:
$ cd my-project
$ phpunit --no-configuration --group slow tests
5. To run a specific test case:
$ cd my-project
$ phpunit --no-configuration tests/myTests.php
5. To run a specific tests (e.g. WidgetAddTest, WidgetDeleteTest):
$ cd my-project
$ phpunit --no-configuration --filter Widget tests
6. Lovely test reports can be found in the test-reports directory (with an .htaccess "deny from all")
-->

*/
Loading