This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
918c9dc
commit b46760f
Showing
2 changed files
with
39 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,28 @@ public static function setUpBeforeClass(): void | |
$userRecordModel->set('hour_format', '24'); | ||
$userRecordModel->set('time_zone', \App\Fields\DateTime::getTimeZone()); | ||
$userRecordModel->save(); | ||
\date_default_timezone_set(\App\Fields\DateTime::getTimeZone()); | ||
date_default_timezone_set(\App\Fields\DateTime::getTimeZone()); | ||
} | ||
|
||
/** | ||
* Restore current user preferences. | ||
* | ||
* @throws \Exception | ||
*/ | ||
public static function tearDownAfterClass(): void | ||
{ | ||
$userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users'); | ||
$userModel->set('currency_decimal_separator', self::$separatorDecimal); | ||
$userModel->set('currency_grouping_separator', self::$separatorGrouping); | ||
$userModel->set('currency_symbol_placement', self::$symbolPlacement); | ||
$userModel->set('currency_grouping_pattern', self::$patternGrouping); | ||
$userModel->set('no_of_currency_decimals', self::$decimalNum); | ||
$userModel->set('truncate_trailing_zeros', self::$truncateTrailingZeros); | ||
$userModel->set('hour_format', self::$hourFormat); | ||
$userModel->set('time_zone', self::$userTimeZone); | ||
$userModel->save(); | ||
date_default_timezone_set(self::$timeZone); | ||
parent::tearDownAfterClass(); | ||
} | ||
|
||
/** | ||
|
@@ -97,7 +118,7 @@ public static function setUpBeforeClass(): void | |
*/ | ||
public function dataProviderByType() | ||
{ | ||
//$type, $assertion, $expected, $text, $message, $exception | ||
// $type, $assertion, $expected, $text, $message, $exception | ||
return [ | ||
['Standard', 'Same', 'Test-text-string-for-purifier', 'Test-text-string-for-purifier', 'Sample text should be unchanged', null], | ||
['Standard', 'Same', ['Test-text-string-for-purifier', 'Test-text-string-for-purifier'], ['Test-text-string-for-purifier', 'Test-text-string-for-purifier'], 'Sample text should be unchanged(array)', null], | ||
|
@@ -108,8 +129,8 @@ public function dataProviderByType() | |
[2, 'NotSame', 'Test_text_alnum_4_purifier%$54#T$#BR-', 'Test_text_alnum_4_purifier%$54#T$#BR-', 'Sample text should be purified', \App\Exceptions\IllegalValue::class], | ||
['DateInUserFormat', 'Same', date('Y-m-d'), date('Y-m-d'), 'Sample text should be unchanged', null], | ||
['DateInUserFormat', 'NotSame', date('Y.m.d'), date('Y.m.d'), 'Sample text should be purified', \App\Exceptions\IllegalValue::class], | ||
['DateRangeUserFormat', 'Same', [date('Y-m-d'), date('Y-m-d', \strtotime('+1 day'))], date('Y-m-d') . ',' . date('Y-m-d', \strtotime('+1 day')), 'Sample text should be unchanged', null], | ||
['DateRangeUserFormat', 'NotSame', date('Y.m.d') . ',' . date('Y.m.d', \strtotime('+1 day')), date('Y.m.d') . ',' . date('Y.m.d', \strtotime('+1 day')), 'Sample text should be purified', \App\Exceptions\IllegalValue::class], | ||
['DateRangeUserFormat', 'Same', [date('Y-m-d'), date('Y-m-d', strtotime('+1 day'))], date('Y-m-d') . ',' . date('Y-m-d', strtotime('+1 day')), 'Sample text should be unchanged', null], | ||
['DateRangeUserFormat', 'NotSame', date('Y.m.d') . ',' . date('Y.m.d', strtotime('+1 day')), date('Y.m.d') . ',' . date('Y.m.d', strtotime('+1 day')), 'Sample text should be purified', \App\Exceptions\IllegalValue::class], | ||
['date', 'Same', date('Y-m-d'), date('Y-m-d'), 'Sample text should be unchanged', null], | ||
['date', 'NotSame', '201X-07-26', '201X-07-26', 'Sample text should be purified', \App\Exceptions\IllegalValue::class], | ||
['time', 'Same', date('H:i:s'), date('H:i:s'), 'Sample text should be unchanged', null], | ||
|
@@ -131,9 +152,9 @@ public function dataProviderByType() | |
['Text', 'NotSame', 'ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!) <svg/onabort=alert(3)// <svg/onload=alert(1) onfocus=alert(2)//', 'ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!) <svg/onabort=alert(3)// <svg/onload=alert(1) onfocus=alert(2)//', 'Sample number should be purified', \App\Exceptions\IllegalValue::class], | ||
['Default', 'Same', 'Test-text-string-for-purifier', 'Test-text-string-for-purifier', 'Sample number should be unchanged', null], | ||
['Default', 'NotSame', 'ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!) <svg/onabort=alert(3)// <svg/onload=alert(1) onfocus=alert(2)//', 'ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!) <svg/onabort=alert(3)// <svg/onload=alert(1) onfocus=alert(2)//', 'Sample number should be purified', \App\Exceptions\IllegalValue::class], | ||
['MailId', 'Same', '<[email protected]> (added by [email protected])', '<[email protected]> (added by [email protected])', 'Sample text should be unchanged', null], | ||
['MailId', 'Same', '<30.123.12.JavaMail."admin.azure"@A-PROXY01>', '<30.123.12.JavaMail."admin.azure"@A-PROXY01>', 'Sample text should be unchanged', null], | ||
['MailId', 'Same', '<[email protected]>', '<[email protected]>', 'Sample text should be unchanged', null], | ||
['MailId', 'Same', '[email protected]> (added by [email protected])', '<[email protected]> (added by [email protected])', 'Sample text should be unchanged', null], | ||
['MailId', 'Same', '30.123.12.JavaMail."admin.azure"@A-PROXY01', '<30.123.12.JavaMail."admin.azure"@A-PROXY01>', 'Sample text should be unchanged', null], | ||
['MailId', 'Same', '[email protected]', '<[email protected]>', 'Sample text should be unchanged', null], | ||
[\App\Purifier::PATH, 'NotSame', '../Test', '../Test', 'Path should be discarded', \App\Exceptions\IllegalValue::class], | ||
[\App\Purifier::PATH, 'Same', '/Test/test', '/Test/test', 'Path should be unchanged', null], | ||
]; | ||
|
@@ -246,7 +267,7 @@ public function purifyHtmlProviderSuccess(): array | |
['<div>Test-text-string-for-purifier</div>', '<div>Test-text-string-for-purifier</div>', true], | ||
['ę€ółśążźćń23{}":?>><>?:"{}+_)', 'ę€ółśążźćń23{}":?>><>?:"{}+_)', true], | ||
['ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!)', 'ę€ółśążźćń23{}":?>><>?:"{}+_)(*&^%$#@!)', true], | ||
[\file_get_contents(ROOT_DIRECTORY . '/tests/data/phpFile1.html'), \file_get_contents(ROOT_DIRECTORY . '/tests/data/phpFile2.html'), true], | ||
[file_get_contents(ROOT_DIRECTORY . '/tests/data/phpFile1.html'), file_get_contents(ROOT_DIRECTORY . '/tests/data/phpFile2.html'), true], | ||
['<p><yetiforce type="Documents" crm-id="70521" attachment-id="22855"></yetiforce></p>', '<p><yetiforce type="Documents" crm-id="70521" attachment-id="22855"></yetiforce></p>', true], | ||
]; | ||
} | ||
|
@@ -263,25 +284,4 @@ public function testPurifyHtmlSuccess(string $text, string $expected): void | |
{ | ||
$this->assertSame($expected, \App\Purifier::purifyHtml($text), 'Sample text should be unchanged'); | ||
} | ||
|
||
/** | ||
* Restore current user preferences. | ||
* | ||
* @throws \Exception | ||
*/ | ||
public static function tearDownAfterClass(): void | ||
{ | ||
$userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users'); | ||
$userModel->set('currency_decimal_separator', self::$separatorDecimal); | ||
$userModel->set('currency_grouping_separator', self::$separatorGrouping); | ||
$userModel->set('currency_symbol_placement', self::$symbolPlacement); | ||
$userModel->set('currency_grouping_pattern', self::$patternGrouping); | ||
$userModel->set('no_of_currency_decimals', self::$decimalNum); | ||
$userModel->set('truncate_trailing_zeros', self::$truncateTrailingZeros); | ||
$userModel->set('hour_format', self::$hourFormat); | ||
$userModel->set('time_zone', self::$userTimeZone); | ||
$userModel->save(); | ||
\date_default_timezone_set(self::$timeZone); | ||
parent::tearDownAfterClass(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters