|
From: <al...@us...> - 2013-06-23 17:20:10
|
Revision: 11770
http://sourceforge.net/p/xoops/svn/11770
Author: alain91
Date: 2013-06-23 17:20:07 +0000 (Sun, 23 Jun 2013)
Log Message:
-----------
add tests + fix initialization
Modified Paths:
--------------
XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/common_simpletest.php
XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/xoops_lib/XoopsTest.php
Modified: XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/common_simpletest.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/common_simpletest.php 2013-06-23 17:00:18 UTC (rev 11769)
+++ XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/common_simpletest.php 2013-06-23 17:20:07 UTC (rev 11770)
@@ -3,6 +3,71 @@
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
+if (!defined("XOOPS_MAINFILE_INCLUDED")) {
+ define("XOOPS_MAINFILE_INCLUDED", 1);
+
+ // XOOPS Physical Paths
+
+ // Physical path to the XOOPS documents (served) directory WITHOUT trailing slash
+ define("XOOPS_ROOT_PATH", "D:\MesApp\EasyPHP-2.0b1\www\xoops\htdocs");
+
+ // For forward compatibility
+ // Physical path to the XOOPS library directory WITHOUT trailing slash
+ define("XOOPS_PATH", "D:\MesApp\EasyPHP-2.0b1\www\xoops\htdocs\xoops_lib");
+ // Physical path to the XOOPS datafiles (writable) directory WITHOUT trailing slash
+ define("XOOPS_VAR_PATH", "D:\MesApp\EasyPHP-2.0b1\www\xoops\htdocs\xoops_data");
+ // Alias of XOOPS_PATH, for compatibility, temporary solution
+ define("XOOPS_TRUST_PATH", XOOPS_PATH);
+
+ // URL Association for SSL and Protocol Compatibility
+ $http = 'http://';
+ if (!empty($_SERVER['HTTPS'])) {
+ $http = ($_SERVER['HTTPS']=='on') ? 'https://' : 'http://';
+ }
+ define('XOOPS_PROT', $http);
+
+ // XOOPS Virtual Path (URL)
+ // Virtual path to your main XOOPS directory WITHOUT trailing slash
+ // Example: define("XOOPS_URL", "http://url_to_xoops_directory");
+ define("XOOPS_URL", "http://localhost/xoops/htdocs");
+
+ // Shall be handled later, don't forget!
+ define("XOOPS_CHECK_PATH", 0);
+ // Protect against external scripts execution if safe mode is not enabled
+ if (XOOPS_CHECK_PATH && !@ini_get("safe_mode")) {
+ if (function_exists("debug_backtrace")) {
+ $xoopsScriptPath = debug_backtrace();
+ if (!count($xoopsScriptPath)) {
+ die("XOOPS path check: this file cannot be requested directly");
+ }
+ $xoopsScriptPath = $xoopsScriptPath[0]["file"];
+ } else {
+ $xoopsScriptPath = isset($_SERVER["PATH_TRANSLATED"]) ? $_SERVER["PATH_TRANSLATED"] : $_SERVER["SCRIPT_FILENAME"];
+ }
+ if (DIRECTORY_SEPARATOR != "/") {
+ // IIS6 may double the \ chars
+ $xoopsScriptPath = str_replace(strpos($xoopsScriptPath, "\\\\", 2) ? "\\\\" : DIRECTORY_SEPARATOR, "/", $xoopsScriptPath);
+ }
+ if (strcasecmp(substr($xoopsScriptPath, 0, strlen(XOOPS_ROOT_PATH)), str_replace(DIRECTORY_SEPARATOR, "/", XOOPS_ROOT_PATH))) {
+ exit("XOOPS path check: Script is not inside XOOPS_ROOT_PATH and cannot run.");
+ }
+ }
+
+ // Secure file
+ require XOOPS_VAR_PATH . '/data/secure.php';
+
+ define("XOOPS_GROUP_ADMIN", "1");
+ define("XOOPS_GROUP_USERS", "2");
+ define("XOOPS_GROUP_ANONYMOUS", "3");
+
+ // doesn't include include/common.php
+
+}
+
+require_once XOOPS_ROOT_PATH . DS . 'include' . DS . 'defines.php';
+require_once XOOPS_ROOT_PATH . DS . 'include' . DS . 'version.php';
+require_once XOOPS_ROOT_PATH . DS . 'class' . DS . 'xoopsload.php';
+
defined('SIMPLETEST_ROOT_PATH') OR define('SIMPLETEST_ROOT_PATH',XOOPS_ROOT_PATH.'/../simpletest');
error_reporting(E_ALL);
Modified: XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/xoops_lib/XoopsTest.php
===================================================================
--- XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/xoops_lib/XoopsTest.php 2013-06-23 17:00:18 UTC (rev 11769)
+++ XoopsCore/branches/2.6.x/2.6.0_alain091/UnitTestXoops/xoops_lib/XoopsTest.php 2013-06-23 17:20:07 UTC (rev 11770)
@@ -1,13 +1,18 @@
<?php
require_once(dirname(__FILE__).'/../init_mini.php');
+require_once XOOPS_ROOT_PATH . '/locale/en_US/en_US.php';
+require_once XOOPS_ROOT_PATH . '/locale/en_US/locale.php';
+
class XoopsTest extends MY_UnitTestCase
{
- public function SetUp() {
+ public function SetUp()
+ {
}
- public function test_100() {
+ public function test_100()
+ {
$instance=Xoops::getInstance();
$this->assertInstanceOf('Xoops', $instance);
@@ -36,9 +41,9 @@
$this->assertTrue(is_bool($instance->isAdminSide));
}
- public function test_120() {
+ public function test_200()
+ {
$instance=Xoops::getInstance();
- $this->assertInstanceOf('Xoops', $instance);
$db = $instance->db();
$this->assertInstanceOf('XoopsDatabase', $db);
@@ -47,9 +52,9 @@
$this->assertSame($db, $db1);
}
- public function test_140() {
+ public function test_300()
+ {
$instance=Xoops::getInstance();
- $this->assertInstanceOf('Xoops', $instance);
$value = $instance->preload();
$this->assertInstanceOf('XoopsPreload', $value);
@@ -58,9 +63,9 @@
$this->assertSame($value, $value1);
}
- public function test_160() {
+ public function test_400()
+ {
$instance=Xoops::getInstance();
- $this->assertInstanceOf('Xoops', $instance);
$value = $instance->registry();
$this->assertInstanceOf('Xoops_Registry', $value);
@@ -69,9 +74,9 @@
$this->assertSame($value, $value1);
}
- public function test_180() {
+ public function test_500()
+ {
$instance=Xoops::getInstance();
- $this->assertInstanceOf('Xoops', $instance);
$value = $instance->security();
$this->assertInstanceOf('XoopsSecurity', $value);
@@ -80,9 +85,9 @@
$this->assertSame($value, $value1);
}
- public function test_200() {
+ public function test_600()
+ {
$instance=Xoops::getInstance();
- $this->assertInstanceOf('Xoops', $instance);
$tpl = new XoopsTpl();
@@ -92,5 +97,700 @@
$value1 = $instance->Tpl();
$this->assertSame($value, $value1);
}
+
+ public function test_700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->theme();
+ $this->assertInstanceOf('XoopsTheme', $value);
+
+ $theme = new XoopsTheme();
+ $value = $instance->setTheme($theme);
+ $this->assertSame($theme, $value);
+
+ $value = $instance->theme();
+ $this->assertSame($theme, $value);
+ }
+
+ public function test_800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->path('class');
+ $this->assertTrue(basename($value));
+ $this->assertEquals(XOOPS_ROOT_PATH, dirname($value));
+ }
+
+ public function test_900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->url('http://localhost/tmp/');
+ $this->assertSame('http://localhost/tmp/', $value);
+
+ $value = $instance->url('http://localhost/tmp');
+ $this->assertSame('http://localhost/tmp', $value);
+
+ $value = $instance->url('tmp');
+ $this->assertSame(XOOPS_URL.'/tmp', $value);
+ }
+
+ public function test_1000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->buildUrl('http://localhost/tmp/');
+ $this->assertSame('http://localhost/tmp/', $value);
+
+ $value = $instance->url('.');
+ $this->assertSame(XOOPS_URL.'/.', $value);
+ }
+
+ public function test_1100()
+ {
+ $instance=Xoops::getInstance();
+
+ $this->expectError();
+ $value = $instance->pathExists('',E_USER_WARNING);
+ $this->assertSame(false, $value);
+
+ $value = $instance->pathExists('class',E_USER_WARNING);
+ $this->assertSame(false, $value);
+ }
+
+ public function test_1200()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->gzipCompression();
+ $this->assertSame(true, false);
+ }
+
+ public function test_1300()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->pathTranslation();
+ $this->assertSame(true, false);
+ }
+
+ public function test_1400()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->themeSelect();
+ $this->assertSame(true, false);
+ }
+
+ public function test_1500()
+ {
+ $instance=Xoops::getInstance();
+
+ $path = 'path';
+ $value = $instance->getTplInfo($path);
+ $this->assertSame('module', $value['type']);
+ $this->assertSame('system', $value['module']);
+ $this->assertSame('path', $value['file']);
+ $this->assertSame('module:system|path', $value['tpl_name']);
+ }
+
+ public function test_1600()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->header();
+ $this->assertSame(true, $value);
+ }
+
+ public function test_1700()
+ {
+ $instance=Xoops::getInstance();
+
+ //$value = $instance->footer();
+ $this->assertSame(true, false);
+ }
+
+ public function test_1800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->isModule();
+ $this->assertSame(false, $value);
+ }
+
+ public function test_1900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->isUser();
+ $this->assertSame(false, $value);
+ }
+
+ public function test_2000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->isAdmin();
+ $this->assertSame(false, $value);
+ }
+
+ public function test_2100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->request();
+ $this->assertInstanceOf('Xoops_Request_Http', $value);
+ }
+
+ public function test_2200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerBlock();
+ $this->assertInstanceOf('XoopsBlockHandler', $value);
+ }
+
+ public function test_2300()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerBlockmodulelink();
+ $this->assertInstanceOf('XoopsBlockmodulelinkHandler', $value);
+ }
+
+ public function test_2400()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerCachemodel();
+ $this->assertInstanceOf('XoopsCachemodelHandler', $value);
+ }
+
+ public function test_2500()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerConfig();
+ $this->assertInstanceOf('XoopsConfigHandler', $value);
+ }
+
+ public function test_2600()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerConfigcategory();
+ $this->assertInstanceOf('XoopsConfigCategoryHandler', $value);
+ }
+
+ public function test_2700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerConfigitem();
+ $this->assertInstanceOf('XoopsConfigItemHandler', $value);
+ }
+
+ public function test_2800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerConfigoption();
+ $this->assertInstanceOf('XoopsConfigOptionHandler', $value);
+ }
+
+ public function test_2900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerGroup();
+ $this->assertInstanceOf('XoopsGroupHandler', $value);
+ }
+
+ public function test_3000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerGroupperm();
+ $this->assertInstanceOf('XoopsGrouppermHandler', $value);
+ }
+
+ public function test_3100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerMember();
+ $this->assertInstanceOf('XoopsMemberHandler', $value);
+ }
+
+ public function test_3200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerMembership();
+ $this->assertInstanceOf('XoopsMembershipHandler', $value);
+ }
+
+ public function test_3300()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerModule();
+ $this->assertInstanceOf('XoopsModuleHandler', $value);
+ }
+
+ public function test_3400()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerOnline();
+ $this->assertInstanceOf('XoopsOnlineHandler', $value);
+ }
+
+ public function test_3500()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerPrivmessage();
+ $this->assertInstanceOf('XoopsPrivmessageHandler', $value);
+ }
+
+ public function test_3600()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerRanks();
+ $this->assertInstanceOf('XoopsRanksHandler', $value);
+ }
+
+ public function test_3700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerSession();
+ $this->assertInstanceOf('XoopsSessionHandler', $value);
+ }
+
+ public function test_3800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerTplfile();
+ $this->assertInstanceOf('XoopsTplfileHandler', $value);
+ }
+
+ public function test_3900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerTplset();
+ $this->assertInstanceOf('XoopsTplsetHandler', $value);
+ }
+
+ public function test_4000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandlerUser();
+ $this->assertInstanceOf('XoopsUserHandler', $value);
+ }
+
+ public function test_4100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getHandler('user');
+ $this->assertInstanceOf('XoopsUserHandler', $value);
+ }
+
+ public function test_4200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleHandler();
+ $this->assertSame('', $value);
+ }
+
+ public function test_4300()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleForm(null, null);
+ $this->assertSame(false, $value);
+ }
+
+ public function test_4400()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleHelper('page');
+ $this->assertInstanceOf('Page', $value);
+ }
+
+ public function test_4500()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->loadLanguage(null);
+ $this->assertSame(false, $value);
+ }
+
+ public function test_4600()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->loadLocale();
+ $this->assertSame(true, $value);
+ }
+
+ public function test_4700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->translate(XoopsLocale::ABOUT);
+ $this->assertSame('About', $value);
+ }
+
+ public function test_4800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getActiveModules();
+ $this->assertTrue(is_array($value) AND count($value)>0);
+ }
+
+ public function test_4900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->setActiveModules();
+ $this->assertTrue(is_array($value) AND count($value)>0);
+ }
+
+ public function test_5000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->isActiveModule('page');
+ $this->assertSame(true, $value);
+ }
+
+ public function test_5100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleByDirname('page');
+ $this->assertinstanceOf('XoopsModule', $value);
+ $this->assertSame('Page', $value->name());
+ }
+
+ public function test_5200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleById(1);
+ $this->assertinstanceOf('XoopsModule', $value);
+ }
+
+ public function test_5300()
+ {
+ $instance=Xoops::getInstance();
+
+ ob_start();
+ $instance->simpleHeader();
+ $value = ob_get_contents();
+ ob_end_clean();
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_5400()
+ {
+ $instance=Xoops::getInstance();
+
+ //$instance->simpleFooter();
+ //$this->assertTrue(is_string($value));
+ $this->assertTrue(false);
+ }
+
+ public function test_5500()
+ {
+ $instance=Xoops::getInstance();
+
+ //$value = $instance->alert('test');
+ //$this->assertTrue(is_string($value));
+ $this->assertTrue(false);
+ }
+
+ public function test_5600()
+ {
+ $instance=Xoops::getInstance();
+
+ ob_start();
+ $instance->error('test');
+ $value = ob_get_contents();
+ ob_end_clean();
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_5700()
+ {
+ $instance=Xoops::getInstance();
+
+ ob_start();
+ $instance->result('test');
+ $value = ob_get_contents();
+ ob_end_clean();
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_5800()
+ {
+ $instance=Xoops::getInstance();
+
+ defined('NWLINE') OR define('NWLINE', "\n");
+ //$instance->confirm(array(),array(),'msg');
+ //$this->assertTrue(true);
+ $this->assertTrue(false);
+ }
+
+ public function test_5900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getUserTimestamp(time());
+ $this->assertTrue(is_int($value));
+ }
+
+ public function test_6000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->userTimeToServerTime(time());
+ $this->assertTrue(is_int($value));
+ }
+
+ public function test_6100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->makePass();
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_6200()
+ {
+ $instance=Xoops::getInstance();
+
+ $email = 'te...@te...';
+ $value = $instance->checkEmail($email);
+ $this->assertSame($email, $value);
+ }
+
+ public function test_6300()
+ {
+ $instance=Xoops::getInstance();
+
+ $url = 'http://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'https://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'ftp://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'ftps://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'ed2k://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'ed2ks://localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame($url, $value);
+
+ $url = 'localhost/xoops';
+ $value = $instance->formatURL($url);
+ $this->assertSame('http://'.$url, $value);
+ }
+
+ public function test_6400()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getBanner();
+ $this->assertSame(null, $value);
+ }
+
+ public function test_6500()
+ {
+ $instance=Xoops::getInstance();
+
+ //$value = $instance->redirect();
+ $this->assertTrue(false);
+ }
+
+ public function test_6600()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getEnv('REQUEST_URI');
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_6700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getCss();
+ $this->assertTrue(is_string($value));
+ }
+
+ public function test_6800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getMailer();
+ $this->assertInstanceOf('XoopsMailerLocale', $value);
+ }
+
+ public function test_6900()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getRank();
+ $this->assertTrue(is_array($value));
+ }
+
+ public function test_7000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getOption('dummy');
+ $this->assertSame('', $value);
+ }
+
+ public function test_7100()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->setOption('dummy',null);
+ $value = $instance->getOption('dummy');
+ $this->assertSame('', $value);
+
+ $instance->setOption('dummy','dummy');
+ $value = $instance->getOption('dummy');
+ $this->assertSame('dummy', $value);
+ }
+
+ public function test_7200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getConfig('dummy');
+ $this->assertSame('', $value);
+ }
+
+ public function test_7300()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getConfigs();
+ $this->assertTrue(is_array($value));
+ }
+
+ public function test_7400()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->addConfigs(array());
+ }
+
+ public function test_7500()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->setConfig('dummy');
+ }
+
+ public function test_7600()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->appendConfig('dummy', array());
+ }
+
+ public function test_7700()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleConfig('dummy');
+ $this->assertTrue(is_array($value));
+ }
+
+ public function test_7800()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getModuleConfigs();
+ $this->assertTrue(is_array($value));
+ }
+
+ public function test_7900()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->disableModuleCache();
+ }
+
+ public function test_8000()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getBaseDomain('http::/localhost/tmp');
+ $this->assertSame('', $value);
+ }
+
+ public function test_8100()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->getUrlDomain('http::/localhost/tmp');
+ $this->assertSame('', $value);
+ }
+
+ public function test_8200()
+ {
+ $instance=Xoops::getInstance();
+
+ $value = $instance->templateTouch('default');
+ $this->assertSame(false, $value);
+ }
+ public function test_8300()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->templateClearModuleCache(1);
+ }
+
+ public function test_8400()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->deprecated('message');
+ }
+
+ public function test_8500()
+ {
+ $instance=Xoops::getInstance();
+
+ $instance->disableErrorReporting();
+ }
+
}
|