diff --git a/htdocs/xoops_lib/Xoops/Core/Kernel/Dtype/DtypeEnum.php b/htdocs/xoops_lib/Xoops/Core/Kernel/Dtype/DtypeEnumeration.php similarity index 100% rename from htdocs/xoops_lib/Xoops/Core/Kernel/Dtype/DtypeEnum.php rename to htdocs/xoops_lib/Xoops/Core/Kernel/Dtype/DtypeEnumeration.php diff --git a/htdocs/xoops_lib/Xoops/Core/Kernel/Handlers/XoopsMemberHandler.php b/htdocs/xoops_lib/Xoops/Core/Kernel/Handlers/XoopsMemberHandler.php index a57c49c2b..a36da0c49 100644 --- a/htdocs/xoops_lib/Xoops/Core/Kernel/Handlers/XoopsMemberHandler.php +++ b/htdocs/xoops_lib/Xoops/Core/Kernel/Handlers/XoopsMemberHandler.php @@ -130,9 +130,9 @@ public function getUser($id) */ public function deleteGroup(XoopsGroup $group) { - $this->groupHandler->delete($group); + $ret = $this->groupHandler->delete($group); $this->membershipHandler->deleteAll(new Criteria('groupid', $group->getVar('groupid'))); - return true; + return $ret; } /** @@ -144,9 +144,9 @@ public function deleteGroup(XoopsGroup $group) */ public function deleteUser(XoopsUser $user) { - $this->userHandler->delete($user); + $ret = $this->userHandler->delete($user); $this->membershipHandler->deleteAll(new Criteria('uid', $user->getVar('uid'))); - return true; + return $ret; } /** diff --git a/tests/unit/_archives/init.php b/tests/unit/_archives/init.php deleted file mode 100644 index 863a5005a..000000000 --- a/tests/unit/_archives/init.php +++ /dev/null @@ -1,22 +0,0 @@ - initializing $_SERVER values -if (empty($_SERVER["HTTP_HOST"])) { - define('IS_PHPUNIT',true); -} - -require_once dirname(__FILE__) . '/../../htdocs/xoops_lib/vendor/autoload.php'; - -if (defined('IS_PHPUNIT')) { - require_once dirname(__FILE__) . '/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); -} - -require_once dirname(__FILE__) . '/../../htdocs/mainfile.php'; diff --git a/tests/unit/_archives/init_mini.php b/tests/unit/_archives/init_mini.php deleted file mode 100644 index 2560a13cd..000000000 --- a/tests/unit/_archives/init_mini.php +++ /dev/null @@ -1,95 +0,0 @@ - initializing $_SERVER values -if (empty($_SERVER["HTTP_HOST"])) { - define('IS_PHPUNIT',true); -} - - -if (defined('IS_PHPUNIT')) { - require_once dirname(__FILE__) . '/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); -} - -$xoopsOption["nocommon"]= true; // don't include common.php file -require_once dirname(__FILE__) . '/../../htdocs/mainfile.php'; - -// Get the beginning of include/common.php file but not all - - -/** - * Include XoopsLoad - this should have been done in mainfile.php, but there is - * no update yet, so only only new installs get the change in mainfile.dist.php - * automatically. - * - * Temorarily try and fix, but set up a (delayed) warning - */ -if (!class_exists('XoopsLoad', false)) { - require_once dirname(__FILE__) . '/../../htdocs/class/XoopsBaseConfig.php'; - XoopsBaseConfig::bootstrapTransition(); - $delayedWarning = 'Patch mainfile.php for XoopsBaseConfig'; -} - -global $xoops; -$GLOBALS['xoops'] =& $xoops; - -//Legacy support -global $xoopsDB; -$GLOBALS['xoopsDB'] =& $xoopsDB; -/** - * YOU SHOULD NEVER USE THE FOLLOWING TO CONSTANTS, THEY WILL BE REMOVED - */ -defined('DS') or define('DS', DIRECTORY_SEPARATOR); -defined('NWLINE')or define('NWLINE', "\n"); - -/** - * Include files with definitions - */ -$xoops_root_path = \XoopsBaseConfig::get('root-path'); -include_once $xoops_root_path . DS . 'include' . DS . 'defines.php'; -// include_once XOOPS_ROOT_PATH . DS . 'include' . DS . 'version.php'; - -/** - * Create Instance of Xoops Object - * Atention, not all methods can be used at this point - */ - -$xoops = Xoops::getInstance(); - -$xoops->option =& $GLOBALS['xoopsOption']; - -/** - * Include Required Files not handled by autoload - */ -include_once $xoops->path('include/functions.php'); - -if (!defined('XOOPS_XMLRPC')) { - define('XOOPS_DB_CHKREF', 1); -} else { - define('XOOPS_DB_CHKREF', 0); -} - -/** - * Check Proxy; - * Requires functions - */ -if ($_SERVER['REQUEST_METHOD'] != 'POST' || !$xoops->security()->checkReferer(XOOPS_DB_CHKREF)) { - define('XOOPS_DB_PROXY', 1); -} - -/** - * Load Language settings and defines - */ -$xoops->loadLocale(); -//For legacy -$xoops->setConfig('language', XoopsLocale::getLegacyLanguage()); - -date_default_timezone_set(XoopsLocale::getTimezone()); -setlocale(LC_ALL, XoopsLocale::getLocale()); diff --git a/tests/unit/class/xoopsform/formTest.php b/tests/unit/class/xoopsform/formTest.php new file mode 100644 index 000000000..1a4d5ece0 --- /dev/null +++ b/tests/unit/class/xoopsform/formTest.php @@ -0,0 +1,23 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Form', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formbuttonTest.php b/tests/unit/class/xoopsform/formbuttonTest.php new file mode 100644 index 000000000..66f733c7c --- /dev/null +++ b/tests/unit/class/xoopsform/formbuttonTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Button', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formbuttontrayTest.php b/tests/unit/class/xoopsform/formbuttontrayTest.php new file mode 100644 index 000000000..c8bda39f9 --- /dev/null +++ b/tests/unit/class/xoopsform/formbuttontrayTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\ButtonTray', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formcaptchaTest.php b/tests/unit/class/xoopsform/formcaptchaTest.php new file mode 100644 index 000000000..0a9d48cc0 --- /dev/null +++ b/tests/unit/class/xoopsform/formcaptchaTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Captcha', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formcheckboxTest.php b/tests/unit/class/xoopsform/formcheckboxTest.php new file mode 100644 index 000000000..02b2d9390 --- /dev/null +++ b/tests/unit/class/xoopsform/formcheckboxTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\CheckBox', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formcolorpickerTest.php b/tests/unit/class/xoopsform/formcolorpickerTest.php new file mode 100644 index 000000000..9040e6774 --- /dev/null +++ b/tests/unit/class/xoopsform/formcolorpickerTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\ColorPicker', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formdatetimeTest.php b/tests/unit/class/xoopsform/formdatetimeTest.php new file mode 100644 index 000000000..21a8f8cf4 --- /dev/null +++ b/tests/unit/class/xoopsform/formdatetimeTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\DateTime', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formdhtmltextareaTest.php b/tests/unit/class/xoopsform/formdhtmltextareaTest.php new file mode 100644 index 000000000..fd2cbbe3a --- /dev/null +++ b/tests/unit/class/xoopsform/formdhtmltextareaTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\DhtmlTextArea', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formeditorTest.php b/tests/unit/class/xoopsform/formeditorTest.php new file mode 100644 index 000000000..d2215bac3 --- /dev/null +++ b/tests/unit/class/xoopsform/formeditorTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Editor', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formelementTest.php b/tests/unit/class/xoopsform/formelementTest.php new file mode 100644 index 000000000..04a66c04e --- /dev/null +++ b/tests/unit/class/xoopsform/formelementTest.php @@ -0,0 +1,23 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Element', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formelementtrayTest.php b/tests/unit/class/xoopsform/formelementtrayTest.php new file mode 100644 index 000000000..c415dde2a --- /dev/null +++ b/tests/unit/class/xoopsform/formelementtrayTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\ElementTray', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formfileTest.php b/tests/unit/class/xoopsform/formfileTest.php new file mode 100644 index 000000000..920ed61a9 --- /dev/null +++ b/tests/unit/class/xoopsform/formfileTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\File', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formhiddenTest.php b/tests/unit/class/xoopsform/formhiddenTest.php new file mode 100644 index 000000000..b0be68a00 --- /dev/null +++ b/tests/unit/class/xoopsform/formhiddenTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Hidden', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formhiddentokenTest.php b/tests/unit/class/xoopsform/formhiddentokenTest.php new file mode 100644 index 000000000..7af4fdf1e --- /dev/null +++ b/tests/unit/class/xoopsform/formhiddentokenTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Token', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formlabelTest.php b/tests/unit/class/xoopsform/formlabelTest.php new file mode 100644 index 000000000..3fc674718 --- /dev/null +++ b/tests/unit/class/xoopsform/formlabelTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Label', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formpasswordTest.php b/tests/unit/class/xoopsform/formpasswordTest.php new file mode 100644 index 000000000..1329f9dc7 --- /dev/null +++ b/tests/unit/class/xoopsform/formpasswordTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Password', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formradioTest.php b/tests/unit/class/xoopsform/formradioTest.php new file mode 100644 index 000000000..9d103d42a --- /dev/null +++ b/tests/unit/class/xoopsform/formradioTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Radio', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formradioynTest.php b/tests/unit/class/xoopsform/formradioynTest.php new file mode 100644 index 000000000..660ebda4e --- /dev/null +++ b/tests/unit/class/xoopsform/formradioynTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\RadioYesNo', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectTest.php b/tests/unit/class/xoopsform/formselectTest.php new file mode 100644 index 000000000..436601102 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Select', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectcheckgroupTest.php b/tests/unit/class/xoopsform/formselectcheckgroupTest.php new file mode 100644 index 000000000..84f20c880 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectcheckgroupTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\GroupCheckbox', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectcountryTest.php b/tests/unit/class/xoopsform/formselectcountryTest.php new file mode 100644 index 000000000..21712ca15 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectcountryTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectCountry', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselecteditorTest.php b/tests/unit/class/xoopsform/formselecteditorTest.php new file mode 100644 index 000000000..51eb5ec06 --- /dev/null +++ b/tests/unit/class/xoopsform/formselecteditorTest.php @@ -0,0 +1,20 @@ +myClass($form); + $this->assertInstanceOf('Xoops\\Form\\SelectEditor', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectgroupTest.php b/tests/unit/class/xoopsform/formselectgroupTest.php new file mode 100644 index 000000000..3517d04df --- /dev/null +++ b/tests/unit/class/xoopsform/formselectgroupTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectGroup', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectlangTest.php b/tests/unit/class/xoopsform/formselectlangTest.php new file mode 100644 index 000000000..b0a1fd585 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectlangTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectLanguage', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectmatchoptionTest.php b/tests/unit/class/xoopsform/formselectmatchoptionTest.php new file mode 100644 index 000000000..9da5cd281 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectmatchoptionTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectMatchOption', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectthemeTest.php b/tests/unit/class/xoopsform/formselectthemeTest.php new file mode 100644 index 000000000..61dcc2426 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectthemeTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectTheme', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselecttimezoneTest.php b/tests/unit/class/xoopsform/formselecttimezoneTest.php new file mode 100644 index 000000000..11022f7be --- /dev/null +++ b/tests/unit/class/xoopsform/formselecttimezoneTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectTimezone', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formselectuserTest.php b/tests/unit/class/xoopsform/formselectuserTest.php new file mode 100644 index 000000000..57cfcebb3 --- /dev/null +++ b/tests/unit/class/xoopsform/formselectuserTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SelectUser', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formtextTest.php b/tests/unit/class/xoopsform/formtextTest.php new file mode 100644 index 000000000..b98363812 --- /dev/null +++ b/tests/unit/class/xoopsform/formtextTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\Text', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formtextareaTest.php b/tests/unit/class/xoopsform/formtextareaTest.php new file mode 100644 index 000000000..deae0da76 --- /dev/null +++ b/tests/unit/class/xoopsform/formtextareaTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\TextArea', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/formtextdateselectTest.php b/tests/unit/class/xoopsform/formtextdateselectTest.php new file mode 100644 index 000000000..24fb83753 --- /dev/null +++ b/tests/unit/class/xoopsform/formtextdateselectTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\DateSelect', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/grouppermformTest.php b/tests/unit/class/xoopsform/grouppermformTest.php new file mode 100644 index 000000000..b359fd280 --- /dev/null +++ b/tests/unit/class/xoopsform/grouppermformTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\GroupPermissionForm', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/simpleformTest.php b/tests/unit/class/xoopsform/simpleformTest.php new file mode 100644 index 000000000..86f3dbcc3 --- /dev/null +++ b/tests/unit/class/xoopsform/simpleformTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\SimpleForm', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/tableformTest.php b/tests/unit/class/xoopsform/tableformTest.php new file mode 100644 index 000000000..5a88088a5 --- /dev/null +++ b/tests/unit/class/xoopsform/tableformTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\TableForm', $instance); + } + +} diff --git a/tests/unit/class/xoopsform/themeformTest.php b/tests/unit/class/xoopsform/themeformTest.php new file mode 100644 index 000000000..9e9338959 --- /dev/null +++ b/tests/unit/class/xoopsform/themeformTest.php @@ -0,0 +1,19 @@ +myClass(); + $this->assertInstanceOf('Xoops\\Form\\ThemeForm', $instance); + } + +} diff --git a/tests/unit/verifyTestFiles.php b/tests/unit/verifyTestFiles.php index 6f5051f96..bfffbb86f 100644 --- a/tests/unit/verifyTestFiles.php +++ b/tests/unit/verifyTestFiles.php @@ -1,6 +1,6 @@ object = new DtypeEnumeration(); + } + + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + } + + public function testContracts() + { + $this->assertInstanceOf('\Xoops\Core\Kernel\Dtype\DtypeAbstract', $this->object); + $this->assertInstanceOf('\Xoops\Core\Kernel\Dtype\DtypeEnumeration', $this->object); + } + + /** + * @covers Xoops\Core\Kernel\Dtype\DtypeEnumeration::cleanVar + * @todo Implement testCleanVar(). + */ + public function testCleanVar() + { + // Remove the following lines when you implement this test. + $this->markTestIncomplete( + 'This test has not been implemented yet.' + ); + } +} diff --git a/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGrouppermHandlerTest.php b/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGroupPermHandlerTest.php similarity index 100% rename from tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGrouppermHandlerTest.php rename to tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGroupPermHandlerTest.php diff --git a/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGrouppermTest.php b/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGroupPermTest.php similarity index 91% rename from tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGrouppermTest.php rename to tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGroupPermTest.php index 3e96573f2..c1c0d1c9f 100644 --- a/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGrouppermTest.php +++ b/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsGroupPermTest.php @@ -27,6 +27,12 @@ public function test___construct() $this->assertTrue(isset($value['gperm_modid'])); $this->assertTrue(isset($value['gperm_name'])); } + + public function testContracts() + { + $instance=new $this->myclass(); + $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\XoopsObject', $instance); + } public function test_id() { diff --git a/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsMemberHandlerTest.php b/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsMemberHandlerTest.php new file mode 100644 index 000000000..e458199de --- /dev/null +++ b/tests/unit/xoopsLib/Xoops/Core/Kernel/Handlers/XoopsMemberHandlerTest.php @@ -0,0 +1,64 @@ +conn = Xoops::getInstance()->db(); + } + + public function test_createGroup() + { + $instance=new $this->myclass($this->conn); + $value=$instance->createGroup(); + $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\Handlers\\XoopsGroup', $value); + } + + public function test_createUser() + { + $instance=new $this->myclass($this->conn); + $value=$instance->createUser(); + $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\Handlers\\XoopsUser', $value); + } + + public function test_getGroup() + { + $instance=new $this->myclass($this->conn); + $value=$instance->getGroup(1); + $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\Handlers\\XoopsGroup', $value); + } + + public function test_getUser() + { + $instance=new $this->myclass($this->conn); + $value=$instance->getUser(1); + $this->assertInstanceOf('\\Xoops\\Core\\Kernel\\Handlers\\XoopsUser', $value); + } + + public function test_deleteGroup() + { + $instance=new $this->myclass($this->conn); + $value=$instance->createGroup(); + $ret=$instance->deleteGroup($value); + $this->assertFalse($ret); + } + + public function test_deleteUser() + { + $instance=new $this->myclass($this->conn); + $value=$instance->createUser(); + $ret=$instance->deleteUser($value); + $this->assertFalse($ret); + } +} diff --git a/tests/unit/xoopsLib/Xoops/Core/Kernel/xoopsmodelfactoryTest.php b/tests/unit/xoopsLib/Xoops/Core/Kernel/XoopsModelFactoryTest.php similarity index 70% rename from tests/unit/xoopsLib/Xoops/Core/Kernel/xoopsmodelfactoryTest.php rename to tests/unit/xoopsLib/Xoops/Core/Kernel/XoopsModelFactoryTest.php index 3d296260c..168e6409b 100644 --- a/tests/unit/xoopsLib/Xoops/Core/Kernel/xoopsmodelfactoryTest.php +++ b/tests/unit/xoopsLib/Xoops/Core/Kernel/XoopsModelFactoryTest.php @@ -35,12 +35,12 @@ public function test_loadHandler() $instance = $class::getInstance(); $this->assertInstanceOf($class, $instance); - $x = $instance->loadHandler($handler, 'read', $vars); - $this->assertTrue(is_a($x, 'Xoops\Core\Kernel\Model\Read')); - $this->assertTrue(is_a($x, 'Xoops\Core\Kernel\XoopsModelAbstract')); - $this->assertTrue(!empty($x->one)); - $this->assertTrue($x->one == 1); - $this->assertTrue(!empty($x->two)); - $this->assertTrue($x->two == 2); + $hdl = $instance->loadHandler($handler, 'read', $vars); + $this->assertTrue(is_a($hdl, 'Xoops\Core\Kernel\Model\Read')); + $this->assertTrue(is_a($hdl, 'Xoops\Core\Kernel\XoopsModelAbstract')); + $this->assertTrue(!empty($hdl->one)); + $this->assertTrue($hdl->one == 1); + $this->assertTrue(!empty($hdl->two)); + $this->assertTrue($hdl->two == 2); } } diff --git a/tests/unit/xoopsLib/Xoops/Core/XoopsTplTest.php b/tests/unit/xoopsLib/Xoops/Core/XoopsTplTest.php index f4e68362b..9de2b5c71 100644 --- a/tests/unit/xoopsLib/Xoops/Core/XoopsTplTest.php +++ b/tests/unit/xoopsLib/Xoops/Core/XoopsTplTest.php @@ -15,6 +15,8 @@ class XoopsTplTest extends \PHPUnit_Framework_TestCase */ protected $object; + protected $xoops; + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -22,6 +24,7 @@ class XoopsTplTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->object = new XoopsTpl(); + $this->xoops = \Xoops::getInstance(); } /** @@ -38,16 +41,28 @@ public function testContracts() $this->assertInstanceOf('\Smarty', $this->object); } + public function normalize_path($path) + { + return str_replace('\\','/',$path); + } + public function test__construct() { $xoops = \Xoops::getInstance(); $this->assertSame('{', $this->object->left_delimiter); $this->assertSame('}', $this->object->right_delimiter); - $this->assertTrue(in_array(\XoopsBaseConfig::get('themes-path'). DIRECTORY_SEPARATOR, $this->object->getTemplateDir())); - $this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_cache'. DIRECTORY_SEPARATOR, $this->object->getCacheDir()); - $this->assertSame(\XoopsBaseConfig::get('var-path') . '/caches/smarty_compile' . DIRECTORY_SEPARATOR, $this->object->getCompileDir()); + $this->assertTrue(in_array( + $this->normalize_path(\XoopsBaseConfig::get('themes-path')).'/', + array_map(array($this,'normalize_path'), $this->object->getTemplateDir()))); + $this->assertSame($this->normalize_path(\XoopsBaseConfig::get('var-path')) . '/caches/smarty_cache/', + $this->normalize_path($this->object->getCacheDir())); + $this->assertSame($this->normalize_path(\XoopsBaseConfig::get('var-path')) . '/caches/smarty_compile/', + $this->normalize_path($this->object->getCompileDir())); $this->assertSame($xoops->getConfig('theme_fromfile') == 1, $this->object->compile_check); - $this->assertSame(array(\XoopsBaseConfig::get('lib-path') . '/smarty/xoops_plugins'. DIRECTORY_SEPARATOR, SMARTY_DIR . 'plugins'.DS), $this->object->plugins_dir); + $this->assertSame(array( + $this->normalize_path(\XoopsBaseConfig::get('lib-path')) . '/smarty/xoops_plugins/', + $this->normalize_path(SMARTY_DIR) . 'plugins/'), + array_map(array($this,'normalize_path'), $this->object->plugins_dir)); $this->assertSame(\XoopsBaseConfig::get('url'), $this->object->getTemplateVars('xoops_url')); $this->assertSame(\XoopsBaseConfig::get('root-path'), $this->object->getTemplateVars('xoops_rootpath')); $this->assertSame(\XoopsLocale::getLangCode(), $this->object->getTemplateVars('xoops_langcode')); diff --git a/tests/unit/xoopsLib/Xoops/Locale/AbstractTest.php b/tests/unit/xoopsLib/Xoops/Locale/AbstractLocaleTest.php similarity index 100% rename from tests/unit/xoopsLib/Xoops/Locale/AbstractTest.php rename to tests/unit/xoopsLib/Xoops/Locale/AbstractLocaleTest.php diff --git a/tests/unit/xoopsLib/Xoops/Module/Plugin/ConfigCollectorTest.php b/tests/unit/xoopsLib/Xoops/Module/Plugin/ConfigCollectorTest.php new file mode 100644 index 000000000..aeea3d982 --- /dev/null +++ b/tests/unit/xoopsLib/Xoops/Module/Plugin/ConfigCollectorTest.php @@ -0,0 +1,49 @@ +myclass($module, $configs); + $this->assertInstanceOf($this->myclass, $instance); + } + + public function test_add() + { + $module = new XoopsModule(); + $configs = array(); + + $instance = new $this->myclass($module, $configs); + + $new = array('key1'=>'value1', 'key2'=>'value2', 'key3'=>'value3'); + $instance->add($new); + + $value = $instance->configs; + $this->assertTrue(count($value)==count($new)); + } + + public function test_module() + { + $module = new XoopsModule(); + $configs = array(); + + $instance = new $this->myclass($module, $configs); + $value=$instance->module(); + + $this->assertTrue($value==$module); + } + +}