diff --git a/ecrire/tests/Squelettes/Balise/FiltreTest.php b/ecrire/tests/Squelettes/Balise/FiltreTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4dceafb5e64fb9e973ca07b823bd43f2537ff912 --- /dev/null +++ b/ecrire/tests/Squelettes/Balise/FiltreTest.php @@ -0,0 +1,54 @@ +<?php + +declare(strict_types=1); + +namespace Spip\Test\Squelettes\Balise; + +use PHPUnit\Framework\Attributes\Depends; +use Spip\Test\SquelettesTestCase; +use Spip\Test\Template\Loader\StringLoader; +use Spip\Test\Templating; + +class FiltreTest extends SquelettesTestCase +{ + + public function testFiltre(): void { + $loader = new StringLoader([ + 'fonctions' => <<<PHP + function strip_non(string \$texte): string { + return str_replace('NON', '', \$texte); + } + + function strip_on(string \$texte): string { + return str_replace('ON', '', \$texte); + } + PHP, + 'apres_code' => <<<SPIP + [(#FILTRE{strip_non})] + [(#FILTRE{strip_on})] + SPIP, + ]); + $templating = new Templating($loader); + $this->assertOk($templating->render('NONONOK')); + } + + public function testFiltreNommageExplicite(): void { + $loader = new StringLoader([ + 'fonctions' => <<<PHP + function filtre_remove_non_dist(string \$texte): string { + return str_replace('NON', '', \$texte); + } + + function filtre_remove_on_dist(string \$texte): string { + return str_replace('ON', '', \$texte); + } + PHP, + 'apres_code' => <<<SPIP + [(#FILTRE{remove_non})] + [(#FILTRE{remove_on})] + SPIP, + ]); + $templating = new Templating($loader); + $this->assertOk($templating->render('NONONOK')); + } +} diff --git a/ecrire/tests/legacy/unit/balises/filtre.html b/ecrire/tests/legacy/unit/balises/filtre.html deleted file mode 100644 index 3cc020f1e2382a205eb43d0cffd621a8ff1a3aa5..0000000000000000000000000000000000000000 --- a/ecrire/tests/legacy/unit/balises/filtre.html +++ /dev/null @@ -1,10 +0,0 @@ -[(#REM) - - Squelette - (c) 2009 xxx - Distribue sous licence GPL - -] -NONONOK -#FILTRE{strip_non} -#FILTRE{strip_on} \ No newline at end of file diff --git a/ecrire/tests/legacy/unit/balises/filtre_fonctions.php b/ecrire/tests/legacy/unit/balises/filtre_fonctions.php deleted file mode 100644 index 6daf899504f44e0b934be9fc56721ba479163011..0000000000000000000000000000000000000000 --- a/ecrire/tests/legacy/unit/balises/filtre_fonctions.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -declare(strict_types=1); - -/* - * Plugin xxx - * (c) 2009 xxx - * Distribue sous licence GPL - * - */ - -function strip_non($texte) { - return str_replace('NON', '', $texte); -} - -function strip_on($texte) { - return str_replace('ON', '', $texte); -}