ILIAS  release_7 Revision v7.30-3-g800a261c036
RandomTest.php File Reference

Go to the source code of this file.

Functions

 randomString ($length, $nullOk, $ascii=false)
 
 donorm ($str)
 
 wfMsg ($x)
 
 showDiffs ($a, $b)
 

Variables

 if (php_sapi_name() !='cli')
 
 $size = 16
 
 $n = 0
 

Function Documentation

◆ donorm()

donorm (   $str)

Definition at line 51 of file RandomTest.php.

52{
53 # We exclude a few chars that ICU would not.
54 $str = preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f]/', UTF8_REPLACEMENT, $str);
55 $str = str_replace(UTF8_FFFE, UTF8_REPLACEMENT, $str);
56 $str = str_replace(UTF8_FFFF, UTF8_REPLACEMENT, $str);
57
58 # UnicodeString constructor fails if the string ends with a head byte.
59 # Add a junk char at the end, we'll strip it off
60 return rtrim(utf8_normalize($str . "\x01", UNORM_NFC), "\x01");
61}
const UNORM_NFC
Definition: UtfNormal.php:93
const UTF8_FFFF
Definition: UtfNormal.php:81
const UTF8_FFFE
Definition: UtfNormal.php:80

References UNORM_NFC, UTF8_FFFE, and UTF8_FFFF.

◆ randomString()

randomString (   $length,
  $nullOk,
  $ascii = false 
)

Definition at line 41 of file RandomTest.php.

42{
43 $out = '';
44 for ($i = 0; $i < $length; $i++) {
45 $out .= chr(mt_rand($nullOk ? 0 : 1, $ascii ? 127 : 255));
46 }
47 return $out;
48}
$i
Definition: metadata.php:24

References $i, and $out.

◆ showDiffs()

showDiffs (   $a,
  $b 
)

Definition at line 68 of file RandomTest.php.

69{
70 $ota = explode("\n", str_replace("\r\n", "\n", $a));
71 $nta = explode("\n", str_replace("\r\n", "\n", $b));
72
73 $diffs = new Diff($ota, $nta);
74 $formatter = new TableDiffFormatter();
75 $funky = $formatter->format($diffs);
76 $matches = array();
77 preg_match_all('/<(?:ins|del) class="diffchange">(.*?)<\/(?:ins|del)>/', $funky, $matches);
78 foreach ($matches[1] as $bit) {
79 $hex = bin2hex($bit);
80 echo "\t$hex\n";
81 }
82}
83
84$size = 16;
85$n = 0;
86while (true) {
87 $n++;
88 echo "$n\n";
89
90 $str = randomString($size, true);
91 $clean = UtfNormal::cleanUp($str);
92 $norm = donorm($str);
93
94 echo strlen($clean) . ", " . strlen($norm);
95 if ($clean == $norm) {
96 echo " (match)\n";
97 } else {
98 echo " (FAIL)\n";
99 echo "\traw: " . bin2hex($str) . "\n" .
100 "\tphp: " . bin2hex($clean) . "\n" .
101 "\ticu: " . bin2hex($norm) . "\n";
102 echo "\n\tdiffs:\n";
103 showDiffs($clean, $norm);
104 die();
105 }
106
107
108 $str = '';
109 $clean = '';
110 $norm = '';
111}
$n
Definition: RandomTest.php:85
donorm($str)
Definition: RandomTest.php:51
randomString($length, $nullOk, $ascii=false)
Definition: RandomTest.php:41
showDiffs($a, $b)
Definition: RandomTest.php:68
$size
Definition: RandomTest.php:84
static cleanUp($string)
The ultimate convenience function! Clean up invalid UTF-8 sequences, and convert to normal form C,...
Definition: UtfNormal.php:127
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

◆ wfMsg()

wfMsg (   $x)

Definition at line 63 of file RandomTest.php.

64{
65 return $x;
66}

Referenced by DifferenceEngine\loadRevisionData(), DifferenceEngine\renderNewRevision(), DifferenceEngine\showDiff(), DifferenceEngine\showDiffPage(), and DifferenceEngine\showFirstRevision().

+ Here is the caller graph for this function:

Variable Documentation

◆ $n

$n = 0

Definition at line 85 of file RandomTest.php.

Referenced by ilPersonalSkillExplorerGUI\__construct(), ilSurveySkillExplorer\__construct(), _DiffEngine\_diag(), Text_Diff_Engine_native\_diag(), ilExternalFeed\_getRSSLocation(), wsdl\addComplexType(), wsdl\addOperation(), ilPCParagraph\autoSplit(), ilPersonalSkillExplorerGUI\buildSelectableTree(), nusoap_parser\buildVal(), ilvCard\buildVCard(), ilObjLanguage\check(), ilObjSCORM2004LearningModuleGUI\collapseAll(), ilObjSkillManagementGUI\collapseAll(), ilSCORM13Package\dbImportSco(), ilNewsItem\deleteNewsOfContext(), ilSurveySkill\determineMaxScale(), Securimage\drawLines(), ilObjSCORM2004LearningModuleGUI\expandAll(), ilObjSkillManagementGUI\expandAll(), UtfNormal\fastCombiningSort(), UtfNormal\fastCompose(), UtfNormal\fastDecompose(), ILIAS\GlobalScreen\Scope\Notification\Collector\MainNotificationCollector\filterItemsByVisibilty(), ilSkillUsage\getAllUsagesInfoOfSubtrees(), ilAwarenessData\getData(), ilSkillDataSet\getDependencies(), ILIAS\UI\Implementation\Component\Symbol\Glyph\Renderer\getInnerGlyphHTML(), ilTestTaxonomyTree\getMaxOrderValueLength(), DifferenceEngine\getMultiNotice(), ilTestTaxonomyTree\getNodeOrderingPathString(), ilBlogNewsRendererGUI\getObjectLink(), ilForumNewsRendererGUI\getObjectLink(), ilLearningModuleNewsRendererGUI\getObjectLink(), ilWikiNewsRendererGUI\getObjectLink(), ilAwarenessData\getOnlineUserData(), ilTaxAssignInputGUI\getOptions(), ilMilestoneResponsiblesTableGUI\getParticipantsAndResponsibles(), nusoap_base\getPrefixFromNamespace(), ilRepositoryExplorerGUI\getTopNodeForRefId(), hexSequenceToUtf8(), ilSCORM13Package\il_import(), ilPCTable\importCellAttributes(), ilPCTable\importHtml(), ilPCTable\importRow(), ilPCTable\importTableAttributes(), ilObjUserFolderGUI\initUserRoleAssignmentForm(), ilPageObjectGUI\insertPageToc(), Title\isDeleted(), EvalMathStack\last(), ilMembershipCronNotificationsData\load(), ilMembershipCronNotificationsData\loadMissingNews(), Title\makeName(), ilPCSourceCode\modifyPageContentPostXsl(), ilDashboardGUI\multiarray_sort(), Title\nameOf(), ilObjFileImplementationLegacy\parseInfoParams(), ilStatistics\product_n(), ilStatistics\quantile(), UtfNormal\quickIsNFC(), UtfNormal\quickIsNFCVerify(), ilObjSCORM2004LearningModule\readObject(), ilObjSCORMLearningModule\readObject(), ilCalendarEntry\readResponsibleUsers(), WavFile\readWavHeader(), ilSCORM2004Page\removeInvalidLinks(), ilFileStandardDropzoneInputGUI\render(), ilNestedListInputGUI\render(), ilBookCronNotification\sendMails(), wsdl\serializeType(), phpCAS\setCacheTimesForAuthRecheck(), CAS_Client\setCacheTimesForAuthRecheck(), WavFile\setChannelMask(), ilObjSCORM2004LearningModuleGUI\showTree(), ilRepositoryGUI\showTree(), ilStatistics\sum_n(), and ilObjUserTest\testCreateSetLookupDelete().

◆ $size

$size = 16

Definition at line 84 of file RandomTest.php.

Referenced by ilObjectXMLWriter\__appendObjectProperties(), ilObjectFeedWriter\__construct(), ILIAS\FileUpload\DTO\Metadata\__construct(), ilObjMediaObject\_determineWidthHeight(), ilObjMediaObjectGUI\_getMediaInfoHTML(), ilObjMediaCastAccess\_lookupDiskUsage(), ilObjForumAccess\_lookupDiskUsage(), ilFileDataMail\_lookupDiskUsageOfUser(), ilObjFileAccess\_lookupFileSize(), ilObjFileAccess\_lookupFileSizeFromFilesystem(), ilObjMediaObject\_saveTempFileAsMediaObject(), ilMediaItem\addAreaToMapWorkCopy(), ilADTTextFormBridge\addElementToForm(), ilPageObject\addFileSizes(), ilCloudFileTree\addIdBasedNode(), ilCloudFileTree\addNode(), ilUserAvatarFactory\avatar(), ilObjContainerDAV\createFile(), ILIAS\Data\Factory\dataSize(), ILIAS\FileDelivery\FileDeliveryTypes\PHPChunked\deliver(), ilUtil\dirsize(), Securimage\drawNoise(), ilObjExternalToolsSettingsGUI\editMathJaxObject(), ilUserAvatarFactory\file(), ilMediaCastTableGUI\fillRow(), ilMediaPoolTableGUI\fillRow(), ilClipboardTableGUI\fillRow(), ilUtil\formatBytes(), ilUtil\formatSize(), ilUtil\formSelect(), ilMathJax\getCacheSize(), ilUpdateUtilsMailMigration\getDir(), ilUpdateUtils\getDir(), ilUtil\getDir(), ILIAS\ResourceStorage\AbstractBaseTest\getDummyUploadResult(), ilObjMediaObjectGUI\getFullscreenSizeObject(), ilPreview\getImages(), ilMediaImageUtil\getImageSize(), ilUtil\getImageTagByType(), assFileUpload\getMaxFilesizeAsString(), ilMediaItem\getOriginalSize(), ilObjContentObject\getPublicExportFiles(), ilChatroomAuthInputGUI\getSize(), ilMDTechnical\getSize(), ilMD5295Technical\getSize(), ILIAS\Filesystem\Provider\FlySystem\FlySystemFileAccess\getSize(), ilObjMediaObjectGUI\getStandardSizeObject(), ilObjFileDAV\handleFileUpload(), ilWkhtmlToPdfConfigFormGUI\isNotValidSize(), ilMediaAliasItem\makeMapWorkCopy(), ilMediaItem\makeMapWorkCopy(), ilObjMediaObject\makeThumbnail(), ilObjMediaPoolSubItemListGUI\parseImage(), ilUtil\rangeDownload(), ilObjSurvey\removeQuestions(), ilUtil\resizeImage(), assClozeTest\setGapSize(), ilChatroomAuthInputGUI\setSize(), ilPCInteractiveImage\setTriggerPopupSize(), ilGlossaryPresentationGUI\showDownloadList(), ilMailFormGUI\showForm(), ILIAS\Filesystem\Finder\Finder\size(), ilExSubmissionObjectGUI\submitBlog(), ilExSubmissionObjectGUI\submitPortfolio(), ilExAssTypeWikiTeam\submitWiki(), ILIAS\Filesystem\Provider\FlySystem\FlySystemFileAccessTest\testGetSizeWhichShouldSucceed(), ILIAS\Filesystem\Stream\StreamTest\testGetSizeWithDetachedStreamWhichShouldFail(), ILIAS\Filesystem\Stream\StreamTest\testGetSizeWithOptionsWhichShouldSucceed(), ILIAS\Filesystem\Stream\StreamTest\testGetSizeWithStatsWhichShouldSucceed(), ilFSStorageExercise\uploadAssignmentFiles(), ilFSWebStorageExercise\uploadAssignmentFiles(), ilFSStorageExercise5069\uploadAssignmentFiles(), ilPCInteractiveImageGUI\uploadOverlayImages(), and ILIAS\UI\Implementation\Component\ViewControl\Pagination\withPageSize().

◆ if

if(php_sapi_name() !='cli') ( php_sapi_name() !  = 'cli')

Definition at line 29 of file RandomTest.php.