mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 04:24:14 +09:00
Use a more realistic server environment in unit tests
This commit is contained in:
parent
b088348be2
commit
ca7a7b64ea
9 changed files with 81 additions and 98 deletions
|
|
@ -1,6 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
// This is global bootstrap for autoloading
|
|
||||||
require dirname(__DIR__) . '/common/autoload.php';
|
// Set some superglobal variables for unit tests.
|
||||||
|
$_SERVER['HTTPS'] = 'on';
|
||||||
|
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
||||||
|
$_SERVER['SERVER_NAME'] = 'www.rhymix.org';
|
||||||
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||||
|
$_SERVER['DOCUMENT_ROOT'] = dirname(dirname(__DIR__));
|
||||||
|
$_SERVER['SCRIPT_FILENAME'] = dirname(__DIR__) . '/index.php';
|
||||||
|
$_SERVER['SCRIPT_NAME'] = '/rhymix/index.php';
|
||||||
|
$_SERVER['REQUEST_URI'] = '/rhymix/index.php';
|
||||||
|
|
||||||
|
// Include the autoloader.
|
||||||
|
require_once dirname(__DIR__) . '/common/autoload.php';
|
||||||
|
|
||||||
function _debug() {
|
function _debug() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,2 @@
|
||||||
<?php
|
<?php
|
||||||
// Here you can initialize variables that will be available to your tests
|
// Here you can initialize variables that will be available to your tests
|
||||||
$_SERVER['SCRIPT_NAME'] = '/xe/index.php';
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'classes/context/Context.class.php';
|
|
||||||
require_once _XE_PATH_.'classes/handler/Handler.class.php';
|
|
||||||
require_once _XE_PATH_.'classes/frontendfile/FrontEndFileHandler.class.php';
|
|
||||||
|
|
||||||
class ContextTest extends \Codeception\TestCase\Test
|
class ContextTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'classes/file/FileHandler.class.php';
|
|
||||||
|
|
||||||
class FileHandlerTest extends \Codeception\TestCase\Test
|
class FileHandlerTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'classes/frontendfile/FrontEndFileHandler.class.php';
|
|
||||||
|
|
||||||
class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
|
|
@ -23,8 +22,8 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/common.js', 'body'));
|
$handler->loadFile(array('./common/js/common.js', 'body'));
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head'));
|
$handler->loadFile(array('./common/js/common.js', 'head'));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
||||||
$this->assertEquals($handler->getJsFileList(), $expected);
|
$this->assertEquals($handler->getJsFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -39,8 +38,8 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler = new FrontEndFileHandler();
|
$handler = new FrontEndFileHandler();
|
||||||
$handler->loadFile(array('./common/css/xe.css'));
|
$handler->loadFile(array('./common/css/xe.css'));
|
||||||
$handler->loadFile(array('./common/css/mobile.css'));
|
$handler->loadFile(array('./common/css/mobile.css'));
|
||||||
$expected[] = array('file' => '/xe/common/css/xe.css' . $this->_filemtime('common/css/xe.css'), 'media' => 'all', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/css/xe.css' . $this->_filemtime('common/css/xe.css'), 'media' => 'all', 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/css/mobile.css' . $this->_filemtime('common/css/mobile.css'), 'media' => 'all', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/css/mobile.css' . $this->_filemtime('common/css/mobile.css'), 'media' => 'all', 'targetie' => null);
|
||||||
$this->assertEquals($handler->getCssFileList(), $expected);
|
$this->assertEquals($handler->getCssFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -54,10 +53,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
||||||
$this->assertEquals($handler->getJsFileList(), $expected);
|
$this->assertEquals($handler->getJsFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -67,10 +66,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
||||||
$this->assertEquals($handler->getJsFileList(), $expected);
|
$this->assertEquals($handler->getJsFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -81,9 +80,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$handler->unloadFile('./common/js/js_app.js', '', 'all');
|
$handler->unloadFile('./common/js/js_app.js', '', 'all');
|
||||||
$expected[] = array('file' => '/xe/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
||||||
$this->assertEquals($handler->getJsFileList(), $expected);
|
$this->assertEquals($handler->getJsFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -92,9 +91,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie6'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie6'));
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie7'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie7'));
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie8'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie8'));
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie6');
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie6');
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie7');
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie7');
|
||||||
$expected[] = array('file' => '/xe/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie8');
|
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie8');
|
||||||
$this->assertEquals($handler->getJsFileList(), $expected);
|
$this->assertEquals($handler->getJsFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,9 +126,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
|
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
|
||||||
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
|
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
|
||||||
|
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css', 'media'=>'all', 'targetie' => 'ie6');
|
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => 'ie6');
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css','media'=>'all', 'targetie' => 'ie7');
|
$expected[] = array('file' => '/rhymix/common/css/common.css','media'=>'all', 'targetie' => 'ie7');
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css', 'media'=>'all', 'targetie' => 'ie8');
|
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => 'ie8');
|
||||||
$this->assertEquals($handler->getCssFileList(), $expected);
|
$this->assertEquals($handler->getCssFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -139,9 +138,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/css/common.css', 'screen'));
|
$handler->loadFile(array('./common/css/common.css', 'screen'));
|
||||||
$handler->loadFile(array('./common/css/common.css', 'handled'));
|
$handler->loadFile(array('./common/css/common.css', 'handled'));
|
||||||
|
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css','media'=>'screen', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/css/common.css','media'=>'screen', 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/common/css/common.css', 'media'=>'handled', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'handled', 'targetie' => null);
|
||||||
$this->assertEquals($handler->getCssFileList(), $expected);
|
$this->assertEquals($handler->getCssFileList(), $expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -151,8 +150,8 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler = new FrontEndFileHandler();
|
$handler = new FrontEndFileHandler();
|
||||||
$handler->loadFile(array('./common/css/xe.css'));
|
$handler->loadFile(array('./common/css/xe.css'));
|
||||||
$handler->loadFile(array('./common/css/mobile.css'));
|
$handler->loadFile(array('./common/css/mobile.css'));
|
||||||
$expected[] = array('file' => '/xe/files/cache/minify/common.css.xe.min.css', 'media' => 'all', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/files/cache/minify/common.css.xe.min.css', 'media' => 'all', 'targetie' => null);
|
||||||
$expected[] = array('file' => '/xe/files/cache/minify/common.css.mobile.min.css', 'media' => 'all', 'targetie' => null);
|
$expected[] = array('file' => '/rhymix/files/cache/minify/common.css.mobile.min.css', 'media' => 'all', 'targetie' => null);
|
||||||
$result = $handler->getCssFileList();
|
$result = $handler->getCssFileList();
|
||||||
$result[0]['file'] = preg_replace('/\?\d+$/', '', $result[0]['file']);
|
$result[0]['file'] = preg_replace('/\?\d+$/', '', $result[0]['file']);
|
||||||
$result[1]['file'] = preg_replace('/\?\d+$/', '', $result[1]['file']);
|
$result[1]['file'] = preg_replace('/\?\d+$/', '', $result[1]['file']);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'classes/security/Security.class.php';
|
|
||||||
|
|
||||||
class OldSecurityTest extends \Codeception\TestCase\Test
|
class OldSecurityTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
require_once _XE_PATH_.'classes/file/FileHandler.class.php';
|
|
||||||
require_once _XE_PATH_.'classes/template/TemplateHandler.class.php';
|
|
||||||
$_SERVER['SCRIPT_NAME'] = '/xe/tests/unit/classes/template/index.php';
|
|
||||||
|
|
||||||
class TemplateHandlerTest extends \Codeception\TestCase\Test
|
class TemplateHandlerTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
|
|
@ -148,12 +145,12 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
|
||||||
// relative path1
|
// relative path1
|
||||||
array(
|
array(
|
||||||
'<img src="http://naver.com/naver.gif"><input type="image" src="../local.gif" />',
|
'<img src="http://naver.com/naver.gif"><input type="image" src="../local.gif" />',
|
||||||
'?><img src="http://naver.com/naver.gif"><input type="image" src="/xe/tests/unit/classes/local.gif" />'
|
'?><img src="http://naver.com/naver.gif"><input type="image" src="/rhymix/tests/unit/classes/local.gif" />'
|
||||||
),
|
),
|
||||||
// relative path2
|
// relative path2
|
||||||
array(
|
array(
|
||||||
'<img src="http://naver.com/naver.gif"><input type="image" src="../../../dir/local.gif" />',
|
'<img src="http://naver.com/naver.gif"><input type="image" src="../../../dir/local.gif" />',
|
||||||
'?><img src="http://naver.com/naver.gif"><input type="image" src="/xe/tests/dir/local.gif" />'
|
'?><img src="http://naver.com/naver.gif"><input type="image" src="/rhymix/tests/dir/local.gif" />'
|
||||||
),
|
),
|
||||||
// error case
|
// error case
|
||||||
array(
|
array(
|
||||||
|
|
@ -213,7 +210,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
|
||||||
// issue 584
|
// issue 584
|
||||||
array(
|
array(
|
||||||
'<img cond="$oBodex->display_extra_images[\'mobile\'] && $arr_extra && $arr_extra->bodex->mobile" src="./images/common/mobile.gif" title="mobile" alt="mobile" />',
|
'<img cond="$oBodex->display_extra_images[\'mobile\'] && $arr_extra && $arr_extra->bodex->mobile" src="./images/common/mobile.gif" title="mobile" alt="mobile" />',
|
||||||
PHP_EOL . 'if($__Context->oBodex->display_extra_images[\'mobile\'] && $__Context->arr_extra && $__Context->arr_extra->bodex->mobile){ ?><img src="/xe/tests/unit/classes/template/images/common/mobile.gif" title="mobile" alt="mobile" /><?php } ?>'
|
PHP_EOL . 'if($__Context->oBodex->display_extra_images[\'mobile\'] && $__Context->arr_extra && $__Context->arr_extra->bodex->mobile){ ?><img src="/rhymix/tests/unit/classes/template/images/common/mobile.gif" title="mobile" alt="mobile" /><?php } ?>'
|
||||||
),
|
),
|
||||||
// issue 831
|
// issue 831
|
||||||
array(
|
array(
|
||||||
|
|
@ -222,8 +219,8 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
|
||||||
),
|
),
|
||||||
// issue 746
|
// issue 746
|
||||||
array(
|
array(
|
||||||
'<img src="../myxe/xe/img.png" />',
|
'<img src="../whatever/img.png" />',
|
||||||
'?><img src="/xe/tests/unit/classes/myxe/xe/img.png" />'
|
'?><img src="/rhymix/tests/unit/classes/whatever/img.png" />'
|
||||||
),
|
),
|
||||||
// issue 696
|
// issue 696
|
||||||
array(
|
array(
|
||||||
|
|
@ -233,47 +230,47 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
|
||||||
// https://github.com/xpressengine/xe-core/issues/1510
|
// https://github.com/xpressengine/xe-core/issues/1510
|
||||||
array(
|
array(
|
||||||
'<img cond="$foo->bar" src="../common/mobile.gif" />',
|
'<img cond="$foo->bar" src="../common/mobile.gif" />',
|
||||||
PHP_EOL . 'if($__Context->foo->bar){ ?><img src="/xe/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
PHP_EOL . 'if($__Context->foo->bar){ ?><img src="/rhymix/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
// https://github.com/xpressengine/xe-core/issues/1510
|
// https://github.com/xpressengine/xe-core/issues/1510
|
||||||
array(
|
array(
|
||||||
'<img cond="$foo->bar > 100" alt="a!@#$%^&*()_-=[]{}?/" src="../common/mobile.gif" />',
|
'<img cond="$foo->bar > 100" alt="a!@#$%^&*()_-=[]{}?/" src="../common/mobile.gif" />',
|
||||||
PHP_EOL . 'if($__Context->foo->bar > 100){ ?><img alt="a!@#$%^&*()_-=[]{}?/" src="/xe/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
PHP_EOL . 'if($__Context->foo->bar > 100){ ?><img alt="a!@#$%^&*()_-=[]{}?/" src="/rhymix/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
// https://github.com/xpressengine/xe-core/issues/1510
|
// https://github.com/xpressengine/xe-core/issues/1510
|
||||||
array(
|
array(
|
||||||
'<img src="../common/mobile.gif" cond="$foo->bar" />',
|
'<img src="../common/mobile.gif" cond="$foo->bar" />',
|
||||||
PHP_EOL . 'if($__Context->foo->bar){ ?><img src="/xe/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
PHP_EOL . 'if($__Context->foo->bar){ ?><img src="/rhymix/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
// https://github.com/xpressengine/xe-core/issues/1510
|
// https://github.com/xpressengine/xe-core/issues/1510
|
||||||
array(
|
array(
|
||||||
'<img class="tmp_class" cond="!$module_info->title" src="../img/common/blank.gif" />',
|
'<img class="tmp_class" cond="!$module_info->title" src="../img/common/blank.gif" />',
|
||||||
PHP_EOL . 'if(!$__Context->module_info->title){ ?><img class="tmp_class" src="/xe/tests/unit/classes/img/common/blank.gif" /><?php } ?>'
|
PHP_EOL . 'if(!$__Context->module_info->title){ ?><img class="tmp_class" src="/rhymix/tests/unit/classes/img/common/blank.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
// https://github.com/xpressengine/xe-core/issues/1510
|
// https://github.com/xpressengine/xe-core/issues/1510
|
||||||
array(
|
array(
|
||||||
'<img cond="$mi->title" class="tmp_class"|cond="$mi->use" src="../img/common/blank.gif" />',
|
'<img cond="$mi->title" class="tmp_class"|cond="$mi->use" src="../img/common/blank.gif" />',
|
||||||
PHP_EOL . 'if($__Context->mi->title){ ?><img<?php if($__Context->mi->use){ ?> class="tmp_class"<?php } ?> src="/xe/tests/unit/classes/img/common/blank.gif" /><?php } ?>'
|
PHP_EOL . 'if($__Context->mi->title){ ?><img<?php if($__Context->mi->use){ ?> class="tmp_class"<?php } ?> src="/rhymix/tests/unit/classes/img/common/blank.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<input foo="bar" /> <img cond="$foo->bar" alt="alt" src="../common/mobile.gif" />',
|
'<input foo="bar" /> <img cond="$foo->bar" alt="alt" src="../common/mobile.gif" />',
|
||||||
'?><input foo="bar" /> <?php if($__Context->foo->bar){ ?><img alt="alt" src="/xe/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
'?><input foo="bar" /> <?php if($__Context->foo->bar){ ?><img alt="alt" src="/rhymix/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<input foo="bar" />' . "\n" . '<input foo="bar" /> <img cond="$foo->bar" alt="alt" src="../common/mobile.gif" />',
|
'<input foo="bar" />' . "\n" . '<input foo="bar" /> <img cond="$foo->bar" alt="alt" src="../common/mobile.gif" />',
|
||||||
'?><input foo="bar" />' . PHP_EOL . '<input foo="bar" /> <?php if($__Context->foo->bar){ ?><img alt="alt" src="/xe/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
'?><input foo="bar" />' . PHP_EOL . '<input foo="bar" /> <?php if($__Context->foo->bar){ ?><img alt="alt" src="/rhymix/tests/unit/classes/common/mobile.gif" /><?php } ?>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'asf <img src="{$foo->bar}" />',
|
'asf <img src="{$foo->bar}" />',
|
||||||
'?>asf <img src="<?php echo $__Context->foo->bar ?>" />'
|
'?>asf <img src="<?php echo $__Context->foo->bar ?>" />'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<img alt="" '.PHP_EOL.' src="../myxe/xe/img.png" />',
|
'<img alt="" '.PHP_EOL.' src="../whatever/img.png" />',
|
||||||
'?><img alt="" '.PHP_EOL.' src="/xe/tests/unit/classes/myxe/xe/img.png" />'
|
'?><img alt="" '.PHP_EOL.' src="/rhymix/tests/unit/classes/whatever/img.png" />'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<input>asdf src="../img/img.gif" asdf</input> <img alt="src" src="../myxe/xe/img.png" /> <input>asdf src="../img/img.gif" asdf</input>',
|
'<input>asdf src="../img/img.gif" asdf</input> <img alt="src" src="../whatever/img.png" /> <input>asdf src="../img/img.gif" asdf</input>',
|
||||||
'?><input>asdf src="../img/img.gif" asdf</input> <img alt="src" src="/xe/tests/unit/classes/myxe/xe/img.png" /> <input>asdf src="../img/img.gif" asdf</input>'
|
'?><input>asdf src="../img/img.gif" asdf</input> <img alt="src" src="/rhymix/tests/unit/classes/whatever/img.png" /> <input>asdf src="../img/img.gif" asdf</input>'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'<input>asdf src="../img/img.gif" asdf</input>',
|
'<input>asdf src="../img/img.gif" asdf</input>',
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,9 @@ class SecurityTest extends \Codeception\TestCase\Test
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$this->assertTrue(Rhymix\Framework\Security::checkCSRF());
|
$this->assertTrue(Rhymix\Framework\Security::checkCSRF());
|
||||||
|
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
|
||||||
$_SERVER['HTTP_REFERER'] = 'http://www.foobar.com/';
|
$_SERVER['HTTP_REFERER'] = 'http://www.foobar.com/';
|
||||||
$this->assertFalse(Rhymix\Framework\Security::checkCSRF());
|
$this->assertFalse(Rhymix\Framework\Security::checkCSRF());
|
||||||
|
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
|
||||||
$this->assertTrue(Rhymix\Framework\Security::checkCSRF('http://www.rhymix.org/'));
|
$this->assertTrue(Rhymix\Framework\Security::checkCSRF('http://www.rhymix.org/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,48 +4,42 @@ class URLTest extends \Codeception\TestCase\Test
|
||||||
{
|
{
|
||||||
public function testGetCurrentURL()
|
public function testGetCurrentURL()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
$old_request_uri = $_SERVER['REQUEST_URI'];
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
$_SERVER['REQUEST_URI'] = '/rhymix/index.php?foo=bar&xe=sucks';
|
||||||
$_SERVER['REQUEST_URI'] = '/index.php?foo=bar&xe=sucks';
|
|
||||||
$full_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
|
||||||
|
|
||||||
// Getting the current URL
|
// Getting the current URL
|
||||||
$this->assertEquals($full_url, Rhymix\Framework\URL::getCurrentURL());
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?foo=bar&xe=sucks', Rhymix\Framework\URL::getCurrentURL());
|
||||||
|
|
||||||
// Adding items to the query string
|
// Adding items to the query string
|
||||||
$this->assertEquals($full_url . '&var=1&arr%5B0%5D=2&arr%5B1%5D=3', Rhymix\Framework\URL::getCurrentURL(array('var' => '1', 'arr' => array(2, 3))));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?foo=bar&xe=sucks&var=1&arr%5B0%5D=2&arr%5B1%5D=3', Rhymix\Framework\URL::getCurrentURL(array('var' => '1', 'arr' => array(2, 3))));
|
||||||
|
|
||||||
// Removing item from the query string
|
// Removing item from the query string
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/index.php?xe=sucks', Rhymix\Framework\URL::getCurrentURL(array('foo' => null)));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?xe=sucks', Rhymix\Framework\URL::getCurrentURL(array('foo' => null)));
|
||||||
|
|
||||||
// Removing all items from the query string
|
// Removing all items from the query string
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/index.php', Rhymix\Framework\URL::getCurrentURL(array('foo' => null, 'xe' => null)));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php', Rhymix\Framework\URL::getCurrentURL(array('foo' => null, 'xe' => null)));
|
||||||
|
|
||||||
// Adding and removing parameters at the same time
|
// Adding and removing parameters at the same time
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/index.php?xe=sucks&l=ko', Rhymix\Framework\URL::getCurrentURL(array('l' => 'ko', 'foo' => null)));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?xe=sucks&l=ko', Rhymix\Framework\URL::getCurrentURL(array('l' => 'ko', 'foo' => null)));
|
||||||
|
|
||||||
|
$_SERVER['REQUEST_URI'] = $old_request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCurrentDomainURL()
|
public function testGetCurrentDomainURL()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
$this->assertEquals('https://www.rhymix.org/', Rhymix\Framework\URL::getCurrentDomainURL());
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
$this->assertEquals('https://www.rhymix.org/', Rhymix\Framework\URL::getCurrentDomainURL('/'));
|
||||||
|
$this->assertEquals('https://www.rhymix.org/foo/bar', Rhymix\Framework\URL::getCurrentDomainURL('/foo/bar'));
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/', Rhymix\Framework\URL::getCurrentDomainURL());
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?foo=bar', Rhymix\Framework\URL::getCurrentDomainURL('rhymix/index.php?foo=bar'));
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/', Rhymix\Framework\URL::getCurrentDomainURL('/'));
|
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/foo/bar', Rhymix\Framework\URL::getCurrentDomainURL('/foo/bar'));
|
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/index.php?foo=bar', Rhymix\Framework\URL::getCurrentDomainURL('index.php?foo=bar'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetCanonicalURL()
|
public function testGetCanonicalURL()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
'foo/bar' => $protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'foo/bar',
|
'foo/bar' => 'https://www.rhymix.org/rhymix/foo/bar',
|
||||||
'./foo/bar' => $protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'foo/bar',
|
'./foo/bar' => 'https://www.rhymix.org/rhymix/foo/bar',
|
||||||
'/foo/bar' => $protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'foo/bar',
|
'/foo/bar' => 'https://www.rhymix.org/rhymix/foo/bar',
|
||||||
'//www.example.com/foo' => $protocol . 'www.example.com/foo',
|
'//www.example.com/foo' => 'https://www.example.com/foo',
|
||||||
'http://xn--cg4bkiv2oina.com/' => 'http://삼성전자.com/',
|
'http://xn--cg4bkiv2oina.com/' => 'http://삼성전자.com/',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -71,21 +65,17 @@ class URLTest extends \Codeception\TestCase\Test
|
||||||
|
|
||||||
public function testModifyURL()
|
public function testModifyURL()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
|
||||||
$url = $protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'index.php?foo=bar';
|
|
||||||
|
|
||||||
// Conversion to absolute
|
// Conversion to absolute
|
||||||
$this->assertEquals($url, Rhymix\Framework\URL::modifyURL('./index.php?foo=bar'));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?foo=bar', $url = Rhymix\Framework\URL::modifyURL('./index.php?foo=bar'));
|
||||||
|
|
||||||
// Adding items to the query string
|
// Adding items to the query string
|
||||||
$this->assertEquals($url . '&var=1&arr%5B0%5D=2&arr%5B1%5D=3', Rhymix\Framework\URL::modifyURL($url, array('var' => '1', 'arr' => array(2, 3))));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?foo=bar&var=1&arr%5B0%5D=2&arr%5B1%5D=3', Rhymix\Framework\URL::modifyURL($url, array('var' => '1', 'arr' => array(2, 3))));
|
||||||
|
|
||||||
// Removing item from the query string
|
// Removing item from the query string
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'index.php', Rhymix\Framework\URL::modifyURL($url, array('foo' => null)));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php', Rhymix\Framework\URL::modifyURL($url, array('foo' => null)));
|
||||||
|
|
||||||
// Adding and removing parameters at the same time
|
// Adding and removing parameters at the same time
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'index.php?l=ko', Rhymix\Framework\URL::modifyURL($url, array('l' => 'ko', 'foo' => null)));
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php?l=ko', Rhymix\Framework\URL::modifyURL($url, array('l' => 'ko', 'foo' => null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsInternalURL()
|
public function testIsInternalURL()
|
||||||
|
|
@ -95,23 +85,17 @@ class URLTest extends \Codeception\TestCase\Test
|
||||||
|
|
||||||
public function testURLFromServerPath()
|
public function testURLFromServerPath()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
$this->assertEquals('https://www.rhymix.org/rhymix/', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR));
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
$this->assertEquals('https://www.rhymix.org/rhymix/index.php', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR . 'index.php'));
|
||||||
|
$this->assertEquals('https://www.rhymix.org/rhymix/foo/bar', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR . '/foo/bar'));
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR));
|
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/index.php', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR . 'index.php'));
|
|
||||||
$this->assertEquals($protocol . $_SERVER['HTTP_HOST'] . '/foo/bar', Rhymix\Framework\URL::fromServerPath(\RX_BASEDIR . '/foo/bar'));
|
|
||||||
$this->assertEquals(false, Rhymix\Framework\URL::fromServerPath(dirname(dirname(\RX_BASEDIR))));
|
$this->assertEquals(false, Rhymix\Framework\URL::fromServerPath(dirname(dirname(\RX_BASEDIR))));
|
||||||
$this->assertEquals(false, Rhymix\Framework\URL::fromServerPath('C:/Windows'));
|
$this->assertEquals(false, Rhymix\Framework\URL::fromServerPath('C:/Windows'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testURLToServerPath()
|
public function testURLToServerPath()
|
||||||
{
|
{
|
||||||
$protocol = \RX_SSL ? 'https://' : 'http://';
|
$this->assertEquals(\RX_BASEDIR . 'index.php', Rhymix\Framework\URL::toServerPath('http://www.rhymix.org/rhymix/index.php'));
|
||||||
$_SERVER['HTTP_HOST'] = 'www.rhymix.org';
|
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath('http://www.rhymix.org/rhymix/foo/bar?arg=baz'));
|
||||||
|
|
||||||
$this->assertEquals(\RX_BASEDIR . 'index.php', Rhymix\Framework\URL::toServerPath($protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . 'index.php'));
|
|
||||||
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath($protocol . $_SERVER['HTTP_HOST'] . \RX_BASEURL . '/foo/bar?arg=baz'));
|
|
||||||
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath('./foo/bar'));
|
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath('./foo/bar'));
|
||||||
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath('foo/bar/../bar'));
|
$this->assertEquals(\RX_BASEDIR . 'foo/bar', Rhymix\Framework\URL::toServerPath('foo/bar/../bar'));
|
||||||
$this->assertEquals(false, Rhymix\Framework\URL::toServerPath('http://other.domain.com/'));
|
$this->assertEquals(false, Rhymix\Framework\URL::toServerPath('http://other.domain.com/'));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue