Update unit tests for latest codeception

This commit is contained in:
Kijin Sung 2021-01-28 21:53:44 +09:00
parent 0db02281c9
commit f46b41f437
12 changed files with 331 additions and 295 deletions

View file

@ -28,16 +28,18 @@ jobs:
- name: PHP Lint
run: if find . -name "*.php" ! -path "./vendor/*" -print0 | xargs -0 -n 1 -P 8 php -l | grep -v "No syntax errors detected"; then exit 1; fi
- name: Download codeception
if: matrix.php != '8.0'
run: wget https://codeception.com/releases/2.3.9/codecept.phar
- name: Download codeception (PHP 7.2 and above)
if: matrix.php >= '7.2'
run: wget https://codeception.com/codecept.phar
- name: Download codeception (PHP 7.1 and below)
if: matrix.php <= '7.1'
run: wget https://codeception.com/php56/codecept.phar
- name: Run PHP development server
if: matrix.php != '8.0'
run: php -S localhost:8000 &
- name: Build and run codeception
if: matrix.php != '8.0'
run: |
php codecept.phar build
php codecept.phar run --debug --fail-fast --env travis

View file

@ -4,8 +4,8 @@ paths:
log: tests/_output
data: tests/_data
helpers: tests/_support
bootstrap: _bootstrap.php
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_NOTICE"

View file

@ -1196,6 +1196,16 @@ class DB
return $this->_total_time;
}
/**
* Enable or disable debug comments.
*
* @param bool $enabled
*/
public function setDebugComment(bool $enabled)
{
$this->_debug_comment = $enabled;
}
/**
* ========================== DEPRECATED METHODS ==========================
* ==================== KEPT FOR COMPATIBILITY WITH XE ====================

View file

@ -2,267 +2,292 @@
class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
{
use \Codeception\Specify;
private $reservedCSS;
private $reservedJS;
private function _filemtime($file)
{
return '?' . date('YmdHis', filemtime(_XE_PATH_ . $file));
}
public function testFrontEndFileHandler()
public function _before()
{
$reservedCSS = HTMLDisplayHandler::$reservedCSS;
$reservedJS = HTMLDisplayHandler::$reservedJS;
$this->reservedCSS = HTMLDisplayHandler::$reservedCSS;
$this->reservedJS = HTMLDisplayHandler::$reservedJS;
HTMLDisplayHandler::$reservedCSS = '/xxx$/';
HTMLDisplayHandler::$reservedJS = '/xxx$/';
FrontEndFileHandler::$minify = 'none';
FrontEndFileHandler::$concat = 'none';
}
public function _after()
{
HTMLDisplayHandler::$reservedCSS = $this->reservedCSS;
HTMLDisplayHandler::$reservedJS = $this->reservedJS;
}
public function _failed()
{
HTMLDisplayHandler::$reservedCSS = $this->reservedCSS;
HTMLDisplayHandler::$reservedJS = $this->reservedJS;
}
public function testJsHead()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.js', 'head'));
$handler->loadFile(array('./common/js/common.js', 'body'));
$handler->loadFile(array('./common/js/common.js', 'head'));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
}
public function testJsBody()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/xml_handler.js', 'body'));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head'));
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList('body'));
}
public function testCssLess()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$result = $handler->getCssFileList(true);
$this->assertRegexp('/\.rhymix\.less\.css\?\d+$/', $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
}
$this->specify("js (head)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.js', 'head'));
$handler->loadFile(array('./common/js/common.js', 'body'));
$handler->loadFile(array('./common/js/common.js', 'head'));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
});
public function testDuplicateOrder()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.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_js_filter.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/xml_handler.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.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($expected, $handler->getJsFileList());
}
public function testRedefineOrder()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', 1));
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.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' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
}
public function testUnload()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.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_js_filter.js', 'head', '', -100000));
$handler->unloadFile('./common/js/js_app.js', '', 'all');
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.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($expected, $handler->getJsFileList());
}
$this->specify("js (body)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/xml_handler.js', 'body'));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head'));
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList('body'));
});
public function testExternalFile1()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('http://external.host/js/script.js'));
$handler->loadFile(array('https://external.host/js/script.js'));
$handler->loadFile(array('//external.host/js/script1.js'));
$handler->loadFile(array('///external.host/js/script2.js'));
$this->specify("css and less", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$result = $handler->getCssFileList(true);
$this->assertRegexp('/\.rhymix\.less\.css\?\d+$/', $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
});
$expected[] = array('file' => 'http://external.host/js/script.js', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/js/script.js', 'targetie' => null);
$expected[] = array('file' => '//external.host/js/script1.js', 'targetie' => null);
$expected[] = array('file' => '//external.host/js/script2.js', 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
}
public function testExternalFile2()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('//external.host/js/script.js'));
$handler->loadFile(array('///external.host/js/script.js'));
$this->specify("order (duplicate)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.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_js_filter.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/xml_handler.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.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($expected, $handler->getJsFileList());
});
$expected[] = array('file' => '//external.host/js/script.js', 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
}
public function testExternalFile3()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('http://external.host/css/style1.css'));
$handler->loadFile(array('https://external.host/css/style2.css'));
$handler->loadFile(array('https://external.host/css/style3.css?foo=bar&t=123'));
$this->specify("order (redefine)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', 1));
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.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' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
});
$expected[] = array('file' => 'http://external.host/css/style1.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/css/style2.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
}
public function testExternalFile4()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('//external.host/css/style.css'));
$handler->loadFile(array('///external.host/css2/style2.css'));
$handler->loadFile(array('//external.host/css/style3.css?foo=bar&t=123'));
$this->specify("unload", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/js_app.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_js_filter.js', 'head', '', -100000));
$handler->unloadFile('./common/js/js_app.js', '', 'all');
$expected[] = array('file' => '/rhymix/common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.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($expected, $handler->getJsFileList());
});
$expected[] = array('file' => '//external.host/css/style.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '//external.host/css2/style2.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '//external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
}
$this->specify("target IE (js)", function() {
$handler = new FrontEndFileHandler();
$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', 'ie8'));
$expected[] = array('file' => '/rhymix/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' => 'ie7');
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie8');
$this->assertEquals($expected, $handler->getJsFileList());
});
public function testPathConversion()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/xeicon/xeicon.min.css'));
$result = $handler->getCssFileList();
$this->assertEquals('/rhymix/common/css/xeicon/xeicon.min.css' . $this->_filemtime('common/css/xeicon/xeicon.min.css'), $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
}
$this->specify("external file - schemaless", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('http://external.host/js/script.js'));
$handler->loadFile(array('https://external.host/js/script.js'));
$handler->loadFile(array('//external.host/js/script1.js'));
$handler->loadFile(array('///external.host/js/script2.js'));
public function testTargetie1()
{
$handler = new FrontEndFileHandler();
$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', 'ie8'));
$expected[] = array('file' => '/rhymix/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' => 'ie7');
$expected[] = array('file' => '/rhymix/common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie8');
$this->assertEquals($expected, $handler->getJsFileList());
}
$expected[] = array('file' => 'http://external.host/js/script.js', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/js/script.js', 'targetie' => null);
$expected[] = array('file' => '//external.host/js/script1.js', 'targetie' => null);
$expected[] = array('file' => '//external.host/js/script2.js', 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
});
public function testTargetie2()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/common.css', null, 'ie6'));
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
$this->specify("external file - schemaless", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('//external.host/js/script.js'));
$handler->loadFile(array('///external.host/js/script.js'));
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media' => 'all', 'targetie' => 'ie6');
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media' => 'all', 'targetie' => 'ie7');
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media' => 'all', 'targetie' => 'ie8');
$this->assertEquals($expected, $handler->getCssFileList());
}
public function testMedia()
{
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/common.css', 'all'));
$handler->loadFile(array('./common/css/common.css', 'screen'));
$handler->loadFile(array('./common/css/common.css', 'handled'));
$expected[] = array('file' => '//external.host/js/script.js', 'targetie' => null);
$this->assertEquals($expected, $handler->getJsFileList());
});
$this->specify("target IE (css)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/common.css', null, 'ie6'));
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => 'ie6');
$expected[] = array('file' => '/rhymix/common/css/common.css','media'=>'all', 'targetie' => 'ie7');
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => 'ie8');
$this->assertEquals($expected, $handler->getCssFileList());
});
$this->specify("media", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/common.css', 'all'));
$handler->loadFile(array('./common/css/common.css', 'screen'));
$handler->loadFile(array('./common/css/common.css', 'handled'));
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/css/common.css','media'=>'screen', 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'handled', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
});
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/css/common.css','media'=>'screen', 'targetie' => null);
$expected[] = array('file' => '/rhymix/common/css/common.css', 'media'=>'handled', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
}
public function testMinify()
{
FrontEndFileHandler::$minify = 'all';
$this->specify("minify (css)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$result = $handler->getCssFileList(true);
$this->assertRegexp('/\.rhymix\.less\.min\.css\b/', $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
});
$this->specify("minify (js)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/common.js', 'head'));
$result = $handler->getJsFileList('head', true);
$this->assertRegexp('/minified\/common\.js\.common\.min\.js\?\d+$/', $result[0]['file']);
$this->assertEmpty($result[0]['targetie']);
});
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$result = $handler->getCssFileList(true);
$this->assertRegexp('/\.rhymix\.less\.min\.css\b/', $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/common.js', 'head'));
$result = $handler->getJsFileList('head', true);
$this->assertRegexp('/minified\/common\.js\.common\.min\.js\?\d+$/', $result[0]['file']);
$this->assertEmpty($result[0]['targetie']);
FrontEndFileHandler::$minify = 'none';
}
public function testConcat()
{
FrontEndFileHandler::$concat = 'css';
$this->specify("concat (css)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$handler->loadFile(array('./common/css/bootstrap-responsive.css'));
$handler->loadFile(array('http://external.host/style.css'));
$handler->loadFile(array('./common/css/bootstrap.css', null, 'IE'));
$handler->loadFile(array('./tests/_data/formatter/concat.source1.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.source2.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.target1.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.target2.css'));
$result = $handler->getCssFileList(true);
$this->assertEquals(4, count($result));
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[0]['file']);
$this->assertEquals('/rhymix/common/css/bootstrap.css' . $this->_filemtime('common/css/bootstrap.css'), $result[1]['file']);
$this->assertEquals('IE', $result[1]['targetie']);
$this->assertEquals('http://external.host/style.css', $result[2]['file']);
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[3]['file']);
});
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/rhymix.less'));
$handler->loadFile(array('./common/css/bootstrap-responsive.css'));
$handler->loadFile(array('http://external.host/style.css'));
$handler->loadFile(array('./common/css/bootstrap.css', null, 'IE'));
$handler->loadFile(array('./tests/_data/formatter/concat.source1.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.source2.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.target1.css'));
$handler->loadFile(array('./tests/_data/formatter/concat.target2.css'));
$result = $handler->getCssFileList(true);
$this->assertEquals(4, count($result));
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[0]['file']);
$this->assertEquals('/rhymix/common/css/bootstrap.css' . $this->_filemtime('common/css/bootstrap.css'), $result[1]['file']);
$this->assertEquals('IE', $result[1]['targetie']);
$this->assertEquals('http://external.host/style.css', $result[2]['file']);
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[3]['file']);
FrontEndFileHandler::$concat = 'js';
$this->specify("concat (js)", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/common.js', 'head'));
$handler->loadFile(array('./common/js/debug.js', 'head'));
$handler->loadFile(array('./common/js/html5.js', 'head'));
$handler->loadFile(array('///external.host/js/script.js'));
$handler->loadFile(array('./tests/_data/formatter/concat.source1.js', 'head', 'lt IE 8'));
$handler->loadFile(array('./tests/_data/formatter/concat.source2.js', 'head', 'gt IE 7'));
$handler->loadFile(array('./tests/_data/formatter/concat.target1.js'));
$handler->loadFile(array('./tests/_data/formatter/concat.target2.js'));
$result = $handler->getJsFileList('head', true);
$this->assertEquals(3, count($result));
$this->assertRegexp('/combined\/[0-9a-f]+\.js\?\d+$/', $result[0]['file']);
$this->assertEquals('//external.host/js/script.js', $result[1]['file']);
$this->assertRegexp('/combined\/[0-9a-f]+\.js\?\d+$/', $result[2]['file']);
});
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/js/common.js', 'head'));
$handler->loadFile(array('./common/js/debug.js', 'head'));
$handler->loadFile(array('./common/js/html5.js', 'head'));
$handler->loadFile(array('///external.host/js/script.js'));
$handler->loadFile(array('./tests/_data/formatter/concat.source1.js', 'head', 'lt IE 8'));
$handler->loadFile(array('./tests/_data/formatter/concat.source2.js', 'head', 'gt IE 7'));
$handler->loadFile(array('./tests/_data/formatter/concat.target1.js'));
$handler->loadFile(array('./tests/_data/formatter/concat.target2.js'));
$result = $handler->getJsFileList('head', true);
$this->assertEquals(3, count($result));
$this->assertRegexp('/combined\/[0-9a-f]+\.js\?\d+$/', $result[0]['file']);
$this->assertEquals('//external.host/js/script.js', $result[1]['file']);
$this->assertRegexp('/combined\/[0-9a-f]+\.js\?\d+$/', $result[2]['file']);
FrontEndFileHandler::$concat = 'none';
}
public function testBlockedScripts()
{
HTMLDisplayHandler::$reservedCSS = $this->reservedCSS;
HTMLDisplayHandler::$reservedJS = $this->reservedJS;
$this->specify("external file", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('http://external.host/css/style1.css'));
$handler->loadFile(array('https://external.host/css/style2.css'));
$handler->loadFile(array('https://external.host/css/style3.css?foo=bar&t=123'));
$expected[] = array('file' => 'http://external.host/css/style1.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/css/style2.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => 'https://external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
});
$this->specify("external file - schemaless", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('//external.host/css/style.css'));
$handler->loadFile(array('///external.host/css2/style2.css'));
$handler->loadFile(array('//external.host/css/style3.css?foo=bar&t=123'));
$expected[] = array('file' => '//external.host/css/style.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '//external.host/css2/style2.css', 'media'=>'all', 'targetie' => null);
$expected[] = array('file' => '//external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
$this->assertEquals($expected, $handler->getCssFileList());
});
$this->specify("path conversion", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/xeicon/xeicon.min.css'));
$result = $handler->getCssFileList();
$this->assertEquals('/rhymix/common/css/xeicon/xeicon.min.css' . $this->_filemtime('common/css/xeicon/xeicon.min.css'), $result[0]['file']);
$this->assertEquals('all', $result[0]['media']);
$this->assertEmpty($result[0]['targetie']);
});
HTMLDisplayHandler::$reservedCSS = $reservedCSS;
HTMLDisplayHandler::$reservedJS = $reservedJS;
$this->specify("blocked scripts", function() {
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/xe.min.css'));
$handler->loadFile(array('./common/js/common.js'));
$handler->loadFile(array('./common/js/xe.js'));
$handler->loadFile(array('./common/js/xe.min.js'));
$handler->loadFile(array('./common/js/xml2json.js'));
$handler->loadFile(array('./common/js/jquery.js'));
$handler->loadFile(array('./common/js/jquery-1.x.min.js'));
$handler->loadFile(array('./common/js/jquery-2.0.0.js'));
$handler->loadFile(array('./common/js/jQuery.min.js'));
$handler->loadFile(array('http://code.jquery.com/jquery-latest.js'));
$result = $handler->getCssFileList();
$this->assertEquals(0, count($result));
$result = $handler->getJsFileList();
$this->assertEquals(1, count($result));
$this->assertEquals('/rhymix/common/js/xml2json.js' . $this->_filemtime('common/js/xml2json.js'), $result[0]['file']);
});
$handler = new FrontEndFileHandler();
$handler->loadFile(array('./common/css/xe.min.css'));
$handler->loadFile(array('./common/js/common.js'));
$handler->loadFile(array('./common/js/xe.js'));
$handler->loadFile(array('./common/js/xe.min.js'));
$handler->loadFile(array('./common/js/xml2json.js'));
$handler->loadFile(array('./common/js/jquery.js'));
$handler->loadFile(array('./common/js/jquery-1.x.min.js'));
$handler->loadFile(array('./common/js/jquery-2.0.0.js'));
$handler->loadFile(array('./common/js/jQuery.min.js'));
$handler->loadFile(array('http://code.jquery.com/jquery-latest.js'));
$result = $handler->getCssFileList();
$this->assertEquals(0, count($result));
$result = $handler->getJsFileList();
$this->assertEquals(1, count($result));
$this->assertEquals('/rhymix/common/js/xml2json.js' . $this->_filemtime('common/js/xml2json.js'), $result[0]['file']);
}
}

View file

@ -4,17 +4,25 @@ class ValidatorTest extends \Codeception\TestCase\Test
{
public function _before()
{
$ob_level = ob_get_level();
//$oContext = Context::getInstance();
//$oContext->init();
$ob_level = ob_get_level();
Context::init();
while (ob_get_level() > $ob_level)
{
ob_end_clean();
}
}
public function _after()
{
Rhymix\Framework\Storage::deleteDirectory(__DIR__ . '/validator/ruleset', true);
}
public function _failed()
{
Rhymix\Framework\Storage::deleteDirectory(__DIR__ . '/validator/ruleset', true);
}
public function testRequired()
{
$vd = new Validator();
@ -187,20 +195,5 @@ class ValidatorTest extends \Codeception\TestCase\Test
$js = $vd->getJsPath();
$this->assertEquals(trim(file_get_contents(__DIR__ . '/validator/condition.en.js')), trim(file_get_contents($js)));
}
protected function tearDown()
{
// remove cache directory
$cache_dir = __DIR__ . '/validator/ruleset';
if(is_dir($cache_dir))
{
$files = (array)glob($cache_dir.'/*');
foreach($files as $file)
{
unlink($file);
}
rmdir($cache_dir);
}
}
}

View file

@ -2,6 +2,12 @@
class DBTest extends \Codeception\TestCase\Test
{
public function _before()
{
$oDB = Rhymix\Framework\DB::getInstance();
$oDB->setDebugComment(false);
}
public function testGetInstance()
{
$oDB = Rhymix\Framework\DB::getInstance();

View file

@ -41,7 +41,7 @@ class DebugTest extends \Codeception\TestCase\Test
$errors = Rhymix\Framework\Debug::getErrors();
$this->assertGreaterThanOrEqual(1, count($errors));
$error = array_pop($errors);
$this->assertContains('Rhymix', $error->message);
$this->assertStringContainsString('Rhymix', $error->message);
$this->assertEquals($file, $error->file);
$this->assertEquals($line, $error->line);
Rhymix\Framework\Debug::clearErrors();

View file

@ -13,36 +13,36 @@ class PaginationTest extends \Codeception\TestCase\Test
public function testCreateLinks()
{
$links = Rhymix\Framework\Pagination::createLinks('index.php?page=', 27, 3);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<a href="index.php?page=3">', $links);
$this->assertContains('<span class="page_number">1</span>', $links);
$this->assertContains('<span class="page_number">10</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<a href="index.php?page=3">', $links);
$this->assertStringContainsString('<span class="page_number">1</span>', $links);
$this->assertStringContainsString('<span class="page_number">10</span>', $links);
$links = Rhymix\Framework\Pagination::createLinks('/foo/bar/page/', 27, 13);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<a href="/foo/bar/page/13">', $links);
$this->assertContains('<span class="page_number">11</span>', $links);
$this->assertContains('<span class="page_number">20</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<a href="/foo/bar/page/13">', $links);
$this->assertStringContainsString('<span class="page_number">11</span>', $links);
$this->assertStringContainsString('<span class="page_number">20</span>', $links);
$links = Rhymix\Framework\Pagination::createLinks('/rhymix?page=$PAGE&foo=bar', 27, 25);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<a href="/rhymix?page=27&amp;foo=bar">', $links);
$this->assertContains('<span class="page_number">21</span>', $links);
$this->assertContains('<span class="page_number">27</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<a href="/rhymix?page=27&amp;foo=bar">', $links);
$this->assertStringContainsString('<span class="page_number">21</span>', $links);
$this->assertStringContainsString('<span class="page_number">27</span>', $links);
$links = Rhymix\Framework\Pagination::createLinks('p', 27, 3, 10, Rhymix\Framework\Pagination::COUNT_STYLE_CONTINUOUS);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<span class="page_number">1</span>', $links);
$this->assertContains('<span class="page_number">10</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<span class="page_number">1</span>', $links);
$this->assertStringContainsString('<span class="page_number">10</span>', $links);
$links = Rhymix\Framework\Pagination::createLinks('p', 27, 13, 10, Rhymix\Framework\Pagination::COUNT_STYLE_CONTINUOUS);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<span class="page_number">9</span>', $links);
$this->assertContains('<span class="page_number">18</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<span class="page_number">9</span>', $links);
$this->assertStringContainsString('<span class="page_number">18</span>', $links);
$links = Rhymix\Framework\Pagination::createLinks('p', 27, 25, 10, Rhymix\Framework\Pagination::COUNT_STYLE_CONTINUOUS);
$this->assertContains('<div class="pagination">', $links);
$this->assertContains('<span class="page_number">18</span>', $links);
$this->assertContains('<span class="page_number">27</span>', $links);
$this->assertStringContainsString('<div class="pagination">', $links);
$this->assertStringContainsString('<span class="page_number">18</span>', $links);
$this->assertStringContainsString('<span class="page_number">27</span>', $links);
}
}

View file

@ -171,14 +171,14 @@ class StorageTest extends \Codeception\TestCase\Test
$this->assertTrue(Rhymix\Framework\Storage::write($testfile . '1', ''));
$this->assertTrue(file_exists($testfile . '1'));
$this->assertEquals(0, filesize($testfile . '1'));
$this->assertEmpty(0, glob($testfile . '1.tmp.*'));
$this->assertEmpty(glob($testfile . '1.tmp.*'));
// Empty stream copy test
$stream = fopen('php://temp', 'r');
$this->assertTrue(Rhymix\Framework\Storage::write($testfile . '2', $stream));
$this->assertTrue(file_exists($testfile . '2'));
$this->assertEquals(0, filesize($testfile . '2'));
$this->assertEmpty(0, glob($testfile . '2.tmp.*'));
$this->assertEmpty(glob($testfile . '2.tmp.*'));
fclose($stream);
// Umask test

View file

@ -45,19 +45,19 @@ class DBTableParserTest extends \Codeception\TestCase\Test
{
$table = Rhymix\Framework\Parsers\DBTableParser::loadXML(\RX_BASEDIR . 'tests/_data/dbtable/example.xml');
$sql = $table->getCreateQuery('rx_');
$this->assertContains('CREATE TABLE `rx_example` (', $sql);
$this->assertContains('`comment_srl` BIGINT NOT NULL,', $sql);
$this->assertContains('`status` VARCHAR(20) DEFAULT \'PUBLIC\',', $sql);
$this->assertContains('PRIMARY KEY (`example_srl`),', $sql);
$this->assertContains('INDEX `idx_document_srl` (`document_srl`),', $sql);
$this->assertContains('INDEX `idx_module_document_srl` (`module_srl`, `document_srl`),', $sql);
$this->assertContains('INDEX `idx_status` (`status`(6)),', $sql);
$this->assertContains('UNIQUE INDEX `unique_list_order` (`list_order`),', $sql);
$this->assertContains('SPATIAL INDEX `spatial_geometry` (`geometry`),', $sql);
$this->assertContains('FULLTEXT INDEX `fulltext_description` (`description`) WITH PARSER ngram,', $sql);
$this->assertContains('FOREIGN KEY (`module_srl`) REFERENCES `rx_module` (`module_srl`) ON DELETE CASCADE ON UPDATE RESTRICT', $sql);
$this->assertContains('CHECK (list_order < 0)', $sql);
$this->assertContains('CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci', $sql);
$this->assertContains('ENGINE = InnoDB', $sql);
$this->assertStringContainsString('CREATE TABLE `rx_example` (', $sql);
$this->assertStringContainsString('`comment_srl` BIGINT NOT NULL,', $sql);
$this->assertStringContainsString('`status` VARCHAR(20) DEFAULT \'PUBLIC\',', $sql);
$this->assertStringContainsString('PRIMARY KEY (`example_srl`),', $sql);
$this->assertStringContainsString('INDEX `idx_document_srl` (`document_srl`),', $sql);
$this->assertStringContainsString('INDEX `idx_module_document_srl` (`module_srl`, `document_srl`),', $sql);
$this->assertStringContainsString('INDEX `idx_status` (`status`(6)),', $sql);
$this->assertStringContainsString('UNIQUE INDEX `unique_list_order` (`list_order`),', $sql);
$this->assertStringContainsString('SPATIAL INDEX `spatial_geometry` (`geometry`),', $sql);
$this->assertStringContainsString('FULLTEXT INDEX `fulltext_description` (`description`) WITH PARSER ngram,', $sql);
$this->assertStringContainsString('FOREIGN KEY (`module_srl`) REFERENCES `rx_module` (`module_srl`) ON DELETE CASCADE ON UPDATE RESTRICT', $sql);
$this->assertStringContainsString('CHECK (list_order < 0)', $sql);
$this->assertStringContainsString('CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci', $sql);
$this->assertStringContainsString('ENGINE = InnoDB', $sql);
}
}

View file

@ -45,12 +45,12 @@ class ModuleActionParserTest extends \Codeception\TestCase\Test
// Grant
$this->assertEquals(['view'], array_keys(get_object_vars($info->grant)));
$this->assertEquals('View', $info->grant->view->title);
$this->assertContains($info->grant->view->title, ['View', '열람']);
$this->assertEquals('guest', $info->grant->view->default);
// Menu
$this->assertEquals(['test'], array_keys(get_object_vars($info->menu)));
$this->assertEquals('Test Menu', $info->menu->test->title);
$this->assertContains($info->menu->test->title, ['Test Menu', '테스트 메뉴']);
$this->assertEquals('dispTestAdminIndex', $info->menu->test->index);
$this->assertEquals(['dispTestAdminIndex'], $info->menu->test->acts);
$this->assertEquals('all', $info->menu->test->type);

View file

@ -95,7 +95,7 @@ class LegacyTest extends \Codeception\TestCase\Test
public function testGetEncodedEmailAddress()
{
$this->assertNotEquals('devops@rhymix.org', getEncodeEmailAddress('devops@rhymix.org'));
$this->assertContains('&#X', getEncodeEmailAddress('devops@rhymix.org'));
$this->assertStringContainsString('&#X', getEncodeEmailAddress('devops@rhymix.org'));
}
public function testGetMicrotime()