Remove trailing whitespace in all unit tests

This commit is contained in:
Kijin Sung 2023-01-30 21:48:09 +09:00
parent 37b0d3a1e6
commit 3b77781d15
40 changed files with 840 additions and 840 deletions

View file

@ -15,17 +15,17 @@ class FunctionsTest extends \Codeception\TestCase\Test
$array = array('foo' => 'xe', 'bar' => 'rhymix', 'key' => array('value1', 'value2', array('bar' => 'value3')), 'last' => 'bears');
$flattened1 = array('foo' => 'xe', 'bar' => 'value3', 0 => 'value1', 1 => 'value2', 'last' => 'bears');
$flattened2 = array(0 => 'xe', 1 => 'rhymix', 2 => 'value1', 3 => 'value2', 4 => 'value3', 5 => 'bears');
$this->assertEquals('foo', array_first_key($array));
$this->assertEquals('xe', array_first($array));
$this->assertEquals('last', array_last_key($array));
$this->assertEquals('bears', array_last($array));
$this->assertEquals($flattened1, array_flatten($array));
$this->assertEquals($flattened2, array_flatten($array, false));
}
public function testArrayEscape()
{
$this->assertEquals(array('foo&lt;' => 'bar&gt;', 'baz&quot;baz' => array('fuzz&amp;amp;bazz' => '&lt;rhymix&gt;')), array_escape(array('foo<' => 'bar>', 'baz"baz' => array('fuzz&amp;bazz' => '<rhymix>'))));
@ -33,49 +33,49 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertEquals(array('object' => (object)array('foo&gt;' => 'bar&lt;', 'baz&quot;' => '&amp;amp;')), array_escape(array('object' => (object)array('foo>' => 'bar<', 'baz"' => '&amp;'))));
$this->assertEquals(array('object' => (object)array('foo&gt;' => array('bar&lt;' => array('&amp;')))), array_escape(array('object' => (object)array('foo>' => array('bar<' => array('&amp;')))), false));
}
public function testClassBasename()
{
$this->assertEquals('FunctionsTest', class_basename($this));
$this->assertEquals('FunctionsTest', class_basename(get_class($this)));
}
public function testEscapeFunctions()
{
$this->assertEquals('&lt;foo&gt;&amp;amp;&lt;/foo&gt;', escape('<foo>&amp;</foo>'));
$this->assertEquals('&lt;foo&gt;&amp;&lt;/foo&gt;', escape('<foo>&amp;</foo>', false));
$this->assertEquals('&lt;foo&gt;invalid'. "\xEF\xBF\xBD" . 'unicode&lt;/foo&gt;', escape('<foo>invalid' . "\xE4\xA8" . 'unicode</foo>'));
$this->assertEquals('&lt;foo&gt;invalid'. "\xEF\xBF\xBD" . 'unicode&lt;/foo&gt;', escape('<foo>invalid' . "\xE4\xA8" . 'unicode&lt;/foo&gt;', false));
$this->assertEquals('$user_lang-&gt;userLang1234567890', escape('$user_lang->userLang1234567890', true, false));
$this->assertEquals('$user_lang->userLang1234567890', escape('$user_lang->userLang1234567890', true, true));
$this->assertEquals('expressionalertXSS', escape_css('expression:alert("XSS")'));
$this->assertEquals('#123456', escape_css('#123456'));
$this->assertEquals('hello\\\\world', escape_js('hello\\world'));
$this->assertEquals('\u003Cbr \/\u003E', escape_js('<br />'));
$this->assertEquals('hello\\\\world', escape_sqstr('hello\\world'));
$this->assertEquals('hello"world\\\'quotes', escape_sqstr('hello"world\'quotes'));
$this->assertEquals('hello\\\\\\$world in \\"quotes\\"', escape_dqstr('hello\\$world in "quotes"'));
$this->assertEquals('\\${array[\'key\']}', escape_dqstr('${array[\'key\']}'));
}
public function testExplodeWithEscape()
{
$this->assertEquals(array('foo', 'bar'), explode_with_escape(',', 'foo,bar'));
$this->assertEquals(array('foo', 'bar'), explode_with_escape(',', 'foo , bar'));
$this->assertEquals(array('foo', 'bar', 'baz,rhymix'), explode_with_escape(',', 'foo,bar,baz,rhymix', 3));
$this->assertEquals(array('foo', 'bar', 'baz , rhymix'), explode_with_escape(',', 'foo,bar,baz , rhymix', 3));
$this->assertEquals(array('foo', 'bar,baz'), explode_with_escape(',', 'foo,bar\\,baz'));
$this->assertEquals(array('foo', 'bar\\', 'baz'), explode_with_escape(',', 'foo,bar\\ , baz'));
$this->assertEquals(array('foo', 'bar,baz', 'rhymix'), explode_with_escape(',', 'foo,bar\\,baz,rhymix'));
$this->assertEquals(array('foo', 'bar,baz'), explode_with_escape(',', 'foo,bar!,baz', null, '!'));
}
public function testStartsEndsContains()
{
$this->assertTrue(starts_with('foo', 'foobar'));
@ -84,14 +84,14 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(starts_with('bar', 'foobar'));
$this->assertFalse(starts_with('foobar', 'foo'));
$this->assertTrue(starts_with('', 'foobar'));
$this->assertTrue(ends_with('bar', 'foobar'));
$this->assertFalse(ends_with('BAR', 'foobar'));
$this->assertTrue(ends_with('BAR', 'foobar', false));
$this->assertFalse(ends_with('foo', 'foobar'));
$this->assertFalse(ends_with('foobar', 'bar'));
$this->assertTrue(ends_with('', 'foobar'));
$this->assertTrue(contains('foo', 'foo bar baz rhymix rocks'));
$this->assertFalse(contains('barbaz', 'foo bar baz rhymix rocks'));
$this->assertTrue(contains('RHYMIX', 'foo bar baz rhymix rocks', false));
@ -99,7 +99,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(contains('foobar', 'bar'));
$this->assertTrue(contains('', 'foobar'));
}
public function testRangeFunctions()
{
$this->assertTrue(is_between(5, 1, 10));
@ -108,18 +108,18 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertTrue(is_between(7, 1, 10, true));
$this->assertFalse(is_between(1, 1, 10, true));
$this->assertFalse(is_between(10, 1, 10, true));
$this->assertEquals(10, force_range(14, 1, 10));
$this->assertEquals(3, force_range(3, 1, 10));
$this->assertEquals(1, force_range(-4, 1, 10));
}
public function testUrlSafeBase64()
{
$this->assertEquals('Umh5bWl4IF5-', base64_encode_urlsafe('Rhymix ^~'));
$this->assertEquals('Rhymix ^~', base64_decode_urlsafe('Umh5bWl4IF5-'));
}
public function testNumberShorten()
{
$this->assertEquals('1', number_shorten(1));
@ -150,20 +150,20 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertEquals('1.00000T', number_shorten(1000000000000, 6));
$this->assertEquals('10.0000T', number_shorten(10000000000000, 6));
}
public function testHex2Rgb2Hex()
{
$this->assertEquals(array(128, 128, 128), hex2rgb('808080'));
$this->assertEquals(array(60, 71, 244), hex2rgb('#3c47f4'));
$this->assertEquals(array(119, 119, 119), hex2rgb('#777'));
$this->assertEquals(array(51, 102, 153), hex2rgb('369'));
$this->assertEquals('#808080', rgb2hex(array(128, 128, 128)));
$this->assertEquals('#3c47f4', rgb2hex(array(60, 71, 244)));
$this->assertEquals('777777', rgb2hex(array(119, 119, 119), false));
$this->assertEquals('#000000', rgb2hex(array()));
}
public function testToBool()
{
$this->assertTrue(tobool('Y'));
@ -180,7 +180,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertTrue(tobool(true));
$this->assertTrue(tobool(array(1, 2, 3)));
$this->assertTrue(tobool(new stdClass));
$this->assertFalse(tobool('N'));
$this->assertFalse(tobool('no'));
$this->assertFalse(tobool('none'));
@ -196,7 +196,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(tobool(null));
$this->assertFalse(tobool(array()));
}
public function testCountObj()
{
$this->assertEquals(3, countobj(array('foo' => 1, 'bar' => 2, 'baz' => 3)));
@ -205,7 +205,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertEquals(42, countobj(new CountableTest));
$this->assertEquals(0, countobj(new stdClass));
}
public function testUTF8Functions()
{
$this->assertTrue(utf8_check('Hello, world!'));
@ -214,22 +214,22 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertTrue(utf8_check(iconv('UTF-8', 'EUC-KR', 'One CMS to rule them all...')));
$this->assertFalse(utf8_check(iconv('UTF-8', 'EUC-KR', '라이믹스')));
$this->assertFalse(utf8_check(chr(129) . chr(214) . chr(181) . chr(73) . chr(97)));
$this->assertEquals('Hello', utf8_clean("\xEF\xBB\xBF" . 'Hello' . "\xBC\xBC"));
$this->assertEquals('Hello', utf8_clean('Hello&#8238;&#x3164;' . "\xE3\x85\xA4\xE2\x80\xAE"));
$this->assertEquals('Hello' . "\xC3\xA9", utf8_clean('Hello' . "e\xCC\x81"));
$this->assertEquals('Hello' . "\xCD\x9D\xCD\x9D\xCD\x9D", utf8_clean('Hello' . "\xCD\x9D\xCD\x9D\xCD\x9D\xCD\x9D\xCD\x9D"));
$this->assertEquals('Emoticon: &#x1f601;', utf8_mbencode("Emoticon: \xf0\x9f\x98\x81"));
$this->assertEquals('Emoticon: &#x1f61c;', utf8_mbencode("Emoticon: \xf0\x9f\x98\x9c"));
$this->assertEquals('한글은 인코딩하지 않음', utf8_mbencode('한글은 인코딩하지 않음'));
$this->assertEquals("Weird spaces are in this string", utf8_normalize_spaces("Weird\x20spaces\xe2\x80\x80are\xe2\x80\x84in\xe2\x80\x86\xe2\x80\x8bthis\x0astring"));
$this->assertEquals("Weird spaces are in this\nstring", utf8_normalize_spaces("Weird\x20spaces\xe2\x80\x80are\xe2\x80\x84in\xe2\x80\x86\xe2\x80\x8bthis\x0astring", true));
$this->assertEquals("Trimmed", utf8_trim("\x20\xe2\x80\x80Trimmed\xe2\x80\x84\xe2\x80\x86\xe2\x80\x8b"));
$this->assertEquals("Trimmed", utf8_trim("\x20\xe2\x80\x80Trimmed\x0a\x0c\x07\x09"));
}
public function testIsHTMLContent()
{
$this->assertTrue(is_html_content("<p>Hello World</p>"));
@ -247,7 +247,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(is_html_content("<p> tag is unbalanced here.\nAnother line!<br />\nAnd a dangling line..."));
$this->assertFalse(is_html_content("Looks like a broken editor<br />\nthat produced\nthis kind of\nstring!</div>"));
}
public function testIsEmptyHTMLContent()
{
$this->assertTrue(is_empty_html_content('<p>&nbsp;<br><br></p>'));
@ -259,7 +259,7 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(is_empty_html_content('<p><video src="rickroll.webm" /></p>'));
$this->assertFalse(is_empty_html_content('<p><object></object></p>'));
}
public function testPolyfillFunctions()
{
$this->assertTrue(function_exists('is_countable'));
@ -267,19 +267,19 @@ class FunctionsTest extends \Codeception\TestCase\Test
$this->assertFalse(is_countable('hello world'));
$this->assertTrue(is_countable(new CountableTest));
$this->assertFalse(is_countable(new stdClass));
$this->assertTrue(function_exists('str_starts_with'));
$this->assertTrue(str_starts_with('foobar', 'foo'));
$this->assertFalse(str_starts_with('Foobar', 'FOO'));
$this->assertFalse(str_starts_with('', 'bar'));
$this->assertTrue(str_starts_with('foobar', ''));
$this->assertTrue(function_exists('str_ends_with'));
$this->assertTrue(str_ends_with('foobar', 'bar'));
$this->assertFalse(str_ends_with('Foobar', 'BAR'));
$this->assertFalse(str_ends_with('', 'bar'));
$this->assertTrue(str_ends_with('foobar', ''));
$this->assertTrue(function_exists('str_contains'));
$this->assertTrue(str_contains('foobarbazz', 'bar'));
$this->assertFalse(str_contains('foobarbazz', 'BAR'));

View file

@ -4,7 +4,7 @@ class LegacyTest extends \Codeception\TestCase\Test
{
public function testGetModule()
{
$this->assertTrue(getModule('board', 'controller') instanceof BoardController);
$this->assertTrue(getModule('board', 'controller') instanceof BoardController);
$this->assertTrue(getModule('board', 'model') instanceof BoardModel);
$this->assertTrue(getModule('board', 'view', 'admin') instanceof BoardAdminView);
$this->assertTrue(getModule('board') instanceof BoardView);
@ -19,25 +19,25 @@ class LegacyTest extends \Codeception\TestCase\Test
$this->assertTrue(getWAP('board') instanceof BoardWap);
$this->assertTrue(getClass('board') instanceof Board);
}
public function testGetNextSequence()
{
if (!DB::getInstance()->isConnected())
{
return;
}
$this->assertGreaterThan(0, $sequence1 = getNextSequence());
$this->assertGreaterThan($sequence1, $sequence2 = getNextSequence());
$this->assertTrue(checkUserSequence($sequence1));
$this->assertTrue(checkUserSequence($sequence2));
$this->assertFalse(checkUserSequence(-1));
setUserSequence(-1);
$this->assertTrue(checkUserSequence(-1));
}
public function testGetURL()
{
/**
@ -55,19 +55,19 @@ class LegacyTest extends \Codeception\TestCase\Test
* - getRequestUriByServerEnviroment()
*/
}
public function testIsSiteID()
{
$this->assertTrue(isSiteID('rhymix_RHYMIX_1234'));
$this->assertFalse(isSiteID('www.rhymix.org'));
}
public function testCutStr()
{
$this->assertEquals('안녕하세요? 라이믹스...', cut_str('안녕하세요? 라이믹스입니다. 제목이 너무 길어서 잘립니다.', 20));
$this->assertEquals('Hello? This is Rhymix...', cut_str('Hello? This is Rhymix. This title is very long.', 20));
}
public function testTimeFunctions()
{
$this->assertEquals(0, get_time_zone_offset('00:00'));
@ -76,11 +76,11 @@ class LegacyTest extends \Codeception\TestCase\Test
$this->assertEquals(32400, get_time_zone_offset('0900'));
$this->assertEquals(-18000, get_time_zone_offset('-05:00'));
$this->assertEquals(-18000, get_time_zone_offset('-0500'));
$this->assertEquals('Jan', getMonthName(1));
$this->assertEquals('Sep', getMonthName(9, true));
$this->assertEquals('September', getMonthName(9, false));
/**
* The following functions are tested in DateTimeTest:
* - zgap()
@ -91,41 +91,41 @@ class LegacyTest extends \Codeception\TestCase\Test
* - getTimeGap()
*/
}
public function testGetEncodedEmailAddress()
{
$this->assertNotEquals('devops@rhymix.org', getEncodeEmailAddress('devops@rhymix.org'));
$this->assertStringContainsString('&#X', getEncodeEmailAddress('devops@rhymix.org'));
}
public function testGetMicrotime()
{
$microtime1 = microtime(true);
$microtime2 = getMicroTime();
$microtime3 = microtime(true);
$this->assertEquals('double', gettype($microtime2));
$this->assertGreaterThanOrEqual($microtime1, $microtime2);
$this->assertGreaterThanOrEqual($microtime2, $microtime3);
}
public function testDelObjectVars()
{
$target = (object)array('foo' => 1, 'bar' => 2, 'baz' => 3, 'rhymix' => 4);
$delete = (object)array('bar' => 5, 'baz' => 6);
$result = delObjectVars($target, $delete);
// Check if the keys were deleted from the result.
$this->assertTrue(isset($result->foo));
$this->assertFalse(isset($result->bar));
$this->assertFalse(isset($result->baz));
$this->assertTrue(isset($result->rhymix));
// Check if the keys are intact in the original target.
$this->assertTrue(isset($target->bar));
$this->assertTrue(isset($target->baz));
}
public function testGetDestroyXeVars()
{
// Test array. (Keys should be intact in the original target.)
@ -133,14 +133,14 @@ class LegacyTest extends \Codeception\TestCase\Test
$result = getDestroyXeVars($target);
$this->assertFalse(isset($result['xe_validator_id']));
$this->assertTrue(isset($target['xe_validator_id']));
// Test object. (Keys should be deleted from the original target.)
$target = (object)array('foo' => 1, 'bar' => 2, 'xe_validator_id' => 3);
$result = getDestroyXeVars($target);
$this->assertFalse(isset($result->xe_validator_id));
$this->assertFalse(isset($target->xe_validator_id));
}
public function testGetNumberingPath()
{
$this->assertEquals('001/', getNumberingPath(1));
@ -153,44 +153,44 @@ class LegacyTest extends \Codeception\TestCase\Test
$this->assertEquals('678/345/012/', getNumberingPath(12345678));
$this->assertEquals('789/456/123/', getNumberingPath(123456789));
}
public function testMysqlPre4HashPassword()
{
$this->assertEquals('5d2e19393cc5ef67', mysql_pre4_hash_password('password'));
$this->assertEquals('25a4fb474e17c19a', mysql_pre4_hash_password('pass\'#word'));
}
public function testJsonEncode2()
{
$data = array('foo' => 1, 'bar' => 2, 'baz' => 3, 'rhymix' => 4);
$this->assertEquals(json_encode($data), json_encode2($data));
}
public function TestIsCrawler()
{
$original_user_agent = $_SERVER['HTTP_USER_AGENT'];
// Test automatic detection from User-Agent string.
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0';
$this->assertFalse(isCrawler());
$_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
$this->assertTrue(isCrawler());
// Test manual detection.
$this->assertTrue(isCrawler('Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'));
$this->assertTrue(isCrawler('Yeti/1.0 (NHN Corp.; http://help.naver.com/robots/)'));
$this->assertFalse(isCrawler('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36'));
$this->assertFalse(isCrawler('Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'));
$_SERVER['HTTP_USER_AGENT'] = $original_user_agent;
}
public function testMiscUTF8Functions()
{
$this->assertEquals('&lt;img&gt;', url_decode('%3Cimg%3E'));
$this->assertEquals('한글 % English', utf8RawUrlDecode('%uD55C%uAE00%20%25%20English'));
$this->assertEquals('뷁', _code2utf(48577));
$this->assertTrue(detectUTF8('라이믹스'));
$this->assertTrue(detectUTF8(urlencode('라이믹스')));
$this->assertTrue(detectUTF8('%87%a9%43%cd%ef', false, false));
@ -200,7 +200,7 @@ class LegacyTest extends \Codeception\TestCase\Test
$this->assertEquals(mb_convert_encoding('라이믹스', 'UTF-8', 'CP949'), detectUTF8('라이믹스', true));
$this->assertEquals('라이믹스', detectUTF8(iconv('UTF-8', 'EUC-KR', '라이믹스'), true));
}
public function testMiscSecurityFunctions()
{
/**
@ -209,14 +209,14 @@ class LegacyTest extends \Codeception\TestCase\Test
* - checkCSRF()
*/
}
public function testRecurciveExposureCheck()
{
/**
* TODO
*/
}
public function testChangeValueInUrl()
{
/**