Update to Smarty 5.7.0

Fix tests for translations, where missing in the po/mo files
Add original and post translation for compare for outside and inside smarty translation

Update documentation and only keep the git update path, the others are deprecated

Update phpunit to v11 and update tests according to this, including updated test template data file

Add the tools folder to git ignore
This commit is contained in:
2026-01-07 10:06:39 +09:00
parent 2287af625b
commit 856a88d891
26 changed files with 585 additions and 367 deletions

View File

@@ -5,22 +5,26 @@ declare(strict_types=1);
namespace tests;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\Attributes\CoversClass;
/**
* Test class for Smarty
* @coversDefaultClass \Smarty
* @testdox \Smarty method tests for extended smarty plugins
*/
#[TestDox("\Smarty method tests for extended smarty plugins")]
#[CoversClass(\Smarty\Smarty::class)]
final class SmartyExtendedTest extends TestCase
{
/**
* Undocumented function
*
* @testdox Output\Form\Elements Class tests
*
* @return void
*/
public function testSmartyExtended()
#[Test]
#[TestDox("Test Smarty Extended rendering")]
public function testSmartyExtended(): void
{
define('BASE', str_replace('/configs', '', __DIR__) . DIRECTORY_SEPARATOR);
$locale = 'ja_JP.UTF-8';
@@ -49,6 +53,8 @@ final class SmartyExtendedTest extends TestCase
'HTML_TITLE' => 'Smarty v5 tst',
// smarty test
'SMARTY_TEST' => 'Test Data',
'TRANSLATED_ORIGINAL' => 'Are we translated?',
'TRANSLATED_REPLACED' => 'Yes, we are translated!',
'TRANSLATE_TEST' => $l10n->__('Are we translated?'),
'TRANSLATE_TEST_FUNCTION' => _gettext('Are we translated?'),
'TRANSLATE_TEST_SMARTY' => $l10n->__('Are we translated?'),
@@ -153,13 +159,16 @@ final class SmartyExtendedTest extends TestCase
</div>
<div>
<b>Outside translation test</b><br>
TRANSLATION CLASS (OUT): Are we translated?<br>
TRANSLATION CLASS (OUT FUNCTION): Are we translated?<br>
TRANSLATION CLASS (SMARTY): Are we translated?<br>
TRANSLATED ORIGINAL: Are we translated?<br>
TRANSLATED REPLACED: Yes, we are translated!<br>
TRANSLATION CLASS (OUT): Yes, we are translated!<br>
TRANSLATION CLASS (OUT FUNCTION): Yes, we are translated!<br>
TRANSLATION CLASS (SMARTY): Yes, we are translated!<br>
</div>
<div>
<b>Translate Test with replace:</b><br>
ORIGINAL: Original with string: %1 (Replaced)<br>
TRANSLATED: Translated with string: %1 (Replaced)<br>
TRANSLATED: Translated with string: Replaced<br>
TRANSLATED (escape): Translated with string: on<br>
Capture test: INPUT TEST<br>
@@ -196,6 +205,9 @@ final class SmartyExtendedTest extends TestCase
<div>LOOP OUTPUT: 4</div>
<div>LOOP OUTPUT: 5</div>
</div>
<div>
Drop Down simple
</div>
<div>
<select id="drop_down_test" name="drop_down_test">
<option label="Foo" value="foo">Foo</option>
@@ -204,6 +216,9 @@ final class SmartyExtendedTest extends TestCase
</select>
</div>
<div>
Drop Down nested
</div>
<div>
<select id="drop_down_test_nested" name="drop_down_test_nested">
<option label="選択してください" value="" selected="selected">選択してください</option>
@@ -222,19 +237,28 @@ final class SmartyExtendedTest extends TestCase
</select>
</div>
<div>
radio plain
</div>
<div>
<label><input type="radio" name="radio_test" value="0" />On</label>
<label><input type="radio" name="radio_test" value="1" />Off</label>
<label><input type="radio" name="radio_test" value="-1" checked="checked" />Undefined</label>
</div>
<div>
checkbox plain
</div>
<div>
<label><input type="checkbox" name="checkbox_test[]" value="0" />On</label>
<label><input type="checkbox" name="checkbox_test[]" value="1" checked="checked" />Off</label>
<label><input type="checkbox" name="checkbox_test[]" value="-1" checked="checked" />Undefined</label>
</div>
<div>
<label><input type="checkbox" name="checkbox_test_pos[]" value="0" checked="checked" />On</label>
<label><input type="checkbox" name="checkbox_test_pos[]" value="1" />Off</label>
checkbox pos
</div>
<div>
<label><input type="checkbox" name="checkbox_test_pos[A]" value="0" checked="checked" />On</label>
<label><input type="checkbox" name="checkbox_test_pos[B]" value="1" />Off</label>
<label><input type="checkbox" name="checkbox_test_pos[]" value="-1" checked="checked" />Undefined</label>
</div>
<div>

View File

@@ -23,5 +23,8 @@ msgstr "Translated"
msgid "Original with string: %1"
msgstr "Translated with string: %1"
msgid "Are we translated?"
msgstr "Yes, we are translated!"
#msgid ""
#msgstr ""

View File

@@ -26,6 +26,8 @@ BASE: {$BASE}<br>
</div>
<div>
<b>Outside translation test</b><br>
TRANSLATED ORIGINAL: {$TRANSLATED_ORIGINAL}<br>
TRANSLATED REPLACED: {$TRANSLATED_REPLACED}<br>
TRANSLATION CLASS (OUT): {$TRANSLATE_TEST}<br>
TRANSLATION CLASS (OUT FUNCTION): {$TRANSLATE_TEST_FUNCTION}<br>
TRANSLATION CLASS (SMARTY): {$TRANSLATE_TEST_SMARTY}<br>
@@ -33,6 +35,7 @@ BASE: {$BASE}<br>
<div>
<b>Translate Test with replace:</b><br>
ORIGINAL: Original with string: %1 ({$replace})<br>
TRANSLATED: Translated with string: %1 ({$replace})<br>
TRANSLATED: {t 1=$replace}Original with string: %1{/t}<br>
TRANSLATED (escape): {t escape=on 1=$replace}Original with string: %1{/t}<br>
{capture assign="extra_title"}{t}INPUT TEST{/t}{/capture}

View File

@@ -18,6 +18,8 @@ BASE: {$BASE}<br>
</div>
<div>
<b>Outside translation test</b><br>
TRANSLATED ORIGINAL: {$TRANSLATED_ORIGINAL}<br>
TRANSLATED REPLACED: {$TRANSLATED_REPLACED}<br>
TRANSLATION CLASS (OUT): {$TRANSLATE_TEST}<br>
TRANSLATION CLASS (OUT FUNCTION): {$TRANSLATE_TEST_FUNCTION}<br>
TRANSLATION CLASS (SMARTY): {$TRANSLATE_TEST_SMARTY}<br>
@@ -25,6 +27,7 @@ BASE: {$BASE}<br>
<div>
<b>Translate Test with replace:</b><br>
ORIGINAL: Original with string: %1 ({$replace})<br>
TRANSLATED: Translated with string: %1 ({$replace})<br>
TRANSLATED: {t 1=$replace}Original with string: %1{/t}<br>
TRANSLATED (escape): {t escape=on 1=$replace}Original with string: %1{/t}<br>
{capture assign="extra_title"}{t}INPUT TEST{/t}{/capture}

View File

@@ -74,6 +74,8 @@ $CONTENT_DATA = [
'HTML_TITLE' => 'Smarty v5 tst',
// smarty test
'SMARTY_TEST' => 'Test Data',
'TRANSLATED_ORIGINAL' => 'Are we translated?',
'TRANSLATED_REPLACED' => 'Yes, we are translated!',
'TRANSLATE_TEST' => $l10n->__('Are we translated?'),
'TRANSLATE_TEST_FUNCTION' => _gettext('Are we translated?'),
'TRANSLATE_TEST_SMARTY' => $l10n->__('Are we translated?'),