-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
mambax7
wants to merge
12
commits into
XOOPS:master
Choose a base branch
from
mambax7:feature/tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
PhpUnit tests #1312
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
99b6de1
initial
mambax7 b51adb2
fix for conflict with PhpUnit
mambax7 b8ce948
duplicate testKernel.xml
mambax7 9570b72
Xmf tests
mambax7 83ffa1d
Misordered PHPUnit equality assertion method arguments
mambax7 df42909
changed $debug to public
mambax7 be6565f
replaced $GLOBALS['xoopsModule']
mambax7 deec951
replace $GLOBALS['xoops']->path( with dirname(__DIR__)
mambax7 e8f5a9d
XoopsFormButtonTest
mambax7 680ba35
form tests
mambax7 2aae96b
add .ai
mambax7 6ab6c43
add ProxyCheckTest
mambax7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deny from all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
--> | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
require_once(XOOPS_TU_ROOT_PATH . '/mainfile.php'); | ||
//require_once(XOOPS_TU_ROOT_PATH . '/class/XoopsBaseConfig.php'); | ||
|
||
//\XoopsBaseConfig::bootstrapTransition(); | ||
// | ||
//\Xoops\Locale::loadLocale(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
It comes from here: https://github.com/XOOPS/XoopsCore/blob/master/tests/unit/init_new.php