From 3b77781d156e85ea5faec66384d4c53fe3086af0 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Mon, 30 Jan 2023 21:48:09 +0900 Subject: [PATCH] Remove trailing whitespace in all unit tests --- tests/unit/_bootstrap.php | 2 +- tests/unit/classes/ContextTest.php | 26 +-- .../unit/classes/FrontEndFileHandlerTest.php | 42 ++--- tests/unit/classes/OldSecurityTest.php | 2 +- tests/unit/classes/TemplateHandlerTest.php | 2 +- tests/unit/classes/ValidatorTest.php | 4 +- tests/unit/framework/CacheTest.php | 68 ++++---- tests/unit/framework/CalendarTest.php | 4 +- tests/unit/framework/ConfigTest.php | 6 +- tests/unit/framework/DBTest.php | 48 +++--- tests/unit/framework/DateTimeTest.php | 92 +++++------ tests/unit/framework/DebugTest.php | 12 +- tests/unit/framework/FormatterTest.php | 68 ++++---- tests/unit/framework/KoreaTest.php | 22 +-- tests/unit/framework/LangTest.php | 22 +-- tests/unit/framework/MIMETest.php | 4 +- tests/unit/framework/MailTest.php | 76 ++++----- tests/unit/framework/PaginationTest.php | 12 +- tests/unit/framework/PasswordTest.php | 48 +++--- tests/unit/framework/RouterTest.php | 38 ++--- tests/unit/framework/SMSTest.php | 122 +++++++------- tests/unit/framework/SecurityTest.php | 56 +++---- tests/unit/framework/SessionTest.php | 134 +++++++-------- tests/unit/framework/StorageTest.php | 114 ++++++------- tests/unit/framework/TimerTest.php | 20 +-- tests/unit/framework/UATest.php | 106 ++++++------ tests/unit/framework/URLTest.php | 44 ++--- .../framework/filters/FilenameFilterTest.php | 34 ++-- .../unit/framework/filters/HTMLFilterTest.php | 76 ++++----- tests/unit/framework/filters/IpFilterTest.php | 18 +- .../framework/filters/MediaFilterTest.php | 14 +- .../framework/helpers/ConfigHelperTest.php | 2 +- tests/unit/framework/i18nTest.php | 18 +- .../framework/parsers/DBQueryParserTest.php | 154 +++++++++--------- .../framework/parsers/DBTableParserTest.php | 6 +- .../unit/framework/parsers/LangParserTest.php | 14 +- .../parsers/ModuleActionParserTest.php | 12 +- .../parsers/ModuleInfoParserTest.php | 6 +- tests/unit/functions/FunctionsTest.php | 70 ++++---- tests/unit/functions/LegacyTest.php | 62 +++---- 40 files changed, 840 insertions(+), 840 deletions(-) diff --git a/tests/unit/_bootstrap.php b/tests/unit/_bootstrap.php index 94bf66cf4..8a8855580 100644 --- a/tests/unit/_bootstrap.php +++ b/tests/unit/_bootstrap.php @@ -1,2 +1,2 @@ assertEquals(Context::getBodyClass(), ' class="red green blue"'); Context::addBodyClass('yellow'); $this->assertEquals(Context::getBodyClassList(), ['red', 'green', 'blue', 'yellow']); - + // remove class manually Context::removeBodyClass('yellow'); $this->assertEquals(Context::getBodyClassList(), ['red', 'green', 'blue']); - + // remove duplicated class Context::addBodyClass('red'); $this->assertEquals(Context::getBodyClass(), ' class="red green blue"'); @@ -84,7 +84,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestArguments(); $this->assertEquals('GET', Context::getRequestMethod()); $this->assertEquals('bar', Context::getRequestVars()->foo); - + $_SERVER['REQUEST_METHOD'] = 'GET'; $_GET = array('foo' => 'barrr', 'xe_js_callback' => 'callback12345'); $_POST = array(); @@ -95,7 +95,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestArguments(); $this->assertEquals('JS_CALLBACK', Context::getRequestMethod()); $this->assertEquals('barrr', Context::getRequestVars()->foo); - + $_SERVER['REQUEST_METHOD'] = 'POST'; $_GET = $_REQUEST = array('foo' => 'bazz'); // Request method is POST but actual values are given as GET $_POST = array(); @@ -106,7 +106,7 @@ class ContextTest extends \Codeception\TestCase\Test $this->assertEquals('POST', Context::getRequestMethod()); $this->assertNull(Context::getRequestVars()->foo ?? null); $this->assertNull(Context::get('foo')); // This is different from XE behavior - + $_SERVER['REQUEST_METHOD'] = 'POST'; $_GET = array(); $_POST = $_REQUEST = array('foo' => 'rhymixtest'); @@ -116,7 +116,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestArguments(); $this->assertEquals('POST', Context::getRequestMethod()); $this->assertEquals('rhymixtest', Context::getRequestVars()->foo); - + $_SERVER['REQUEST_METHOD'] = 'POST'; $_GET = $_POST = $_REQUEST = array(); $GLOBALS['HTTP_RAW_POST_DATA'] = 'TestRhymix'; @@ -126,7 +126,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestArguments(); $this->assertEquals('XMLRPC', Context::getRequestMethod()); $this->assertEquals('TestRhymix', Context::getRequestVars()->foo); - + $_SERVER['REQUEST_METHOD'] = 'POST'; $_GET = $_POST = $_REQUEST = array(); $GLOBALS['HTTP_RAW_POST_DATA'] = 'foo=JSON_TEST'; // Not actual JSON @@ -137,7 +137,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestArguments(); $this->assertEquals('JSON', Context::getRequestMethod()); $this->assertEquals('JSON_TEST', Context::getRequestVars()->foo); - + Context::setRequestMethod('POST'); $_GET = $_POST = $_REQUEST = array(); unset($GLOBALS['HTTP_RAW_POST_DATA']); @@ -147,7 +147,7 @@ class ContextTest extends \Codeception\TestCase\Test Context::setRequestMethod(); Context::setRequestArguments(); $this->assertEquals('POST', Context::getRequestMethod()); - + Context::setRequestMethod('POST'); $_GET = array(); $_POST = $_REQUEST = array('foo' => 'legacy', '_rx_ajax_compat' => 'XMLRPC'); @@ -160,20 +160,20 @@ class ContextTest extends \Codeception\TestCase\Test $this->assertEquals('XMLRPC', Context::getRequestMethod()); $this->assertEquals('legacy', Context::getRequestVars()->foo); } - + public function testSetResponseMethod() { $this->assertEquals(Context::getResponseMethod(), 'HTML'); - + Context::setRequestMethod('JSON'); $this->assertEquals(Context::getResponseMethod(), 'JSON'); Context::setResponseMethod('WRONG_TYPE'); $this->assertEquals(Context::getResponseMethod(), 'HTML'); - + Context::setResponseMethod('XMLRPC'); $this->assertEquals(Context::getResponseMethod(), 'XMLRPC'); - + Context::setResponseMethod('HTML'); $this->assertEquals(Context::getResponseMethod(), 'HTML'); } diff --git a/tests/unit/classes/FrontEndFileHandlerTest.php b/tests/unit/classes/FrontEndFileHandlerTest.php index 05a5a9d0a..5005e417d 100644 --- a/tests/unit/classes/FrontEndFileHandlerTest.php +++ b/tests/unit/classes/FrontEndFileHandlerTest.php @@ -20,19 +20,19 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test 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(); @@ -44,7 +44,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js')); $this->assertEquals($expected, $handler->getJsFileList()); } - + public function testJsBody() { $handler = new FrontEndFileHandler(); @@ -53,7 +53,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js')); $this->assertEquals($expected, $handler->getJsFileList('body')); } - + public function testDefaultScss() { $handler = new FrontEndFileHandler(); @@ -81,7 +81,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js')); $this->assertEquals($expected, $handler->getJsFileList()); } - + public function testRedefineOrder() { $handler = new FrontEndFileHandler(); @@ -95,7 +95,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js')); $this->assertEquals($expected, $handler->getJsFileList()); } - + public function testUnload() { $handler = new FrontEndFileHandler(); @@ -124,7 +124,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => '//external.host/js/script2.js'); $this->assertEquals($expected, $handler->getJsFileList()); } - + public function testExternalFile2() { $handler = new FrontEndFileHandler(); @@ -134,7 +134,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => '//external.host/js/script.js'); $this->assertEquals($expected, $handler->getJsFileList()); } - + public function testExternalFile3() { $handler = new FrontEndFileHandler(); @@ -147,7 +147,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => 'https://external.host/css/style3.css?foo=bar&t=123', 'media'=>'all'); $this->assertEquals($expected, $handler->getCssFileList()); } - + public function testExternalFile4() { $handler = new FrontEndFileHandler(); @@ -196,7 +196,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test $expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media' => 'all'); $this->assertEquals($expected, $handler->getCssFileList()); } - + public function testMedia() { $handler = new FrontEndFileHandler(); @@ -213,27 +213,27 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test public function testMinify() { FrontEndFileHandler::$minify = 'all'; - + $handler = new FrontEndFileHandler(); $handler->loadFile(array('./common/css/rhymix.scss')); $result = $handler->getCssFileList(true); $this->assertRegexp('/\.rhymix\.scss\.min\.css\b/', $result[0]['file']); $this->assertEquals('all', $result[0]['media']); $this->assertTrue(empty($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->assertTrue(empty($result[0]['targetie'])); - + FrontEndFileHandler::$minify = 'none'; } - + public function testConcat() { FrontEndFileHandler::$concat = 'css'; - + $handler = new FrontEndFileHandler(); $handler->loadFile(array('./common/css/rhymix.scss')); $handler->loadFile(array('./common/css/bootstrap-responsive.css')); @@ -250,9 +250,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test //$this->assertEquals('IE', $result[1]['targetie']); $this->assertEquals('http://external.host/style.css', $result[1]['file']); $this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[2]['file']); - + FrontEndFileHandler::$concat = 'js'; - + $handler = new FrontEndFileHandler(); $handler->loadFile(array('./common/js/common.js', 'head')); $handler->loadFile(array('./common/js/debug.js', 'head')); @@ -267,15 +267,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'; } - + public function testBlockedScripts() { HTMLDisplayHandler::$reservedCSS = $this->reservedCSS; HTMLDisplayHandler::$reservedJS = $this->reservedJS; - + $handler = new FrontEndFileHandler(); $handler->loadFile(array('./common/css/xe.min.css')); $handler->loadFile(array('./common/js/common.js')); diff --git a/tests/unit/classes/OldSecurityTest.php b/tests/unit/classes/OldSecurityTest.php index 51816c998..9ab8a9f6b 100644 --- a/tests/unit/classes/OldSecurityTest.php +++ b/tests/unit/classes/OldSecurityTest.php @@ -6,7 +6,7 @@ class OldSecurityTest extends \Codeception\TestCase\Test { $this->_reset(); } - + protected function _reset() { /** diff --git a/tests/unit/classes/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php index f5006943d..2bff4a567 100644 --- a/tests/unit/classes/TemplateHandlerTest.php +++ b/tests/unit/classes/TemplateHandlerTest.php @@ -9,7 +9,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test { $this->baseurl = '/' . basename(dirname(dirname(dirname(__DIR__)))) . '/'; } - + public function testParse() { $tests = array( diff --git a/tests/unit/classes/ValidatorTest.php b/tests/unit/classes/ValidatorTest.php index 35fa35cbf..e9b6aaf50 100644 --- a/tests/unit/classes/ValidatorTest.php +++ b/tests/unit/classes/ValidatorTest.php @@ -15,12 +15,12 @@ class ValidatorTest extends \Codeception\TestCase\Test { 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(); diff --git a/tests/unit/framework/CacheTest.php b/tests/unit/framework/CacheTest.php index 690ab3631..7a5120e96 100644 --- a/tests/unit/framework/CacheTest.php +++ b/tests/unit/framework/CacheTest.php @@ -8,27 +8,27 @@ class CacheTest extends \Codeception\TestCase\Test { Rhymix\Framework\Config::set('crypto.authentication_key', Rhymix\Framework\Security::getRandom(64, 'alnum')); } - + $driver = Rhymix\Framework\Cache::init(array('dummy')); } - + public function _after() { $driver = Rhymix\Framework\Cache::clearAll(); } - + public function testInit() { $driver = Rhymix\Framework\Cache::init(array('type' => 'dummy')); $this->assertTrue($driver instanceof Rhymix\Framework\Drivers\Cache\Dummy); - + $driver = Rhymix\Framework\Cache::init(array('type' => 'sqlite')); $this->assertTrue($driver instanceof Rhymix\Framework\Drivers\Cache\SQLite); - + $driver = Rhymix\Framework\Cache::init(array()); $this->assertTrue($driver instanceof Rhymix\Framework\Drivers\Cache\Dummy); } - + public function testGetSupportedDrivers() { $drivers = Rhymix\Framework\Cache::getSupportedDrivers(); @@ -37,79 +37,79 @@ class CacheTest extends \Codeception\TestCase\Test $this->assertFalse(in_array('file', $drivers)); $this->assertContains('sqlite', $drivers); } - + public function testGetDriverName() { $driver = Rhymix\Framework\Cache::init(array('type' => 'dummy')); $this->assertEquals('dummy', Rhymix\Framework\Cache::getDriverName()); - + $driver = Rhymix\Framework\Cache::init(array('type' => 'sqlite')); $this->assertEquals('sqlite', Rhymix\Framework\Cache::getDriverName()); } - + public function testGetDriverInstance() { $driver = Rhymix\Framework\Cache::getDriverInstance('dummy'); $this->assertTrue($driver instanceof Rhymix\Framework\Drivers\Cache\Dummy); - + $driver = Rhymix\Framework\Cache::getDriverInstance(); $this->assertTrue($driver instanceof Rhymix\Framework\Drivers\Cache\File); } - + public function testGetPrefix() { $prefix = Rhymix\Framework\Cache::getPrefix(); $this->assertEquals(\RX_VERSION . ':', $prefix); } - + public function testGetSet() { $value = true; $this->assertTrue(Rhymix\Framework\Cache::set('foobar1', $value)); $this->assertTrue(Rhymix\Framework\Cache::get('foobar1')); - + $value = false; $this->assertTrue(Rhymix\Framework\Cache::set('foobar2', $value)); $this->assertFalse(Rhymix\Framework\Cache::get('foobar2')); - + $value = 1756234; $this->assertTrue(Rhymix\Framework\Cache::set('foobar3', $value)); $this->assertEquals($value, Rhymix\Framework\Cache::get('foobar3')); - + $value = 'Rhymix is a PHP CMS.'; $this->assertTrue(Rhymix\Framework\Cache::set('foobar4', $value)); $this->assertEquals($value, Rhymix\Framework\Cache::get('foobar4')); - + $value = array('foo' => 'bar', 'rhy' => 'mix'); $this->assertTrue(Rhymix\Framework\Cache::set('foobar:subkey:5', $value)); $this->assertEquals($value, Rhymix\Framework\Cache::get('foobar:subkey:5')); - + $value = (object)array('foo' => 'bar', 'rhy' => 'mix'); $this->assertTrue(Rhymix\Framework\Cache::set('foobar:subkey:6', $value)); $this->assertEquals($value, Rhymix\Framework\Cache::get('foobar:subkey:6')); - + $this->assertNull(Rhymix\Framework\Cache::get('foobar7')); $this->assertNull(Rhymix\Framework\Cache::get('foobar:subkey:8')); } - + public function testDeleteAndExists() { Rhymix\Framework\Cache::set('foo', 'FOO'); Rhymix\Framework\Cache::set('bar', 'BAR'); - + $this->assertTrue(Rhymix\Framework\Cache::delete('foo')); $this->assertFalse(Rhymix\Framework\Cache::delete('foo')); $this->assertFalse(Rhymix\Framework\Cache::exists('foo')); $this->assertTrue(Rhymix\Framework\Cache::exists('bar')); } - + public function testIncrDecr() { Rhymix\Framework\Cache::init(array('type' => 'sqlite')); Rhymix\Framework\Cache::set('foo', 'foo'); Rhymix\Framework\Cache::set('bar', 42); $prefix = Rhymix\Framework\Cache::getPrefix(); - + $this->assertEquals(1, Rhymix\Framework\Cache::getDriverInstance()->incr($prefix . 'foo', 1)); $this->assertEquals(8, Rhymix\Framework\Cache::getDriverInstance()->incr($prefix . 'foo', 7)); $this->assertEquals(-7, Rhymix\Framework\Cache::decr('foo', 15)); @@ -117,7 +117,7 @@ class CacheTest extends \Codeception\TestCase\Test $this->assertEquals(60, Rhymix\Framework\Cache::incr('bar', 15)); $this->assertEquals(20, Rhymix\Framework\Cache::getDriverInstance()->incr($prefix . 'bar', -40)); } - + public function testClearAll() { $this->assertTrue(Rhymix\Framework\Cache::set('foo', 'foo')); @@ -125,30 +125,30 @@ class CacheTest extends \Codeception\TestCase\Test $this->assertTrue(Rhymix\Framework\Cache::clearAll()); $this->assertFalse(Rhymix\Framework\Cache::exists('foo')); } - + public function testCacheGroups() { Rhymix\Framework\Cache::init(array('type' => 'sqlite')); $prefix = Rhymix\Framework\Cache::getPrefix(); - + $this->assertTrue(Rhymix\Framework\Cache::set('foobar:subkey:1234', 'rhymix')); $this->assertTrue(Rhymix\Framework\Cache::exists('foobar:subkey:1234')); $this->assertEquals('rhymix', Rhymix\Framework\Cache::get('foobar:subkey:1234')); $this->assertEquals('rhymix', Rhymix\Framework\Cache::getDriverInstance()->get($prefix . 'foobar#0:subkey:1234')); $this->assertEquals(0, Rhymix\Framework\Cache::getGroupVersion('foobar')); - + $this->assertTrue(Rhymix\Framework\Cache::clearGroup('foobar')); $this->assertFalse(Rhymix\Framework\Cache::exists('foobar:subkey:1234')); $this->assertTrue(Rhymix\Framework\Cache::set('foobar:subkey:1234', 'rhymix')); $this->assertEquals('rhymix', Rhymix\Framework\Cache::getDriverInstance()->get($prefix . 'foobar#1:subkey:1234')); $this->assertEquals(1, Rhymix\Framework\Cache::getGroupVersion('foobar')); } - + public function testGetRealKey() { Rhymix\Framework\Cache::init(array('type' => 'sqlite')); $prefix = Rhymix\Framework\Cache::getPrefix(); - + $this->assertEquals($prefix . 'foo', Rhymix\Framework\Cache::getRealKey('foo')); $this->assertEquals($prefix . 'bar#0:2016', Rhymix\Framework\Cache::getRealKey('bar:2016')); Rhymix\Framework\Cache::clearGroup('bar'); @@ -156,34 +156,34 @@ class CacheTest extends \Codeception\TestCase\Test Rhymix\Framework\Cache::clearGroup('bar'); $this->assertEquals($prefix . 'bar#2:2016', Rhymix\Framework\Cache::getRealKey('bar:2016')); } - + public function testCompatibility() { Rhymix\Framework\Cache::init(array('type' => 'sqlite')); $ch = \CacheHandler::getInstance(); $this->assertTrue($ch instanceof \CacheHandler); $this->assertTrue($ch->isSupport()); - + $this->assertEquals('rhymix', $ch->getCacheKey('rhymix')); $this->assertEquals('rhymix:123:456', $ch->getCacheKey('rhymix:123:456')); - + $this->assertTrue($ch->put('rhymix', 'foo bar buzz')); $this->assertEquals('foo bar buzz', $ch->get('rhymix')); $this->assertTrue($ch->isValid('rhymix')); $this->assertTrue($ch->delete('rhymix')); $this->assertFalse($ch->get('rhymix')); $this->assertFalse($ch->isValid('rhymix')); - + $this->assertEquals('rhymix:123:456', $ch->getGroupKey('rhymix', '123:456')); $this->assertTrue($ch->put('rhymix:123:456', 'rhymix rules!')); $this->assertEquals('rhymix rules!', $ch->get('rhymix:123:456')); $this->assertEquals(0, Rhymix\Framework\Cache::getGroupVersion('rhymix')); - + $this->assertTrue($ch->invalidateGroupKey('rhymix')); $this->assertTrue($ch->put('rhymix:123:456', 'rhymix rules!')); $this->assertEquals('rhymix rules!', $ch->get('rhymix:123:456')); $this->assertEquals(1, Rhymix\Framework\Cache::getGroupVersion('rhymix')); - + $this->assertTrue($ch->truncate()); $this->assertFalse($ch->get('rhymix:123:456')); } diff --git a/tests/unit/framework/CalendarTest.php b/tests/unit/framework/CalendarTest.php index 19388aec6..367021c79 100644 --- a/tests/unit/framework/CalendarTest.php +++ b/tests/unit/framework/CalendarTest.php @@ -36,7 +36,7 @@ class CalendarTest extends \Codeception\TestCase\Test array(23, 24, 25, 26, 27, 28, 29), array(30, 31, null, null, null, null, null), ); - + $target_201603 = array( array(null, null, 1, 2, 3, 4, 5), array(6, 7, 8, 9, 10, 11, 12), @@ -45,7 +45,7 @@ class CalendarTest extends \Codeception\TestCase\Test array(27, 28, 29, 30, 31, null, null), array(null, null, null, null, null, null, null), ); - + $this->assertEquals($target_201508, Rhymix\Framework\Calendar::getMonthCalendar(8, 2015)); $this->assertEquals($target_201603, Rhymix\Framework\Calendar::getMonthCalendar(3, 2016)); } diff --git a/tests/unit/framework/ConfigTest.php b/tests/unit/framework/ConfigTest.php index b9ef136d2..39116e5f5 100644 --- a/tests/unit/framework/ConfigTest.php +++ b/tests/unit/framework/ConfigTest.php @@ -9,16 +9,16 @@ class ConfigTest extends \Codeception\TestCase\Test mkdir(RX_BASEDIR . 'files/config', 0755, true); copy(RX_BASEDIR . 'common/defaults/config.php', RX_BASEDIR . 'files/config/config.php'); } - + Rhymix\Framework\Config::init(); $this->assertTrue(version_compare(Rhymix\Framework\Config::get('config_version'), '2.0', '>=')); $this->assertTrue(is_array(Rhymix\Framework\Config::get('db.master'))); $this->assertNotEmpty(Rhymix\Framework\Config::get('db.master.host')); - + Rhymix\Framework\Config::set('foo.bar', $rand = mt_rand()); $this->assertEquals(array('bar' => $rand), Rhymix\Framework\Config::get('foo')); $this->assertEquals($rand, Rhymix\Framework\Config::get('foo.bar')); - + $var = array('foo' => 'bar'); $serialized = "array(\n\t'foo' => 'bar',\n)"; $this->assertEquals($serialized, Rhymix\Framework\Config::serialize($var)); diff --git a/tests/unit/framework/DBTest.php b/tests/unit/framework/DBTest.php index 04bad598d..e68d8a4b0 100644 --- a/tests/unit/framework/DBTest.php +++ b/tests/unit/framework/DBTest.php @@ -7,7 +7,7 @@ class DBTest extends \Codeception\TestCase\Test $oDB = Rhymix\Framework\DB::getInstance(); $oDB->setDebugComment(false); } - + public function testGetInstance() { $oDB = Rhymix\Framework\DB::getInstance(); @@ -15,12 +15,12 @@ class DBTest extends \Codeception\TestCase\Test $this->assertTrue($oDB->isConnected()); $this->assertTrue($oDB->getHandle() instanceof Rhymix\Framework\Helpers\DBHelper); } - + public function testPrepare() { $oDB = Rhymix\Framework\DB::getInstance(); $prefix = Rhymix\Framework\Config::get('db.master.prefix'); - + $stmt = $oDB->prepare('SELECT * FROM documents WHERE document_srl = ?'); $this->assertTrue($stmt instanceof Rhymix\Framework\Helpers\DBStmtHelper); if ($prefix) @@ -31,19 +31,19 @@ class DBTest extends \Codeception\TestCase\Test { $this->assertEquals('SELECT * FROM documents WHERE document_srl = ?', $stmt->queryString); } - + $this->assertTrue($stmt->execute([123])); $this->assertTrue($stmt->execute([456])); $this->assertTrue($stmt->execute([789])); $this->assertTrue(is_array($stmt->fetchAll())); $this->assertTrue($stmt->closeCursor()); } - + public function testQuery() { $oDB = Rhymix\Framework\DB::getInstance(); $prefix = Rhymix\Framework\Config::get('db.master.prefix'); - + $stmt = $oDB->query('SELECT * FROM documents WHERE document_srl = 123'); $this->assertTrue($stmt instanceof Rhymix\Framework\Helpers\DBStmtHelper); if ($prefix) @@ -54,10 +54,10 @@ class DBTest extends \Codeception\TestCase\Test { $this->assertEquals('SELECT * FROM documents WHERE document_srl = 123', $stmt->queryString); } - + $this->assertTrue(is_array($stmt->fetchAll())); $this->assertTrue($stmt->closeCursor()); - + $stmt = $oDB->query('SELECT * FROM documents WHERE document_srl = ?', [123]); $this->assertTrue($stmt instanceof Rhymix\Framework\Helpers\DBStmtHelper); if ($prefix) @@ -68,10 +68,10 @@ class DBTest extends \Codeception\TestCase\Test { $this->assertEquals('SELECT * FROM documents WHERE document_srl = ?', $stmt->queryString); } - + $this->assertTrue(is_array($stmt->fetchAll())); $this->assertTrue($stmt->closeCursor()); - + $stmt = $oDB->query('SELECT * FROM documents WHERE document_srl = ? AND status = ?', 123, 'PUBLIC'); $this->assertTrue($stmt instanceof Rhymix\Framework\Helpers\DBStmtHelper); if ($prefix) @@ -82,48 +82,48 @@ class DBTest extends \Codeception\TestCase\Test { $this->assertEquals('SELECT * FROM documents WHERE document_srl = ? AND status = ?', $stmt->queryString); } - + $this->assertTrue(is_array($stmt->fetchAll())); $this->assertTrue($stmt->closeCursor()); } - + public function testAddPrefixes() { $oDB = Rhymix\Framework\DB::getInstance(); $prefix = Rhymix\Framework\Config::get('db.master.prefix'); - + $source = 'SELECT a, b, c FROM documents JOIN comments ON documents.document_srl = comment.document_srl WHERE documents.member_srl = ?'; $target = 'SELECT a, b, c FROM `' . $prefix . 'documents` AS `documents` JOIN `' . $prefix . 'comments` AS `comments` ' . 'ON documents.document_srl = comment.document_srl WHERE documents.member_srl = ?'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'SELECT a AS aa FROM documents as foo JOIN bar ON documents.a = bar.a'; $target = 'SELECT a AS aa FROM `' . $prefix . 'documents` AS `foo` JOIN `' . $prefix . 'bar` AS `bar` ON documents.a = bar.a'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'INSERT INTO documents (a, b, c) VALUES (?, ?, ?)'; $target = 'INSERT INTO `' . $prefix . 'documents` (a, b, c) VALUES (?, ?, ?)'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'INSERT INTO documents (a, b, c) SELECT d, e, f FROM old_documents WHERE g = ?'; $target = 'INSERT INTO `' . $prefix . 'documents` (a, b, c) SELECT d, e, f FROM `' . $prefix . 'old_documents` AS `old_documents` WHERE g = ?'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'UPDATE documents SET a = ?, b = ? WHERE c = ?'; $target = 'UPDATE `' . $prefix . 'documents` SET a = ?, b = ? WHERE c = ?'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'DELETE FROM documents WHERE d = ?'; $target = 'DELETE FROM `' . $prefix . 'documents` WHERE d = ?'; $this->assertEquals($target, $oDB->addPrefixes($source)); - + $source = 'update documents set a = ?, b = ? where c = ?'; $this->assertEquals($source, $oDB->addPrefixes($source)); - + $source = 'delete from documents where d = ?'; $this->assertEquals($source, $oDB->addPrefixes($source)); } - + public function testIsTableColumnIndexExists() { $oDB = Rhymix\Framework\DB::getInstance(); @@ -134,7 +134,7 @@ class DBTest extends \Codeception\TestCase\Test $this->assertFalse($oDB->isColumnExists('documents', 'document_nx')); $this->assertFalse($oDB->isIndexExists('documents', 'idx_regex')); } - + public function testGetColumnInfo() { $oDB = Rhymix\Framework\DB::getInstance(); @@ -146,7 +146,7 @@ class DBTest extends \Codeception\TestCase\Test $this->assertNull($info->default_value); $this->assertTrue($info->notnull); } - + public function testIsValidOldPassword() { $oDB = Rhymix\Framework\DB::getInstance(); @@ -160,7 +160,7 @@ class DBTest extends \Codeception\TestCase\Test $this->assertFalse($oDB->isValidOldPassword($password, $saved3)); $this->assertFalse($oDB->isValidOldPassword($password, $saved4)); } - + public function testAddQuotes() { $oDB = Rhymix\Framework\DB::getInstance(); diff --git a/tests/unit/framework/DateTimeTest.php b/tests/unit/framework/DateTimeTest.php index 37af0017c..60fd05705 100644 --- a/tests/unit/framework/DateTimeTest.php +++ b/tests/unit/framework/DateTimeTest.php @@ -3,7 +3,7 @@ class DateTimeTest extends \Codeception\TestCase\Test { private $old_timezone; - + public function _before() { // Add some dummy data to system configuration. Asia/Seoul offset is 32400. @@ -11,191 +11,191 @@ class DateTimeTest extends \Codeception\TestCase\Test Rhymix\Framework\Config::set('locale.internal_timezone', 10800); Context::getInstance(); Context::set('_default_timezone', $GLOBALS['_time_zone'] = 'Asia/Seoul'); - + // Set PHP time zone to the internal time zone. $this->old_timezone = @date_default_timezone_get(); date_default_timezone_set('Etc/GMT-3'); } - + public function _after() { // Restore the default and internal timezone. Rhymix\Framework\Config::set('locale.default_timezone', 'Asia/Seoul'); Rhymix\Framework\Config::set('locale.internal_timezone', 10800); Context::set('_default_timezone', $GLOBALS['_time_zone'] = 'Asia/Seoul'); - + // Restore the old timezone. date_default_timezone_set($this->old_timezone); } - + public function testZgap() { // Test zgap() when the current user's time zone is different from the system default. $_SESSION['RHYMIX']['timezone'] = 'Etc/UTC'; $this->assertEquals(-10800, zgap()); - + // Test zgap() when the current user's time zone is the same as the system default. unset($_SESSION['RHYMIX']['timezone']); $this->assertEquals(21600, zgap()); } - + public function testZtime() { $timestamp = 1454000000; - + // Test ztime() when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals($timestamp, ztime('20160128195320')); - + // Test ztime() when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals($timestamp, ztime('20160129015320')); - + // Restore the internal timezone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } - + public function testZtimeDateOnly() { $timestamp = -271641600; - + // Test ztime() when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals($timestamp, ztime('19610524')); - + // Test ztime() when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals($timestamp, ztime('19610524')); - + // Restore the internal timezone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } - + public function testZdate() { $expected = '2016-01-29 01:53:20'; - + // Test zdate() when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals($expected, zdate('20160128195320')); $this->assertEquals($expected, zdate('2016-01-28 19:53:20')); $this->assertEquals($expected, zdate('2016-01-28T23:53:20-07:00')); $this->assertEquals($expected, zdate('2016-01-28 21:23:20+04:30')); - + // Test zdate() when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals($expected, zdate('20160129015320')); $this->assertEquals($expected, zdate('2016-01-29 01:53:20')); $this->assertEquals($expected, zdate('2016-01-29 05:53:20+13:00')); $this->assertEquals($expected, zdate('2016-01-28T20:53:20+04:00')); - + // Restore the internal timezone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } - + public function testZdateDateOnly() { // Korea Standard Time was UTC+08:30 until 1961 $expected = '1960-04-19 08:30:00'; - + // Test zdate() when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals($expected, zdate('19600419', 'Y-m-d H:i:s')); - + // Test zdate() when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals($expected, zdate('19600419', 'Y-m-d H:i:s')); - + // Restore the internal timezone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); } - + public function testGetInternalDateTime() { $timestamp = 1454000000; - + // Test when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals('20160128195320', getInternalDateTime($timestamp)); - + // Test when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals('20160129015320', getInternalDateTime($timestamp)); } - + public function testGetDisplayDateTime() { $timestamp = 1454000000; - + // Test when the display time zone is different from the internal time zone. $_SESSION['RHYMIX']['timezone'] = 'America/Los_Angeles'; $this->assertEquals('20160128085320', getDisplayDateTime($timestamp)); - + // Test when the display time zone is the same as the internal time zone. $_SESSION['RHYMIX']['timezone'] = 'Etc/GMT-3'; $this->assertEquals('20160128195320', getDisplayDateTime($timestamp)); } - + public function testGetTimeGap() { $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance('en'); $GLOBALS['lang']->loadPlugin('common'); - + // Test getTimeGap() when the internal time zone is different from the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 10800); $this->assertEquals('1 minute ago', getTimeGap(getInternalDateTime(RX_TIME - 30))); $this->assertEquals('30 minutes ago', getTimeGap(getInternalDateTime(RX_TIME - 1800))); $this->assertEquals('2 hours ago', getTimeGap(getInternalDateTime(RX_TIME - 8000))); - + // Test getTimeGap() when the internal time zone is the same as the default time zone. Rhymix\Framework\Config::set('locale.internal_timezone', 32400); $this->assertEquals('30 minutes ago', getTimeGap(getInternalDateTime(RX_TIME - 1800))); $this->assertEquals('2 hours ago', getTimeGap(getInternalDateTime(RX_TIME - 8000))); $this->assertEquals(getInternalDateTime(RX_TIME - 240000, 'Y.m.d'), getTimeGap(getInternalDateTime(RX_TIME - 240000))); } - + public function testGetTimezoneForCurrentUser() { // Test when the current user's time zone is different from the system default. $_SESSION['RHYMIX']['timezone'] = 'Pacific/Auckland'; $this->assertEquals('Pacific/Auckland', Rhymix\Framework\DateTime::getTimezoneForCurrentUser()); - + // Test when the current user's time zone is the same as the system default. unset($_SESSION['RHYMIX']['timezone']); $this->assertEquals('Asia/Seoul', Rhymix\Framework\DateTime::getTimezoneForCurrentUser()); } - + public function testFormatTimestampForCurrentUser() { $timestamp_winter = 1454000000; $timestamp_summer = $timestamp_winter - (86400 * 184); - + // Test when the current user's time zone is in the Northern hemisphere with DST. $_SESSION['RHYMIX']['timezone'] = 'America/Chicago'; $this->assertEquals('20160128 105320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_winter)); $this->assertEquals('20150728 115320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_summer)); $this->assertEquals('20150728 115320', getDisplayDateTime($timestamp_summer, 'Ymd His')); - + // Test when the current user's time zone is in the Southern hemisphere with DST. $_SESSION['RHYMIX']['timezone'] = 'Pacific/Auckland'; $this->assertEquals('20160129 055320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_winter)); $this->assertEquals('20150729 045320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_summer)); $this->assertEquals('20150729 045320', getDisplayDateTime($timestamp_summer, 'Ymd His')); - + // Test when the current user's time zone is the same as the system default without DST. unset($_SESSION['RHYMIX']['timezone']); $this->assertEquals('20160129 015320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_winter)); $this->assertEquals('20150729 015320', Rhymix\Framework\DateTime::formatTimestampForCurrentUser('Ymd His', $timestamp_summer)); $this->assertEquals('20150729 015320', getDisplayDateTime($timestamp_summer, 'Ymd His')); } - + public function testGetTimezoneList() { $tzlist = Rhymix\Framework\DateTime::getTimezoneList(); $this->assertTrue(array_key_exists('Etc/UTC', $tzlist)); $this->assertEquals('Asia/Seoul (+09:00)', $tzlist['Asia/Seoul']); } - + public function testGetTimezoneOffset() { $this->assertEquals(32400, Rhymix\Framework\DateTime::getTimezoneOffset('Asia/Seoul')); @@ -204,7 +204,7 @@ class DateTimeTest extends \Codeception\TestCase\Test $this->assertEquals(-18000, Rhymix\Framework\DateTime::getTimezoneOffset('America/New_York', strtotime('2016-01-01'))); $this->assertEquals(-14400, Rhymix\Framework\DateTime::getTimezoneOffset('America/New_York', strtotime('2015-07-01'))); } - + public function testGetTimezoneOffsetFromInternal() { $this->assertEquals(21600, Rhymix\Framework\DateTime::getTimezoneOffsetFromInternal('Asia/Seoul')); @@ -213,7 +213,7 @@ class DateTimeTest extends \Codeception\TestCase\Test $this->assertEquals(-28800, Rhymix\Framework\DateTime::getTimezoneOffsetFromInternal('America/New_York', strtotime('2016-01-01'))); $this->assertEquals(-25200, Rhymix\Framework\DateTime::getTimezoneOffsetFromInternal('America/New_York', strtotime('2015-07-01'))); } - + public function testGetTimezoneOffsetByLegacyFormat() { $this->assertEquals(32400, Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat('+0900')); @@ -221,7 +221,7 @@ class DateTimeTest extends \Codeception\TestCase\Test $this->assertEquals(19800, Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat('+0530')); $this->assertEquals(-38700, Rhymix\Framework\DateTime::getTimezoneOffsetByLegacyFormat('-1045')); } - + public function testGetTimezoneNameByOffset() { $this->assertEquals('Etc/GMT-9', Rhymix\Framework\DateTime::getTimezoneNameByOffset(32400)); @@ -230,22 +230,22 @@ class DateTimeTest extends \Codeception\TestCase\Test $this->assertEquals('Asia/Kolkata', Rhymix\Framework\DateTime::getTimezoneNameByOffset(19800)); $this->assertEquals('Australia/Eucla', Rhymix\Framework\DateTime::getTimezoneNameByOffset(31500)); } - + public function testGetRelativeTimestamp() { $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance('ko'); $GLOBALS['lang']->loadPlugin('common'); - + $this->assertEquals('방금', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME)); $this->assertEquals('20초 전', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME - 20)); $this->assertEquals('1분 전', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME - 60)); $this->assertEquals('30분 전', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME - 1800)); $this->assertEquals('10일 전', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME - 86400 * 10)); $this->assertEquals('6개월 전', Rhymix\Framework\DateTime::getRelativeTimestamp(RX_TIME - 86400 * 190)); - + $GLOBALS['lang'] = Rhymix\Framework\Lang::getInstance('en'); $GLOBALS['lang']->loadPlugin('common'); - + $this->assertEquals('just now', getInternalDateTime(RX_TIME + 3600, 'relative')); $this->assertEquals('5 days ago', getDisplayDateTime(RX_TIME - 86400 * 5.4, 'relative')); $this->assertEquals('3 months ago', zdate(date('YmdHis', RX_TIME - 86400 * 100), 'relative')); diff --git a/tests/unit/framework/DebugTest.php b/tests/unit/framework/DebugTest.php index 99522147d..62177f176 100644 --- a/tests/unit/framework/DebugTest.php +++ b/tests/unit/framework/DebugTest.php @@ -3,14 +3,14 @@ class DebugTest extends \Codeception\TestCase\Test { public $error_log; - + public function _before() { Rhymix\Framework\Debug::enable(); $this->error_log = ini_get('error_log'); ini_set('error_log', '/dev/null'); } - + public function _after() { if ($this->error_log) @@ -32,7 +32,7 @@ class DebugTest extends \Codeception\TestCase\Test Rhymix\Framework\Debug::clearEntries(); $this->assertEquals(0, count(Rhymix\Framework\Debug::getEntries())); } - + public function testDebugError() { $file = __FILE__; @@ -47,7 +47,7 @@ class DebugTest extends \Codeception\TestCase\Test Rhymix\Framework\Debug::clearErrors(); $this->assertEquals(0, count(Rhymix\Framework\Debug::getErrors())); } - + public function testDebugQuery() { Rhymix\Framework\Debug::addQuery(array( @@ -72,13 +72,13 @@ class DebugTest extends \Codeception\TestCase\Test Rhymix\Framework\Debug::clearQueries(); $this->assertEquals(0, count(Rhymix\Framework\Debug::getQueries())); } - + public function testDebugTranslateFilename() { $original_filename = __FILE__; $trans_filename = substr($original_filename, strlen(\RX_BASEDIR)); $this->assertEquals($trans_filename, Rhymix\Framework\Debug::translateFilename($original_filename)); - + $original_filename = __FILE__; $alias_filename = $original_filename . '.foobar'; $trans_filename = substr($alias_filename, strlen(\RX_BASEDIR)); diff --git a/tests/unit/framework/FormatterTest.php b/tests/unit/framework/FormatterTest.php index 3b36ec2ec..bed7674ca 100644 --- a/tests/unit/framework/FormatterTest.php +++ b/tests/unit/framework/FormatterTest.php @@ -8,20 +8,20 @@ class FormatterTest extends \Codeception\TestCase\Test $html1 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/text2html.target1.html'); $html2 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/text2html.target2.html'); $html3 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/text2html.target3.html'); - + $this->assertEquals($html1, Rhymix\Framework\Formatter::text2html($text)); $this->assertEquals($html2, Rhymix\Framework\Formatter::text2html($text, Rhymix\Framework\Formatter::TEXT_NEWLINE_AS_P)); $this->assertEquals($html3, Rhymix\Framework\Formatter::text2html($text, Rhymix\Framework\Formatter::TEXT_DOUBLE_NEWLINE_AS_P)); } - + public function testHTML2Text() { $html = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/html2text.source.html'); $text = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/html2text.target.txt'); - + $this->assertEquals($text, Rhymix\Framework\Formatter::html2text($html)); } - + public function testMarkdown2HTML() { $markdown = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.source.md'); @@ -29,47 +29,47 @@ class FormatterTest extends \Codeception\TestCase\Test $html2 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target2.html')); $html3 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target3.html')); $html4 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdown2html.target4.html')); - + $this->assertEquals($html1, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown))); $this->assertEquals($html2, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR))); $this->assertEquals($html3, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_NEWLINE_AS_BR | Rhymix\Framework\Formatter::MD_ENABLE_EXTRA))); $this->assertEquals($html4, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA))); } - + public function testMarkdownExtra() { $markdown = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.source.md'); $html1 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target1.html')); $html2 = $this->_removeSpace(file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/markdownextra.target2.html')); - + $this->assertEquals($html1, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown))); $this->assertEquals($html2, $this->_removeSpace(Rhymix\Framework\Formatter::markdown2html($markdown, Rhymix\Framework\Formatter::MD_ENABLE_EXTRA))); } - + public function testHTML2Markdown() { $html = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/html2markdown.source.html'); $markdown = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/html2markdown.target.md'); - + $this->assertEquals($markdown, Rhymix\Framework\Formatter::html2markdown($html)); } - + public function testBBCode() { $bbcode = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/bbcode.source.txt'); $html = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/bbcode.target.html'); - + $this->assertEquals($html, Rhymix\Framework\Formatter::bbcode($bbcode)); } - + public function testApplySmartQuotes() { $before = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/smartypants.source.html'); $after = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/smartypants.target.html'); - + $this->assertEquals($after, Rhymix\Framework\Formatter::applySmartQuotes($before)); } - + public function testCompileLESS() { $sources = array( @@ -80,21 +80,21 @@ class FormatterTest extends \Codeception\TestCase\Test 'foo' => '#123456', 'bar' => '320px', ); - + $real_target1 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/less.target1.css'); $real_target2 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/less.target2.css'); $test_target1 = \RX_BASEDIR . 'tests/_output/less.target1.css'; $test_target2 = \RX_BASEDIR . 'tests/_output/less.target2.css'; - + $this->assertTrue(Rhymix\Framework\Formatter::compileLESS($sources, $test_target1, $variables)); $this->assertEquals($real_target1, file_get_contents($test_target1)); $this->assertTrue(Rhymix\Framework\Formatter::compileLESS($sources, $test_target2, $variables, true)); $this->assertEquals($real_target2, file_get_contents($test_target2)); - + unlink($test_target1); unlink($test_target2); } - + public function testCompileSCSS() { $sources = array( @@ -105,45 +105,45 @@ class FormatterTest extends \Codeception\TestCase\Test 'foo' => '#123456', 'bar' => '320px', ); - + $real_target1 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/scss.target1.css'); $real_target2 = file_get_contents(\RX_BASEDIR . 'tests/_data/formatter/scss.target2.css'); $test_target1 = \RX_BASEDIR . 'tests/_output/scss.target1.css'; $test_target2 = \RX_BASEDIR . 'tests/_output/scss.target2.css'; - + $this->assertTrue(Rhymix\Framework\Formatter::compileSCSS($sources, $test_target1, $variables)); $this->assertEquals($real_target1, file_get_contents($test_target1)); $this->assertTrue(Rhymix\Framework\Formatter::compileSCSS($sources, $test_target2, $variables, true)); $this->assertEquals($real_target2, file_get_contents($test_target2)); - + unlink($test_target1); unlink($test_target2); } - + public function testMinifyCSS() { $source = \RX_BASEDIR . 'tests/_data/formatter/minify.source.css'; $real_target = \RX_BASEDIR . 'tests/_data/formatter/minify.target.css'; $test_target = \RX_BASEDIR . 'tests/_output/minify.target.css'; - + $this->assertTrue(Rhymix\Framework\Formatter::minifyCSS($source, $test_target)); $this->assertEquals(file_get_contents($real_target), file_get_contents($test_target)); - + unlink($test_target); } - + public function testMinifyJS() { $source = \RX_BASEDIR . 'tests/_data/formatter/minify.source.js'; $real_target = \RX_BASEDIR . 'tests/_data/formatter/minify.target.js'; $test_target = \RX_BASEDIR . 'tests/_output/minify.target.js'; - + $this->assertTrue(Rhymix\Framework\Formatter::minifyJS($source, $test_target)); $this->assertEquals(file_get_contents($real_target), file_get_contents($test_target)); - + unlink($test_target); } - + public function testConcatCSS() { $source1 = \RX_BASEDIR . 'tests/_data/formatter/concat.source1.css'; @@ -151,14 +151,14 @@ class FormatterTest extends \Codeception\TestCase\Test $real_target1 = \RX_BASEDIR . 'tests/_data/formatter/concat.target1.css'; $real_target2 = \RX_BASEDIR . 'tests/_data/formatter/concat.target2.css'; $test_target = \RX_BASEDIR . 'tests/_output/concat.target.css'; - + $test_without_media_query = Rhymix\Framework\Formatter::concatCSS(array($source1, $source2), $test_target); $this->assertEquals(trim(file_get_contents($real_target1)), trim($test_without_media_query)); - + $test_with_media_query = Rhymix\Framework\Formatter::concatCSS(array(array($source1, 'screen and (max-width: 640px)'), $source2), $test_target); $this->assertEquals(trim(file_get_contents($real_target2)), trim($test_with_media_query)); } - + public function testConcatJS() { $source1 = \RX_BASEDIR . 'tests/_data/formatter/concat.source1.js'; @@ -166,14 +166,14 @@ class FormatterTest extends \Codeception\TestCase\Test $real_target1 = \RX_BASEDIR . 'tests/_data/formatter/concat.target1.js'; $real_target2 = \RX_BASEDIR . 'tests/_data/formatter/concat.target2.js'; $test_target = \RX_BASEDIR . 'tests/_output/concat.target.js'; - + $test_without_targetie = Rhymix\Framework\Formatter::concatJS(array($source1, $source2), $test_target); $this->assertEquals(trim(file_get_contents($real_target1)), trim($test_without_targetie)); - + $test_with_targetie = Rhymix\Framework\Formatter::concatJS(array($source1, array($source2, '(gte IE 6) & (lte IE 8)')), $test_target); $this->assertEquals(trim(file_get_contents($real_target2)), trim($test_with_targetie)); } - + protected function _removeSpace($str) { return preg_replace('/\s+/', '', $str); diff --git a/tests/unit/framework/KoreaTest.php b/tests/unit/framework/KoreaTest.php index e7fdaeba2..d47bda78a 100644 --- a/tests/unit/framework/KoreaTest.php +++ b/tests/unit/framework/KoreaTest.php @@ -17,7 +17,7 @@ class KoreaTest extends \Codeception\TestCase\Test $this->assertEquals('0505-9876-5432', Rhymix\Framework\Korea::formatPhoneNumber('050-5987-65432')); $this->assertEquals('070-7432-1000', Rhymix\Framework\Korea::formatPhoneNumber('0707-432-1000')); } - + public function testIsValidPhoneNumber() { $this->assertTrue(Rhymix\Framework\Korea::isValidPhoneNumber('1588-0000')); @@ -39,7 +39,7 @@ class KoreaTest extends \Codeception\TestCase\Test $this->assertFalse(Rhymix\Framework\Korea::isValidPhoneNumber('0303-1111-5432')); $this->assertFalse(Rhymix\Framework\Korea::isValidPhoneNumber('0505-9876-543210')); } - + public function testIsValidMobilePhoneNumber() { $this->assertTrue(Rhymix\Framework\Korea::isValidMobilePhoneNumber('011-345-6789')); @@ -51,28 +51,28 @@ class KoreaTest extends \Codeception\TestCase\Test $this->assertFalse(Rhymix\Framework\Korea::isValidMobilePhoneNumber('063-9876-5432')); $this->assertFalse(Rhymix\Framework\Korea::isValidMobilePhoneNumber('070-7654-3210')); } - + public function testIsValidJuminNumber() { // These numbers are fake. $this->assertTrue(Rhymix\Framework\Korea::isValidJuminNumber('123456-3456787')); $this->assertFalse(Rhymix\Framework\Korea::isValidJuminNumber('123456-3456788')); } - + public function testIsValidCorporationNumber() { // These numbers are fake. $this->assertTrue(Rhymix\Framework\Korea::isValidCorporationNumber('123456-0123453')); $this->assertFalse(Rhymix\Framework\Korea::isValidCorporationNumber('123456-0123454')); } - + public function testIsValidBusinessNumber() { // These numbers are fake. $this->assertTrue(Rhymix\Framework\Korea::isValidBusinessNumber('123-45-67891')); $this->assertFalse(Rhymix\Framework\Korea::isValidBusinessNumber('123-45-67892')); } - + public function testIsKoreanIP() { // Private IP ranges. @@ -80,32 +80,32 @@ class KoreaTest extends \Codeception\TestCase\Test $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('127.0.123.45')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('192.168.10.1')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('::1')); - + // Korean IP ranges. $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('115.71.233.0')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('114.207.12.3')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('2001:0320::1')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanIP('2407:B800::F')); - + // Foreign IP ranges. $this->assertFalse(Rhymix\Framework\Korea::isKoreanIP('216.58.197.0')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanIP('170.14.168.0')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanIP('2001:41d0:8:e8ad::1')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanIP('2404:6800:4005:802::200e')); } - + public function testIsKoreanEmailAddress() { // Test Korean portals. $this->assertTrue(Rhymix\Framework\Korea::isKoreanEmailAddress('test@naver.com')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanEmailAddress('test@hanmail.net')); $this->assertTrue(Rhymix\Framework\Korea::isKoreanEmailAddress('test@worksmobile.com')); - + // Test foreign portals. $this->assertFalse(Rhymix\Framework\Korea::isKoreanEmailAddress('test@gmail.com')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanEmailAddress('test@hotmail.com')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanEmailAddress('test@yahoo.com')); - + // Test third-party MX services. $this->assertTrue(Rhymix\Framework\Korea::isKoreanEmailAddress('test@woorimail.com')); $this->assertFalse(Rhymix\Framework\Korea::isKoreanEmailAddress('test@rhymix.org')); diff --git a/tests/unit/framework/LangTest.php b/tests/unit/framework/LangTest.php index 0fc64b12f..3248e3df9 100644 --- a/tests/unit/framework/LangTest.php +++ b/tests/unit/framework/LangTest.php @@ -10,63 +10,63 @@ class LangTest extends \Codeception\TestCase\Test $this->assertTrue($ko instanceof Rhymix\Framework\Lang); $this->assertTrue($en instanceof Rhymix\Framework\Lang); $this->assertFalse($ko === $en); - + // Test backward compatible language code for Japanese. $ja = Rhymix\Framework\Lang::getInstance('ja'); $jp = Rhymix\Framework\Lang::getInstance('jp'); $this->assertTrue($ja === $jp); - + // Test loading new plugins. $this->assertNotEquals('ヘルプ', $ja->help); $ja->loadPlugin('common'); $this->assertEquals('ヘルプ', $ja->help); - + // Test simple translations with namespacing. $this->assertEquals('도움말', $ko->get('common.help')); $this->assertEquals('Help', $en->get('common.help')); - + // Test simple translations without namespacing. $this->assertEquals('도움말', $ko->help); $this->assertEquals('Help', $en->help); - + // Test complex translations with multidimensional arrays. $this->assertEquals('%d분 전', $ko->get('common.time_gap.min')); $this->assertEquals('10분 전', $ko->get('common.time_gap.min', 10)); $this->assertTrue($ko->get('common.time_gap') instanceof \ArrayObject); $this->assertEquals('%d분 전', $ko->get('common.time_gap')->min); - + // Test nonexistent keys. $this->assertEquals('common.nonexistent', $ko->get('common.nonexistent')); $this->assertEquals('common.nonexistent', $ko->get('common.nonexistent', 'foo', 'bar')); $this->assertEquals('admin.help', $ko->get('admin.help')); $this->assertEquals('admin.help', $en->get('admin.help')); - + // Test setting new keys with and without namespacing. $ko->set('foo', 'FOO!'); $this->assertEquals('FOO!', $ko->get('foo')); $ko->set('common.foobar', 'FOOBAR!'); $this->assertEquals('FOOBAR!', $ko->get('common.foobar')); $this->assertEquals('FOOBAR!', $ko->get('foobar')); - + // Test setting new keys with multidimensional arrays. $ko->set('common.time_gap.foobar', 'FOOBAR!'); $this->assertEquals('FOOBAR!', $ko->get('common.time_gap.foobar')); $ko->set('common.foobar.baz', 'BAZ!'); $this->assertNotEquals('BAZ!', $ko->get('common.foobar.baz')); - + // Test fallback to English. $en->only_in_english = 'Hello world'; $this->assertEquals('Hello world', $ko->only_in_english); $this->assertEquals('Hello world', $en->only_in_english); $this->assertEquals('Hello world', $ja->only_in_english); - + // Test string interpolation. $ko->foobartestlang = '%s님 안녕하세요?'; $this->assertEquals('Travis님 안녕하세요?', $ko->foobartestlang('Travis')); $en->foobartestlang = 'Hello, %s!'; $this->assertEquals('Hello, Travis!', $en->get('foobartestlang', 'Travis')); } - + public function testLangCompat() { Context::loadLang('./modules/member/lang'); diff --git a/tests/unit/framework/MIMETest.php b/tests/unit/framework/MIMETest.php index d3dd7f680..9ccd31d01 100644 --- a/tests/unit/framework/MIMETest.php +++ b/tests/unit/framework/MIMETest.php @@ -7,13 +7,13 @@ class MIMETest extends \Codeception\TestCase\Test $this->assertEquals('audio/ogg', Rhymix\Framework\MIME::getTypeByExtension('ogg')); $this->assertEquals('image/gif', Rhymix\Framework\MIME::getTypeByExtension('gif')); $this->assertEquals('text/html', Rhymix\Framework\MIME::getTypeByExtension('htm')); - + $this->assertEquals('application/msword', Rhymix\Framework\MIME::getTypeByFilename('attachment.doc')); $this->assertEquals('application/pdf', Rhymix\Framework\MIME::getTypeByFilename('라이믹스.pdf')); $this->assertEquals('application/postscript', Rhymix\Framework\MIME::getTypeByFilename('MyGraphics.v2.eps')); $this->assertEquals('application/vnd.ms-excel', Mail::returnMIMEType('MySpreadsheet.xls')); $this->assertEquals('application/octet-stream', Mail::returnMIMEType('Untitled File')); - + $this->assertEquals('odt', Rhymix\Framework\MIME::getExtensionByType('application/vnd.oasis.opendocument.text')); $this->assertEquals('jpg', Rhymix\Framework\MIME::getExtensionByType('image/jpeg')); $this->assertEquals('mpg', Rhymix\Framework\MIME::getExtensionByType('video/mpeg')); diff --git a/tests/unit/framework/MailTest.php b/tests/unit/framework/MailTest.php index f4f88fe95..840c78707 100644 --- a/tests/unit/framework/MailTest.php +++ b/tests/unit/framework/MailTest.php @@ -6,12 +6,12 @@ class MailTest extends \Codeception\TestCase\Test { $driver = Rhymix\Framework\Mail::getDefaultDriver(); $this->assertInstanceOf('\\Rhymix\\Framework\\Drivers\\MailInterface', $driver); - + $driver = Rhymix\Framework\Drivers\Mail\Dummy::getInstance(array()); Rhymix\Framework\Mail::setDefaultDriver($driver); $this->assertEquals($driver, Rhymix\Framework\Mail::getDefaultDriver()); } - + public function testGetSupportedDrivers() { $drivers = Rhymix\Framework\Mail::getSupportedDrivers(); @@ -22,82 +22,82 @@ class MailTest extends \Codeception\TestCase\Test $this->assertEquals(array('api_token'), $drivers['sparkpost']['required']); $this->assertNotEmpty($drivers['woorimail']['spf_hint']); } - + public function testSenderAndRecipients() { $mail = new Rhymix\Framework\Mail; - + $this->assertNull($mail->getFrom()); $mail->setFrom('devops@rhymix.org', 'Rhymix Developers'); $this->assertEquals('Rhymix Developers ', $mail->getFrom()); - + $this->assertEquals(null, $mail->message->getTo()); $mail->addTo('whoever@rhymix.org', 'Name'); $this->assertEquals(array('whoever@rhymix.org' => 'Name'), $mail->message->getTo()); - + $this->assertEquals(null, $mail->message->getCc()); $mail->addCc('whatever@rhymix.org', 'Nick'); $this->assertEquals(array('whatever@rhymix.org' => 'Nick'), $mail->message->getCc()); - + $this->assertEquals(null, $mail->message->getBcc()); $mail->addBcc('wherever@rhymix.org', 'User'); $this->assertEquals(array('wherever@rhymix.org' => 'User'), $mail->message->getBcc()); - + $this->assertEquals(null, $mail->message->getReplyTo()); $mail->setReplyTo('replyto@rhymix.org'); $this->assertEquals(array('replyto@rhymix.org' => ''), $mail->message->getReplyTo()); - + $recipients = $mail->getRecipients(); $this->assertEquals(3, count($recipients)); $this->assertContains('Name ', $recipients); $this->assertContains('Nick ', $recipients); $this->assertContains('User ', $recipients); } - + public function testMiscHeaders() { $mail = new Rhymix\Framework\Mail; - + $mail->setReturnPath('envelope@rhymix.org'); $this->assertEquals('envelope@rhymix.org', $mail->message->getReturnPath()); - + $mail->setMessageID('some.random.string@rhymix.org'); $this->assertEquals('some.random.string@rhymix.org', $mail->message->getId()); - + $mail->setInReplyTo(''); $this->assertEquals('', $mail->message->getHeaders()->get('In-Reply-To')->getValue()); - + $mail->setReferences(', , '); $this->assertEquals(', , ', $mail->message->getHeaders()->get('References')->getValue()); } - + public function testMailSubject() { $mail = new Rhymix\Framework\Mail; - + $mail->setSubject('Foobar!'); $this->assertEquals('Foobar!', $mail->getSubject()); $mail->setTitle('Foobarbazz?'); $this->assertEquals('Foobarbazz?', $mail->getTitle()); } - + public function testMailBody() { $baseurl = '/' . basename(dirname(dirname(dirname(__DIR__)))) . '/'; $mail = new Rhymix\Framework\Mail; - + $mail->setBody('

Hello world!

', 'text/html'); $this->assertEquals('

Hello world!

', $mail->getBody()); $this->assertEquals('text/html', $mail->getContentType()); - + $mail->setContent('

Hello world! Foobar?

', 'text/plain'); $this->assertEquals('

Hello world! Foobar?

', $mail->getBody()); $this->assertEquals('text/plain', $mail->getContentType()); - + $mail->setBody('

Hello foobar...

', 'invalid value'); $this->assertEquals('

Hello foobar...

', $mail->getContent()); $this->assertEquals('text/plain', $mail->getContentType()); - + $mail->setBody('

TEST

', 'text/html'); $this->assertEquals('

TEST

', $mail->getBody()); $mail->setBody('

TEST

', 'text/html'); @@ -106,24 +106,24 @@ class MailTest extends \Codeception\TestCase\Test $this->assertEquals('

TEST

', $mail->getBody()); $mail->setBody('

TEST

', 'text/plain'); $this->assertEquals('

TEST

', $mail->getBody()); - + $mail->setContentType('html'); $this->assertEquals('text/html', $mail->getContentType()); $mail->setContentType('invalid'); $this->assertEquals('text/plain', $mail->getContentType()); } - + public function testMailAttach() { $mail = new Rhymix\Framework\Mail; - + $success = $mail->attach(\RX_BASEDIR . 'tests/_data/formatter/minify.source.css'); $this->assertTrue($success); $success = $mail->attach(\RX_BASEDIR . 'tests/_data/formatter/minify.target.css', 'target.css'); $this->assertTrue($success); $success = $mail->attach(\RX_BASEDIR . 'tests/_data/nonexistent.file.jpg'); $this->assertFalse($success); - + $attachments = $mail->getAttachments(); $this->assertEquals(2, count($attachments)); $this->assertEquals('attach', $attachments[0]->type); @@ -131,51 +131,51 @@ class MailTest extends \Codeception\TestCase\Test $this->assertEquals('minify.source.css', $attachments[0]->display_filename); $this->assertEquals('target.css', $attachments[1]->display_filename); } - + public function testMailEmbed() { $mail = new Rhymix\Framework\Mail; - + $cid = $mail->embed(\RX_BASEDIR . 'tests/_data/formatter/minify.source.css', 'thisismyrandomcid@rhymix.org'); $this->assertEquals('cid:thisismyrandomcid@rhymix.org', $cid); - + $cid = $mail->embed(\RX_BASEDIR . 'tests/_data/formatter/minify.target.css'); $this->assertRegexp('/^cid:[0-9a-z]+@[^@]+$/i', $cid); } - + public function testMailClassCompatibility() { \Mail::useGmailAccount('devops@rhymix.org', 'password'); $this->assertInstanceOf('\\Rhymix\\Framework\\Drivers\\Mail\\SMTP', \Mail::getDefaultDriver()); - + \Mail::useSMTP(null, 'rhymix.org', 'devops@rhymix.org', 'password', 'tls', 587); $this->assertInstanceOf('\\Rhymix\\Framework\\Drivers\\Mail\\SMTP', \Mail::getDefaultDriver()); - + $mail = new \Mail; - + $mail->setSender('Rhymix', 'devops@rhymix.org'); $this->assertEquals('Rhymix ', $mail->getSender()); - + $mail->setReceiptor('Recipient', 'whoever@rhymix.org'); $this->assertEquals('Recipient ', $mail->getReceiptor()); $mail->setReceiptor('Another Recipient', 'whatever@rhymix.org'); $this->assertEquals('Another Recipient ', $mail->getReceiptor()); $this->assertEquals(1, count($mail->message->getTo())); $this->assertEquals(null, $mail->message->getCc()); - + $mail->setBcc('bcc-1@rhymix.org'); $mail->setBcc('bcc-2@rhymix.org'); $this->assertEquals(array('bcc-2@rhymix.org' => ''), $mail->message->getBcc()); - + $content = '

Hello world!

This is a long message to test chunk splitting.

This feature is only available using the legacy Mail class.

'; $mail->setBody($content); $this->assertEquals(chunk_split(base64_encode($content)), $mail->getHTMLContent()); $this->assertEquals(chunk_split(base64_encode(htmlspecialchars($content))), $mail->getPlainContent()); - + $mail->addAttachment(\RX_BASEDIR . 'tests/_data/formatter/minify.target.css', 'target.css'); $cid = $mail->addCidAttachment(\RX_BASEDIR . 'tests/_data/formatter/minify.target.css', 'thisismyrandomcid@rhymix.org'); $this->assertEquals('cid:thisismyrandomcid@rhymix.org', $cid); - + $attachments = $mail->getAttachments(); $this->assertEquals(2, count($attachments)); $this->assertEquals('attach', $attachments[0]->type); @@ -183,7 +183,7 @@ class MailTest extends \Codeception\TestCase\Test $this->assertEquals('embed', $attachments[1]->type); $this->assertEquals('cid:thisismyrandomcid@rhymix.org', $attachments[1]->cid); } - + public function testEmailAddressValidator() { $this->assertEquals('devops@rhymix.org', Mail::isVaildMailAddress('devops@rhymix.org')); diff --git a/tests/unit/framework/PaginationTest.php b/tests/unit/framework/PaginationTest.php index 79d720afa..91fac5e82 100644 --- a/tests/unit/framework/PaginationTest.php +++ b/tests/unit/framework/PaginationTest.php @@ -9,7 +9,7 @@ class PaginationTest extends \Codeception\TestCase\Test $this->assertEquals(1, Rhymix\Framework\Pagination::countPages(20, 20)); $this->assertEquals(2, Rhymix\Framework\Pagination::countPages(21, 20)); } - + public function testCreateLinks() { $links = Rhymix\Framework\Pagination::createLinks('index.php?page=', 27, 3); @@ -17,29 +17,29 @@ class PaginationTest extends \Codeception\TestCase\Test $this->assertStringContainsString('', $links); $this->assertStringContainsString('1', $links); $this->assertStringContainsString('10', $links); - + $links = Rhymix\Framework\Pagination::createLinks('/foo/bar/page/', 27, 13); $this->assertStringContainsString('