composer test update
This commit is contained in:
@@ -143,6 +143,26 @@ print "DATE-dow[$date];invalid: " . DateTime::setWeekdayNameFromDate($date) . "<
|
||||
print "DATE-dow[$date],long;invalid: " . DateTime::setWeekdayNameFromDate($date, true) . "<br>";
|
||||
print "DOW-date[$date];invalid: " . DateTime::setWeekdayNumberFromDate($date) . "<br>";
|
||||
|
||||
// check date range includes a weekend
|
||||
// does not:
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-05';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-10';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-03';
|
||||
$end_date = '2023-07-31';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
$start_date = '2023-07-01';
|
||||
$end_date = '2023-07-03';
|
||||
print "Has Weekend: " . $start_date . " ~ " . $end_date . ": "
|
||||
. Dgs::prBl(DateTime::dateRangeHasWeekend($start_date, $end_date)) . "<br>";
|
||||
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
|
||||
83
www/admin/class_test.html_build.block.php
Normal file
83
www/admin/class_test.html_build.block.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build-block';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\Block;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: BLOCK';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$el = Block::cel('div', 'el-1', 'Content', ['red'], ['onClick' => 'javascript:alert(\'JS alert\');']);
|
||||
|
||||
print "<pre>" . htmlentities(Block::buildHtml($el)) . "</pre>";
|
||||
|
||||
$el_a = Block::cel('div', 'u-id', '', ['base', 'cool']);
|
||||
$el_a_1 = Block::cel('span', 's-id-1', 'Span A', ['bold']);
|
||||
$el_a_2 = Block::cel('span', 's-id-2', 'Span B');
|
||||
$el_a_3 = Block::cel('a', 'link-a', 'Title', ['l-highlight'], ['OnClick' => 'Foo();']);
|
||||
$el_a_2 = Block::aelx($el_a_2, $el_a_3);
|
||||
// css changes before added to array
|
||||
$el_a_1 = Block::acssel($el_a_1, 'italic', 'green', 'italic', 'font-large');
|
||||
$el_a_1 = Block::rcssel($el_a_1, 'green');
|
||||
// switch
|
||||
$el_a_1 = Block::scssel($el_a_1, ['one', 'two', 'three'], ['three']);
|
||||
// this will add el_a_2 to the el_a block
|
||||
$el_a_1 = Block::aelx($el_a_1, $el_a_2);
|
||||
$el_a = Block::aelx($el_a, $el_a_1, $el_a_2);
|
||||
|
||||
// this will not update el_a
|
||||
// $el_a_1 = Block::aelx($el_a_1, $el_a_2);
|
||||
|
||||
$el_a_list = [];
|
||||
$el_a_list[] = Block::cel('foo', 'foo-A');
|
||||
$el_a_list[] = Block::cel('bar', 'foo-B');
|
||||
$el_a_list[] = Block::cel('baz', 'foo-C');
|
||||
$el_a_list[] = Block::cel('br');
|
||||
$el_a_list[] = Block::cel('input');
|
||||
|
||||
echo "<hr>";
|
||||
print "EL_A: <pre>" . print_r($el_a, true) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
print "phfo(\$el_o): <pre>" . htmlentities(Block::buildHtml($el_a, true)) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfa(\$el_list): <pre>" . htmlentities(Block::buildHtmlFromList($el_a_list, true)) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
// self loop test (will not trigger, are arrays)
|
||||
$el_s = Block::cel('div', 'id-s', 'Self', []);
|
||||
$el_s = Block::aelx($el_s, $el_s);
|
||||
|
||||
print "phfo(\$el_): <pre>" . htmlentities(Block::buildHtml($el_s, true)) . "</pre>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
142
www/admin/class_test.html_build.element.php
Normal file
142
www/admin/class_test.html_build.element.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\Element;
|
||||
use CoreLibs\Template\HtmlBuilder\General\Error;
|
||||
use CoreLibs\Template\HtmlBuilder\General\HtmlBuilderExcpetion;
|
||||
use CoreLibs\Debug\Support;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$el = new Element('div', 'el-1', 'Content', ['red'], ['onClick' => 'javascript:alert(\'JS alert\');']);
|
||||
|
||||
print "<pre>" . htmlentities($el->buildHtml()) . "</pre>";
|
||||
|
||||
$el_o = new Element('div', 'u-id', '', ['base', 'cool']);
|
||||
$el_o_1 = new Element('span', 's-id-1', 'Span A', ['bold']);
|
||||
$el_o_2 = new Element('span', 's-id-2', 'Span B');
|
||||
$el_o_3 = new Element('a', 'link-a', 'Title', ['l-highlight'], ['OnClick' => 'Foo();']);
|
||||
$el_o_2->addSub($el_o_3);
|
||||
$el_o->addSub($el_o_1, $el_o_2);
|
||||
|
||||
$el_o_1->addCss('italic', 'green', 'italic', 'font-large')
|
||||
->removeCss('green');
|
||||
|
||||
$el_o_2->addCss('wrong-css')
|
||||
->removeCss('wrong-css', 'correct-css');
|
||||
$el_o_2->addCss('a', 'b')->removeCss('correct-css');
|
||||
|
||||
$el_o_1->addSub($el_o_2);
|
||||
|
||||
// var_dump($el2);
|
||||
|
||||
$el_o_list = [];
|
||||
$el_o_list[] = new Element('foo', 'foo-A');
|
||||
$el_o_list[] = new Element('bar', 'foo-B');
|
||||
$el_o_list[] = new Element('baz', 'foo-C');
|
||||
$el_o_list[] = new Element('br');
|
||||
$el_o_list[] = new Element('input', 'tag', '', [], ['name' => 'foo', 'value' => 'ABC']);
|
||||
|
||||
// $el2->resetSub();
|
||||
// var_dump($el2);
|
||||
echo "<hr>";
|
||||
print "EL_O: <pre>" . print_r($el_o, true) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
print "buildHtml(): <pre>" . htmlentities($el_o->buildHtml()) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfo(\$el_o): <pre>" . htmlentities($el_o::printHtmlFromObject($el_o, true)) . "</pre>";
|
||||
echo "<hr>";
|
||||
print "phfa(\$el_list): <pre>" . htmlentities($el_o::buildHtmlFromList($el_o_list, true)) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
|
||||
// self loop
|
||||
|
||||
$el_s = new Element('div', 'id-s', 'Self');
|
||||
try {
|
||||
$el_s->addSub($el_s, new Element('span', '', 'Span'));
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
}
|
||||
|
||||
// var_dump($el_s);
|
||||
print "el_s, buildHtml(): <pre>" . htmlentities($el_s->buildHtml()) . "</pre>";
|
||||
|
||||
$el_s_2 = new Element('div', 'id-s', 'Self', []);
|
||||
$el_s_2->addSub(
|
||||
new Element('span', 's-1', 's 1'),
|
||||
new Element('span', 's-2', 's 2'),
|
||||
);
|
||||
|
||||
$el_s_3 = new Element('div', 'id-3', 'ID 3');
|
||||
try {
|
||||
$el_s_3->addSub($el_s_2);
|
||||
$el_s_2->addSub($el_s_2);
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
}
|
||||
|
||||
// print "<pre>" . var_export($el_s_3, true) . "</pre>";
|
||||
|
||||
print "el_s_3, buildHtml(): <pre>" . htmlentities($el_s_3->buildHtml()) . "</pre>";
|
||||
|
||||
echo "<hr>";
|
||||
Error::resetMessages();
|
||||
try {
|
||||
$el_er = new Element('');
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
if ($e->getPrevious() !== null) {
|
||||
print "E: " . $e->getPrevious()->getMessage() . " | " . $e->getPrevious()->getTraceAsString() . "<br>";
|
||||
}
|
||||
}
|
||||
print "Errors: <pre>" . print_r(Error::getMessages(), true) . "</pre>";
|
||||
print "Warning: " . Support::printToString(Error::hasWarning()) . "<br>";
|
||||
print "Error: " . Support::printToString(Error::hasError()) . "<br>";
|
||||
Error::resetMessages();
|
||||
try {
|
||||
$el_er = new Element('123123');
|
||||
} catch (HtmlBuilderExcpetion $e) {
|
||||
print "E: " . $e->getMessage() . " | " . $e->getTraceAsString() . "<br>";
|
||||
if ($e->getPrevious() !== null) {
|
||||
print "E: " . $e->getPrevious()->getMessage() . " | " . $e->getPrevious()->getTraceAsString() . "<br>";
|
||||
}
|
||||
}
|
||||
print "Errors: <pre>" . print_r(Error::getMessages(), true) . "</pre>";
|
||||
print "Warning: " . Support::printToString(Error::hasWarning()) . "<br>";
|
||||
print "Error: " . Support::printToString(Error::hasError()) . "<br>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
83
www/admin/class_test.html_build.replace.php
Normal file
83
www/admin/class_test.html_build.replace.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php // phpcs:ignore warning
|
||||
|
||||
/**
|
||||
* @phan-file-suppress PhanTypeSuspiciousStringExpression
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
|
||||
|
||||
ob_start();
|
||||
|
||||
// basic class test file
|
||||
define('USE_DATABASE', false);
|
||||
// sample config
|
||||
require 'config.php';
|
||||
// define log file id
|
||||
$LOG_FILE_ID = 'classTest-html_build-string-replace';
|
||||
ob_end_flush();
|
||||
|
||||
use CoreLibs\Template\HtmlBuilder\StringReplace;
|
||||
|
||||
$log = new CoreLibs\Logging\Logging([
|
||||
'log_folder' => BASE . LOG,
|
||||
'log_file_id' => $LOG_FILE_ID,
|
||||
'log_per_date' => true,
|
||||
]);
|
||||
|
||||
// define a list of from to color sets for conversion test
|
||||
|
||||
$PAGE_NAME = 'TEST CLASS: HTML BUILD: STRING REPLACE';
|
||||
print "<!DOCTYPE html>";
|
||||
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
|
||||
print "<body>";
|
||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||
|
||||
$html_block = <<<HTML
|
||||
<div id="{ID}" class="{CSS}">
|
||||
{CONTENT}
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
print "<pre>" . htmlentities(StringReplace::replaceData(
|
||||
$html_block,
|
||||
[
|
||||
'ID' => 'block-id',
|
||||
'CSS' => join(',', ['blue', 'red']),
|
||||
'{CONTENT}' => 'Some content here<br>with bla bla inside'
|
||||
]
|
||||
)) . "</pre>";
|
||||
|
||||
StringReplace::loadElements(
|
||||
['foo', $html_block],
|
||||
['bar', <<<HTML
|
||||
<span id="{ID}">{CONTENT}</span>
|
||||
HTML]
|
||||
);
|
||||
|
||||
print "Get: <pre>" . htmlentities(StringReplace::getElement('bar') ?: '') . '</pre>';
|
||||
|
||||
print "Build element: <pre>" . htmlentities(StringReplace::buildElement(
|
||||
'bar',
|
||||
[
|
||||
'ID}' => 'new-id',
|
||||
'{CONTENT' => 'Test cow 日本語'
|
||||
]
|
||||
)) . '</pre>' ;
|
||||
|
||||
print "Build element as replace: <pre>" . htmlentities(StringReplace::buildElement(
|
||||
'bar',
|
||||
['
|
||||
ID}' => 'diff-id',
|
||||
'{CONTENT' => 'Test cow 日本語. More text plus'
|
||||
],
|
||||
'rpl-1'
|
||||
)) . '</pre>' ;
|
||||
|
||||
print "Get replacement: <pre>" . htmlentities(StringReplace::getReplaceBlock('rpl-1')) . "</pre>";
|
||||
|
||||
print "</body></html>";
|
||||
|
||||
// __END__
|
||||
@@ -81,6 +81,9 @@ $test_files = [
|
||||
'class_test.encryption.php' => 'Class Test: ENCRYPTION',
|
||||
'class_test.math.php' => 'Class Test: MATH',
|
||||
'class_test.html.php' => 'Class Test: HTML/ELEMENTS',
|
||||
'class_test.html_build.element.php' => 'Class Test: HTML BUILDER: ELEMENT',
|
||||
'class_test.html_build.block.php' => 'Class Test: HTML BUILDER: BLOCK',
|
||||
'class_test.html_build.replace.php' => 'Class Test: HTML BUILDER: STRING REPLACE',
|
||||
'class_test.email.php' => 'Class Test: EMAIL',
|
||||
'class_test.create_email.php' => 'Class Test: CREATE EMAIL',
|
||||
'class_test.uids.php' => 'Class Test: UIDS',
|
||||
|
||||
Reference in New Issue
Block a user