mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
125 lines
4.9 KiB
PHP
125 lines
4.9 KiB
PHP
<script src="../assets/config/config.js"></script>
|
|
<script src="../assets/core/core.js"></script>
|
|
<script src="../assets/core/core.register.js"></script>
|
|
|
|
<div style="display: flex; flex-direction: column; align-items: center;">
|
|
<script>
|
|
var iframeList = [], iframe;
|
|
</script>
|
|
<?php
|
|
$arFilesItems = glob(__DIR__ . '/*Test.php');
|
|
foreach ($arFilesItems as $file) {
|
|
$file = basename($file);
|
|
$clName = substr($file, 0, -8);
|
|
//echo "<a href=\"$file\"><b>$clName</b></a>";
|
|
?>
|
|
<script>
|
|
iframe = document.createElement("frame");
|
|
iframe.src = '<?=$file?>';
|
|
iframeList.push({
|
|
fileName: '<?=$file?>',
|
|
clName: '<?=$clName?>',
|
|
iframe: iframe,
|
|
});
|
|
</script>
|
|
<?
|
|
}
|
|
?>
|
|
</div>
|
|
<div class="kit-wrapper">
|
|
<div class="kit-logger"></div>
|
|
</div>
|
|
<script>
|
|
kit.ready(['Collection', 'flexKit', 'log', 'support'], function () {
|
|
|
|
var support = kit.support;
|
|
window.frameList = new kit.Collection(iframeList);
|
|
|
|
frameList.map(function (frameData) {
|
|
kit.service.logger.notice('<a href="'+frameData.fileName+'">'+frameData.clName+'</a>');
|
|
});
|
|
|
|
kit.service.logger.notice(' ');
|
|
kit.service.logger.warning('FRAME LIST <span id="total-unit-testing-counter">...<span>');
|
|
kit.service.logger.notice(' ');
|
|
|
|
var totalCountTest = 0;
|
|
var totalCountTestNode = document.getElementById('total-unit-testing-counter');
|
|
//console.log(frameList);
|
|
frameList.map(function (data) {
|
|
data.iframe.onload = function() {
|
|
data.window = data.iframe.contentWindow;
|
|
data.document = data.iframe.contentWindow.document;
|
|
data.kit = data.window.kit;
|
|
if(!data.kit) {
|
|
return;
|
|
}
|
|
data.kit.ready([], function () {
|
|
setTimeout(function () {
|
|
var result = {};
|
|
var countTest = 0;
|
|
if(!data.kit.service.logger){
|
|
return;
|
|
}
|
|
|
|
function pushResult(log){
|
|
var acceptKeys = new kit.Collection(['fail', 'warn', 'pass']);
|
|
acceptKeys.each(function (key) {
|
|
if(!result.hasOwnProperty(key)) {
|
|
result[key] = new kit.Collection();
|
|
}
|
|
if(!support.isObject(log.message)) {
|
|
return;
|
|
}
|
|
if(log.message.hasOwnProperty(key)) {
|
|
result[key].push(log);
|
|
countTest++;
|
|
totalCountTest++;
|
|
if(totalCountTestNode) {
|
|
totalCountTestNode.innerHTML = totalCountTest.toString();
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
data.kit.service.logger.collection.map(function (log) {
|
|
pushResult(log);
|
|
});
|
|
|
|
|
|
kit.service.logger.info(data.clName);
|
|
|
|
if(result.pass.count()){
|
|
kit.service.logger.success({
|
|
pass: result.pass.count(),
|
|
});
|
|
}
|
|
if(result.warn.count()) {
|
|
kit.service.logger.warning({
|
|
warn: result.warn.count(),
|
|
}, result.warn.map(function (log) {
|
|
return {
|
|
expected: log.context.expected,
|
|
actual: log.context.actual,
|
|
message: log.message.warn,
|
|
};
|
|
}).toObject());
|
|
}
|
|
if(result.fail.count()) {
|
|
kit.service.logger.error({
|
|
fail: result.fail.count(),
|
|
}, result.fail.map(function (log) {
|
|
return {
|
|
expected: log.context.expected,
|
|
actual: log.context.actual,
|
|
message: log.message.fail,
|
|
};
|
|
}).toObject());
|
|
}
|
|
}, 1000);
|
|
});
|
|
};
|
|
document.body.appendChild(data.iframe);
|
|
})
|
|
});
|
|
</script>
|