mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Update unit tests for latest codeception
This commit is contained in:
parent
0db02281c9
commit
f46b41f437
12 changed files with 331 additions and 295 deletions
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 ====================
|
||||
|
|
|
|||
|
|
@ -2,23 +2,37 @@
|
|||
|
||||
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';
|
||||
}
|
||||
|
||||
$this->specify("js (head)", function() {
|
||||
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'));
|
||||
|
|
@ -27,26 +41,29 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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());
|
||||
});
|
||||
}
|
||||
|
||||
$this->specify("js (body)", function() {
|
||||
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'));
|
||||
});
|
||||
}
|
||||
|
||||
$this->specify("css and less", function() {
|
||||
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("order (duplicate)", function() {
|
||||
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));
|
||||
|
|
@ -61,9 +78,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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("order (redefine)", function() {
|
||||
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));
|
||||
|
|
@ -74,9 +92,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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());
|
||||
});
|
||||
}
|
||||
|
||||
$this->specify("unload", function() {
|
||||
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));
|
||||
|
|
@ -87,20 +106,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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("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());
|
||||
});
|
||||
|
||||
$this->specify("external file - schemaless", function() {
|
||||
public function testExternalFile1()
|
||||
{
|
||||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('http://external.host/js/script.js'));
|
||||
$handler->loadFile(array('https://external.host/js/script.js'));
|
||||
|
|
@ -112,30 +121,81 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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());
|
||||
});
|
||||
}
|
||||
|
||||
$this->specify("external file - schemaless", function() {
|
||||
public function testExternalFile2()
|
||||
{
|
||||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('//external.host/js/script.js'));
|
||||
$handler->loadFile(array('///external.host/js/script.js'));
|
||||
|
||||
$expected[] = array('file' => '//external.host/js/script.js', 'targetie' => null);
|
||||
$this->assertEquals($expected, $handler->getJsFileList());
|
||||
});
|
||||
}
|
||||
|
||||
$this->specify("target IE (css)", function() {
|
||||
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'));
|
||||
|
||||
$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'));
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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'));
|
||||
|
||||
$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');
|
||||
$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() {
|
||||
public function testMedia()
|
||||
{
|
||||
$handler = new FrontEndFileHandler();
|
||||
$handler->loadFile(array('./common/css/common.css', 'all'));
|
||||
$handler->loadFile(array('./common/css/common.css', 'screen'));
|
||||
|
|
@ -145,32 +205,32 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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']);
|
||||
});
|
||||
|
||||
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'));
|
||||
|
|
@ -187,11 +247,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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'));
|
||||
|
|
@ -206,47 +264,15 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$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';
|
||||
}
|
||||
|
||||
$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'));
|
||||
public function testBlockedScripts()
|
||||
{
|
||||
HTMLDisplayHandler::$reservedCSS = $this->reservedCSS;
|
||||
HTMLDisplayHandler::$reservedJS = $this->reservedJS;
|
||||
|
||||
$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'));
|
||||
|
|
@ -263,6 +289,5 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
|||
$result = $handler->getJsFileList();
|
||||
$this->assertEquals(1, count($result));
|
||||
$this->assertEquals('/rhymix/common/js/xml2json.js' . $this->_filemtime('common/js/xml2json.js'), $result[0]['file']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,15 +6,23 @@ class ValidatorTest extends \Codeception\TestCase\Test
|
|||
{
|
||||
$ob_level = ob_get_level();
|
||||
|
||||
//$oContext = Context::getInstance();
|
||||
//$oContext->init();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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&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&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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue