Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
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
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")
-->

*/
39 changes: 39 additions & 0 deletions htdocs/tests/Unit/class/testClass.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="false"
verbose="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
bootstrap="bootstrap.php"
>

<testsuites>
<testsuite name="My Test Suite for Class">
<directory>class</directory>
</testsuite>
</testsuites>

<groups>
<exclude>
<group>slow</group>
</exclude>
</groups>

<filter>
<whitelist>
<directory suffix=".php">../htdocs/class</directory>
<exclude>
</exclude>
</whitelist>
</filter>

<!--
<logging>
<log type="coverage-html" target="test-report-class" charset="UTF-8" yui="true" />
</logging>
-->

</phpunit>
30 changes: 30 additions & 0 deletions htdocs/tests/Unit/common_phpunit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

// needed for phpunit => initializing $_SERVER values
if (empty($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = 'localhost';
$_SERVER['HTTP_CONNECTION'] = 'keep-alive';
$_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1496.0 Safari/537.36';
$_SERVER['HTTP_REFERER'] = 'http://localhost/xoops/';
$_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate,sdch';
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4';
$_SERVER['SERVER_SIGNATURE'] = '';
$_SERVER['SERVER_SOFTWARE'] = 'Apache/2.2.3 (Win32) PHP/7.4.0';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_PORT'] = '80';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REMOTE_PORT'] = '58644';
$_SERVER['GATEWAY_INTERFACE'] = 'CGI/1.1';
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['QUERY_STRING'] = '';
$_SERVER['REQUEST_URI'] = '/XoopsCore/tests/xoops_lib/XoopsTest.php';
}
42 changes: 42 additions & 0 deletions htdocs/tests/Unit/init_new.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

if (defined('XOOPS_TU_ROOT_PATH')) {
return;
}

if (version_compare(PHP_VERSION, '7.4.0', '<')) {
die('XOOP check: PHP version require 7.4.0 or more');
}

// needed for phpunit => initializing $_SERVER values
if (empty($_SERVER['HTTP_HOST'])) {
define('IS_PHPUNIT', true);
}

if (defined('IS_PHPUNIT')) {
require_once __DIR__ . '/common_phpunit.php';
} else {
// Avoid check proxy to define constant XOOPS_DB_PROXY
// because it implies a readonly database connection
$_SERVER['REQUEST_METHOD'] = 'POST';
define('XOOPS_XMLRPC', 0);
}

define('XOOPS_TU_ROOT_PATH', realpath(dirname(__DIR__, 2)));

// echo 'XOOPS_TU_ROOT_PATH = ' . XOOPS_TU_ROOT_PATH. "\n";

//temporary patch, we still need mainfile until we have a config file
$xoopsOption['nocommon'] = true; // don't include common.php file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not including common.php?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

require_once(XOOPS_TU_ROOT_PATH . '/mainfile.php');
//require_once(XOOPS_TU_ROOT_PATH . '/class/XoopsBaseConfig.php');

//\XoopsBaseConfig::bootstrapTransition();
//
//\Xoops\Locale::loadLocale();
33 changes: 33 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsBlockHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/class/logger/xoopslogger.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/xoopsload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/preload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/database/databasefactory.php');

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/block.php');

class XoopsBlockHandlerTest extends TestCase
{
protected $conn = null;

protected function setUp(): void
{
$this->conn = XoopsDatabaseFactory::getDatabaseConnection();
}

public function test___construct()
{
$instance = new \XoopsBlockHandler($this->conn);
$this->assertInstanceOf(\XoopsBlockHandler::class, $instance);
}
}
25 changes: 25 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsBlockTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/block.php');

class XoopsBlockTest extends TestCase
{
protected function setUp():void
{
}

public function test___construct()
{
$instance = new \XoopsBlock();
$this->assertInstanceOf(\XoopsBlock::class, $instance);
}
}
33 changes: 33 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsConfigHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/class/logger/xoopslogger.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/xoopsload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/preload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/database/databasefactory.php');

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/config.php');

class XoopsConfigHandlerTest extends TestCase
{
protected $conn = null;

protected function setUp():void
{
$this->conn = XoopsDatabaseFactory::getDatabaseConnection();
}

public function test___construct()
{
$instance = new \XoopsConfigHandler($this->conn);
$this->assertInstanceOf(\XoopsConfigHandler::class, $instance);
}
}
34 changes: 34 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsConfigItemHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/class/logger/xoopslogger.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/xoopsload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/preload.php');
require_once(XOOPS_TU_ROOT_PATH . '/class/database/databasefactory.php');

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/configitem.php');

class XoopsConfigItemHandlerTest extends TestCase
{
protected $myclass = 'XoopsConfigItemHandler';
protected $conn = null;

protected function setUp(): void
{
$this->conn = XoopsDatabaseFactory::getDatabaseConnection();
}

public function test___construct()
{
$instance = new \XoopsConfigItemHandler($this->conn);
$this->assertInstanceOf(\XoopsConfigItemHandler::class, $instance);
}
}
25 changes: 25 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsConfigItemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/configitem.php');

class XoopsConfigItemTest extends TestCase
{
protected function setUp():void
{
}

public function test___construct()
{
$instance = new \XoopsConfigItem();
$this->assertInstanceOf(\XoopsConfigItem::class, $instance);
}
}
29 changes: 29 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsConfigOptionHandlerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/kernel/config.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/configitem.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/configoption.php');

class XoopsConfigOptionHandlerTest extends TestCase
{
protected $conn = null;

protected function setUp():void
{
$this->conn = XoopsDatabaseFactory::getDatabaseConnection();
}

public function test___construct()
{
$instance = new \XoopsConfigOptionHandler($this->conn);
$this->assertInstanceOf(\XoopsConfigOptionHandler::class, $instance);
}
}
25 changes: 25 additions & 0 deletions htdocs/tests/Unit/kernel/XoopsConfigOptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

//namespace Xoops\Tests\Database;

use PHPUnit\Framework\TestCase;

require_once dirname(__DIR__) . '/init_new.php';

require_once(XOOPS_TU_ROOT_PATH . '/kernel/object.php');
require_once(XOOPS_TU_ROOT_PATH . '/kernel/configoption.php');

class XoopsConfigOptionTest extends TestCase
{
protected function setUp():void
{
}

public function test___construct()
{
$instance = new \XoopsConfigOption();
$this->assertInstanceOf(\XoopsConfigOption::class, $instance);
}
}
Loading