@@ -3,7 +3,7 @@ |
||
| 3 | 3 | declare(strict_types=1); |
| 4 | 4 | |
| 5 | 5 | function formulaires_test_dyn_lang_charger_dist($lang_skel) { |
| 6 | - return [ |
|
| 7 | - 'message_ok' => $lang_skel === $GLOBALS['spip_lang'] ? 'OK' : "NOK : La langue dans le squelette appelant est {$lang_skel} mais la langue dans charger() est " . $GLOBALS['spip_lang'], |
|
| 8 | - ]; |
|
| 6 | + return [ |
|
| 7 | + 'message_ok' => $lang_skel === $GLOBALS['spip_lang'] ? 'OK' : "NOK : La langue dans le squelette appelant est {$lang_skel} mais la langue dans charger() est " . $GLOBALS['spip_lang'], |
|
| 8 | + ]; |
|
| 9 | 9 | } |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | function formulaires_test_dyn_lang_charger_dist($lang_skel) { |
| 6 | 6 | return [ |
| 7 | - 'message_ok' => $lang_skel === $GLOBALS['spip_lang'] ? 'OK' : "NOK : La langue dans le squelette appelant est {$lang_skel} mais la langue dans charger() est " . $GLOBALS['spip_lang'], |
|
| 7 | + 'message_ok' => $lang_skel === $GLOBALS['spip_lang'] ? 'OK' : "NOK : La langue dans le squelette appelant est {$lang_skel} mais la langue dans charger() est ".$GLOBALS['spip_lang'], |
|
| 8 | 8 | ]; |
| 9 | 9 | } |
@@ -13,36 +13,36 @@ |
||
| 13 | 13 | \***************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 16 | - return; |
|
| 16 | + return; |
|
| 17 | 17 | } |
| 18 | 18 | #securite |
| 19 | 19 | |
| 20 | 20 | function balise_FORMULAIRE_TEST_PHRASEUR($p) { |
| 21 | - return calculer_balise_dynamique($p, 'FORMULAIRE_TEST_PHRASEUR', ['id_rubrique']); |
|
| 21 | + return calculer_balise_dynamique($p, 'FORMULAIRE_TEST_PHRASEUR', ['id_rubrique']); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function balise_FORMULAIRE_TEST_PHRASEUR_stat($args, $context_compil) { |
| 25 | - // le denier arg peut contenir l'url sur lequel faire le retour |
|
| 26 | - // exemple dans un squelette article.html : [(#FORMULAIRE_FORUM{#SELF})] |
|
| 25 | + // le denier arg peut contenir l'url sur lequel faire le retour |
|
| 26 | + // exemple dans un squelette article.html : [(#FORMULAIRE_FORUM{#SELF})] |
|
| 27 | 27 | |
| 28 | - // recuperer les donnees du forum auquel on repond. |
|
| 29 | - [$idr, $url] = $args; |
|
| 28 | + // recuperer les donnees du forum auquel on repond. |
|
| 29 | + [$idr, $url] = $args; |
|
| 30 | 30 | |
| 31 | - return [$idr, $url]; |
|
| 31 | + return [$idr, $url]; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function balise_FORMULAIRE_TEST_PHRASEUR_dyn($id_rubrique, $url) { |
| 35 | - $res = 'OK'; |
|
| 36 | - |
|
| 37 | - if (!preg_match('#^\d+$#', $id_rubrique)) { |
|
| 38 | - $res = 'Erreur id_rubrique non numerique : ' . var_export($id_rubrique, true); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - return [ |
|
| 42 | - 'formulaires/test_phraseur', |
|
| 43 | - 0, |
|
| 44 | - [ |
|
| 45 | - 'result' => $res, |
|
| 46 | - ], |
|
| 47 | - ]; |
|
| 35 | + $res = 'OK'; |
|
| 36 | + |
|
| 37 | + if (!preg_match('#^\d+$#', $id_rubrique)) { |
|
| 38 | + $res = 'Erreur id_rubrique non numerique : ' . var_export($id_rubrique, true); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + return [ |
|
| 42 | + 'formulaires/test_phraseur', |
|
| 43 | + 0, |
|
| 44 | + [ |
|
| 45 | + 'result' => $res, |
|
| 46 | + ], |
|
| 47 | + ]; |
|
| 48 | 48 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | $res = 'OK'; |
| 36 | 36 | |
| 37 | 37 | if (!preg_match('#^\d+$#', $id_rubrique)) { |
| 38 | - $res = 'Erreur id_rubrique non numerique : ' . var_export($id_rubrique, true); |
|
| 38 | + $res = 'Erreur id_rubrique non numerique : '.var_export($id_rubrique, true); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return [ |
@@ -10,37 +10,37 @@ |
||
| 10 | 10 | |
| 11 | 11 | class BaliseDetacheeTest extends SquelettesTestCase |
| 12 | 12 | { |
| 13 | - public function testNecessiteNomSite(): void { |
|
| 14 | - $this->assertNotEmptyCode('<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - #[Depends('testNecessiteNomSite')] |
|
| 18 | - public function testBaliseDetacheeInterne(): void { |
|
| 19 | - $templating = Templating::fromString(); |
|
| 20 | - $expected = $templating->render('<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 21 | - $actual = $templating->render( |
|
| 22 | - '<BOUCLE_meta(spip_meta){nom=nom_site}> |
|
| 13 | + public function testNecessiteNomSite(): void { |
|
| 14 | + $this->assertNotEmptyCode('<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + #[Depends('testNecessiteNomSite')] |
|
| 18 | + public function testBaliseDetacheeInterne(): void { |
|
| 19 | + $templating = Templating::fromString(); |
|
| 20 | + $expected = $templating->render('<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 21 | + $actual = $templating->render( |
|
| 22 | + '<BOUCLE_meta(spip_meta){nom=nom_site}> |
|
| 23 | 23 | <BOUCLE_meta2(spip_meta){nom=adresse_site}> |
| 24 | 24 | #_meta:VALEUR |
| 25 | 25 | </BOUCLE_meta2> |
| 26 | 26 | </BOUCLE_meta>' |
| 27 | - ); |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | - $this->assertEquals($expected, trim($actual)); |
|
| 30 | - } |
|
| 29 | + $this->assertEquals($expected, trim($actual)); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function testBaliseDetacheeHorsBoucle(): void { |
|
| 33 | - // en dehors de sa boucle, une balise detachee n'est pas reconnue |
|
| 34 | - $this->assertEmptyCode( |
|
| 35 | - '<BOUCLE_meta(spip_meta){nom=nom_site}></BOUCLE_meta> |
|
| 32 | + public function testBaliseDetacheeHorsBoucle(): void { |
|
| 33 | + // en dehors de sa boucle, une balise detachee n'est pas reconnue |
|
| 34 | + $this->assertEmptyCode( |
|
| 35 | + '<BOUCLE_meta(spip_meta){nom=nom_site}></BOUCLE_meta> |
|
| 36 | 36 | <BOUCLE_meta2(spip_meta){nom=version_base}>#_meta:VALEUR</BOUCLE_meta2>' |
| 37 | - ); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @depends testBaliseDetacheeInterne |
|
| 42 | - */ |
|
| 43 | - public function testBaliseDetacheeComplexe(): void { |
|
| 44 | - $this->assertOkSquelette(__DIR__ . '/data/balise_detachee.html'); |
|
| 45 | - } |
|
| 37 | + ); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @depends testBaliseDetacheeInterne |
|
| 42 | + */ |
|
| 43 | + public function testBaliseDetacheeComplexe(): void { |
|
| 44 | + $this->assertOkSquelette(__DIR__ . '/data/balise_detachee.html'); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -41,6 +41,6 @@ |
||
| 41 | 41 | * @depends testBaliseDetacheeInterne |
| 42 | 42 | */ |
| 43 | 43 | public function testBaliseDetacheeComplexe(): void { |
| 44 | - $this->assertOkSquelette(__DIR__ . '/data/balise_detachee.html'); |
|
| 44 | + $this->assertOkSquelette(__DIR__.'/data/balise_detachee.html'); |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -9,65 +9,65 @@ |
||
| 9 | 9 | |
| 10 | 10 | class InclureTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testInclureNormal(): void { |
|
| 13 | - $dir = $this->relativePath(__DIR__); |
|
| 14 | - $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>'); |
|
| 15 | - $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}/>'); |
|
| 16 | - } |
|
| 12 | + public function testInclureNormal(): void { |
|
| 13 | + $dir = $this->relativePath(__DIR__); |
|
| 14 | + $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>'); |
|
| 15 | + $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}/>'); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function testInclureDouble(): void { |
|
| 19 | - $dir = $this->relativePath(__DIR__); |
|
| 20 | - $this->assertEqualsCode( |
|
| 21 | - 'Hello WorldHello World', |
|
| 22 | - '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 23 | - . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 24 | - ); |
|
| 25 | - $this->assertEqualsCode( |
|
| 26 | - 'Hello WorldHello World', |
|
| 27 | - ' |
|
| 18 | + public function testInclureDouble(): void { |
|
| 19 | + $dir = $this->relativePath(__DIR__); |
|
| 20 | + $this->assertEqualsCode( |
|
| 21 | + 'Hello WorldHello World', |
|
| 22 | + '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 23 | + . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 24 | + ); |
|
| 25 | + $this->assertEqualsCode( |
|
| 26 | + 'Hello WorldHello World', |
|
| 27 | + ' |
|
| 28 | 28 | <INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
| 29 | - . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 30 | - ); |
|
| 31 | - } |
|
| 29 | + . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testInclureArray(): void { |
|
| 34 | - $dir = $this->relativePath(__DIR__); |
|
| 35 | - $array = '#LISTE{ |
|
| 33 | + public function testInclureArray(): void { |
|
| 34 | + $dir = $this->relativePath(__DIR__); |
|
| 35 | + $array = '#LISTE{ |
|
| 36 | 36 | ' . $dir . '/data/texte_hello_world, |
| 37 | 37 | ' . $dir . '/data/texte_hello_world, |
| 38 | 38 | ' . $dir . '/data/texte_hello_world}'; |
| 39 | - $this->assertEqualsCode('Hello WorldHello WorldHello World', "<INCLURE{fond={$array}}>"); |
|
| 40 | - } |
|
| 39 | + $this->assertEqualsCode('Hello WorldHello WorldHello World', "<INCLURE{fond={$array}}>"); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function testInclureOldParam(): void { |
|
| 43 | - $dir = $this->relativePath(__DIR__); |
|
| 44 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}>'); |
|
| 45 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}/>'); |
|
| 46 | - } |
|
| 42 | + public function testInclureOldParam(): void { |
|
| 43 | + $dir = $this->relativePath(__DIR__); |
|
| 44 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}>'); |
|
| 45 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}/>'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function testInclureNormalParam(): void { |
|
| 49 | - $dir = $this->relativePath(__DIR__); |
|
| 50 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}>'); |
|
| 51 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}/>'); |
|
| 52 | - } |
|
| 48 | + public function testInclureNormalParam(): void { |
|
| 49 | + $dir = $this->relativePath(__DIR__); |
|
| 50 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}>'); |
|
| 51 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}/>'); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function testInclureArrayParam(): void { |
|
| 55 | - $dir = $this->relativePath(__DIR__); |
|
| 56 | - $array = '#LISTE{ |
|
| 54 | + public function testInclureArrayParam(): void { |
|
| 55 | + $dir = $this->relativePath(__DIR__); |
|
| 56 | + $array = '#LISTE{ |
|
| 57 | 57 | ' . $dir . '/data/balise_env_test, |
| 58 | 58 | ' . $dir . '/data/texte_hello_world, |
| 59 | 59 | ' . $dir . '/data/balise_env_test}'; |
| 60 | - $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}>"); |
|
| 61 | - $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}/>"); |
|
| 62 | - } |
|
| 60 | + $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}>"); |
|
| 61 | + $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}/>"); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Un inclure manquant doit creer une erreur de compilation pour SPIP qui ne doivent pas s'afficher dans le public si |
|
| 66 | - * visiteur |
|
| 67 | - */ |
|
| 68 | - public function testInclureManquantGenereErreurCompilation(): void { |
|
| 69 | - $templating = Templating::fromString(); |
|
| 70 | - $infos = $templating->rawRender('<INCLURE{fond=carabistouille/de/tripoli/absente}/>ok'); |
|
| 71 | - $this->assertCount(1, $infos['erreurs']); |
|
| 72 | - } |
|
| 64 | + /** |
|
| 65 | + * Un inclure manquant doit creer une erreur de compilation pour SPIP qui ne doivent pas s'afficher dans le public si |
|
| 66 | + * visiteur |
|
| 67 | + */ |
|
| 68 | + public function testInclureManquantGenereErreurCompilation(): void { |
|
| 69 | + $templating = Templating::fromString(); |
|
| 70 | + $infos = $templating->rawRender('<INCLURE{fond=carabistouille/de/tripoli/absente}/>ok'); |
|
| 71 | + $this->assertCount(1, $infos['erreurs']); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -11,52 +11,52 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function testInclureNormal(): void { |
| 13 | 13 | $dir = $this->relativePath(__DIR__); |
| 14 | - $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>'); |
|
| 15 | - $this->assertEqualsCode('Hello World', '<INCLURE{fond=' . $dir . '/data/texte_hello_world}/>'); |
|
| 14 | + $this->assertEqualsCode('Hello World', '<INCLURE{fond='.$dir.'/data/texte_hello_world}>'); |
|
| 15 | + $this->assertEqualsCode('Hello World', '<INCLURE{fond='.$dir.'/data/texte_hello_world}/>'); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | public function testInclureDouble(): void { |
| 19 | 19 | $dir = $this->relativePath(__DIR__); |
| 20 | 20 | $this->assertEqualsCode( |
| 21 | 21 | 'Hello WorldHello World', |
| 22 | - '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 23 | - . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 22 | + '<INCLURE{fond='.$dir.'/data/texte_hello_world}>' |
|
| 23 | + . '<INCLURE{fond='.$dir.'/data/texte_hello_world}>' |
|
| 24 | 24 | ); |
| 25 | 25 | $this->assertEqualsCode( |
| 26 | 26 | 'Hello WorldHello World', |
| 27 | 27 | ' |
| 28 | - <INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 29 | - . '<INCLURE{fond=' . $dir . '/data/texte_hello_world}>' |
|
| 28 | + <INCLURE{fond=' . $dir.'/data/texte_hello_world}>' |
|
| 29 | + . '<INCLURE{fond='.$dir.'/data/texte_hello_world}>' |
|
| 30 | 30 | ); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function testInclureArray(): void { |
| 34 | 34 | $dir = $this->relativePath(__DIR__); |
| 35 | 35 | $array = '#LISTE{ |
| 36 | - ' . $dir . '/data/texte_hello_world, |
|
| 37 | - ' . $dir . '/data/texte_hello_world, |
|
| 38 | - ' . $dir . '/data/texte_hello_world}'; |
|
| 36 | + ' . $dir.'/data/texte_hello_world, |
|
| 37 | + ' . $dir.'/data/texte_hello_world, |
|
| 38 | + ' . $dir.'/data/texte_hello_world}'; |
|
| 39 | 39 | $this->assertEqualsCode('Hello WorldHello WorldHello World', "<INCLURE{fond={$array}}>"); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testInclureOldParam(): void { |
| 43 | 43 | $dir = $this->relativePath(__DIR__); |
| 44 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}>'); |
|
| 45 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test}{test=Kitty}/>'); |
|
| 44 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond='.$dir.'/data/balise_env_test}{test=Kitty}>'); |
|
| 45 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond='.$dir.'/data/balise_env_test}{test=Kitty}/>'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | public function testInclureNormalParam(): void { |
| 49 | 49 | $dir = $this->relativePath(__DIR__); |
| 50 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}>'); |
|
| 51 | - $this->assertEqualsCode('Kitty', '<INCLURE{fond=' . $dir . '/data/balise_env_test, test=Kitty}/>'); |
|
| 50 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond='.$dir.'/data/balise_env_test, test=Kitty}>'); |
|
| 51 | + $this->assertEqualsCode('Kitty', '<INCLURE{fond='.$dir.'/data/balise_env_test, test=Kitty}/>'); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function testInclureArrayParam(): void { |
| 55 | 55 | $dir = $this->relativePath(__DIR__); |
| 56 | 56 | $array = '#LISTE{ |
| 57 | - ' . $dir . '/data/balise_env_test, |
|
| 58 | - ' . $dir . '/data/texte_hello_world, |
|
| 59 | - ' . $dir . '/data/balise_env_test}'; |
|
| 57 | + ' . $dir.'/data/balise_env_test, |
|
| 58 | + ' . $dir.'/data/texte_hello_world, |
|
| 59 | + ' . $dir.'/data/balise_env_test}'; |
|
| 60 | 60 | $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}>"); |
| 61 | 61 | $this->assertEqualsCode('KittyHello WorldKitty', "<INCLURE{fond={$array}, test=Kitty}/>"); |
| 62 | 62 | } |
@@ -10,123 +10,123 @@ |
||
| 10 | 10 | |
| 11 | 11 | class CacheSessionTest extends SquelettesTestCase |
| 12 | 12 | { |
| 13 | - private static array $errors = []; |
|
| 14 | - private static string $squelettes; |
|
| 15 | - |
|
| 16 | - public static function setUpBeforeClass(): void { |
|
| 17 | - self::$squelettes = self::relativePath(__DIR__ . '/data/squelettes'); |
|
| 18 | - $GLOBALS['dossier_squelettes'] = self::$squelettes; |
|
| 19 | - $GLOBALS['delais'] = 3600; // See boostrap.php qui met delais = 0 (inhibe le cache) |
|
| 20 | - include_spip('inc/invalideur'); |
|
| 21 | - purger_repertoire(_DIR_CACHE . 'calcul/', ['subdir' => true]); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public static function tearDownAfterClass(): void { |
|
| 25 | - $GLOBALS['dossier_squelettes'] = ''; |
|
| 26 | - $GLOBALS['delais'] = 0; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - protected function setUp(): void { |
|
| 30 | - $this->resetErrors(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public function testVerifierPathMajInvalideurs(): void { |
|
| 34 | - $this->assertEquals(self::$squelettes, $GLOBALS['dossier_squelettes'] ?? null); |
|
| 35 | - $this->assertTrue(file_exists(__DIR__ . '/data/squelettes/inc/maj_invalideurs.php')); |
|
| 36 | - $this->assertNotFalse(find_in_path('inc/maj_invalideurs.php')); |
|
| 37 | - $this->assertNotFalse(include_spip('inc/maj_invalideurs')); |
|
| 38 | - $this->assertEquals('inc_maj_invalideurs', charger_fonction('maj_invalideurs', 'inc', true)); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** Vérifier qu’on sait attraper les données de cache */ |
|
| 42 | - #[Depends('testVerifierPathMajInvalideurs')] |
|
| 43 | - #[DataProvider('providerVerifierCaptureMajInvalideurs')] |
|
| 44 | - public function testVerifierCaptureMajInvalideurs(int $expectedCountErrors, string $squelette, bool $session_attendue): void { |
|
| 45 | - $this->runWithSquelette($squelette, $session_attendue); |
|
| 46 | - $this->assertCount($expectedCountErrors, $this->getErrors(), $this->showErrors()); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public static function providerVerifierCaptureMajInvalideurs(): array { |
|
| 50 | - return [ |
|
| 51 | - [0, 'inclure/A_session_wo', false], |
|
| 52 | - [2, 'inclure/A_session_wo', true], |
|
| 53 | - [2, 'inclure/A_session_w', false], |
|
| 54 | - [0, 'inclure/A_session_w', true], |
|
| 55 | - ]; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - #[Depends('testVerifierCaptureMajInvalideurs')] |
|
| 59 | - #[DataProvider('providerCachesSessionnes')] |
|
| 60 | - public function testCachesSessionnes(int $expectedCountErrors, string $squelette, bool $session_attendue): void { |
|
| 61 | - $this->runWithSquelette($squelette, $session_attendue); |
|
| 62 | - $this->assertCount($expectedCountErrors, $this->getErrors(), $this->showErrors()); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public static function providerCachesSessionnes(): array { |
|
| 66 | - return [ |
|
| 67 | - [0, 'cache_session_wo_1', false], |
|
| 68 | - [0, 'cache_session_wo_2', false], |
|
| 69 | - [0, 'cache_session_wo_3', false], |
|
| 70 | - [0, 'cache_session_wo_4', false], |
|
| 71 | - [0, 'cache_session_wo_5', false], |
|
| 72 | - [0, 'cache_session_wo_6', false], |
|
| 73 | - [0, 'cache_session_wo_7', false], |
|
| 74 | - [0, 'cache_session_w_1', true], |
|
| 75 | - [0, 'cache_session_w_2', true], |
|
| 76 | - [0, 'cache_session_w_3', true], |
|
| 77 | - ]; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - private function runWithSquelette(string $fond, bool $session_attendue) { |
|
| 81 | - unset($GLOBALS['cache_utilise_session']); |
|
| 82 | - recuperer_fond($fond, [ |
|
| 83 | - 'assert_session' => $session_attendue, |
|
| 84 | - 'caller' => 'none', |
|
| 85 | - 'salt' => $this->saltContext(), |
|
| 86 | - ]); |
|
| 87 | - unset($GLOBALS['cache_utilise_session']); |
|
| 88 | - recuperer_fond('root', [ |
|
| 89 | - 'sousfond' => $fond, |
|
| 90 | - 'inc_assert_session' => $session_attendue, |
|
| 91 | - 'salt' => $this->saltContext(), |
|
| 92 | - ]); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - private function saltContext(): string { |
|
| 96 | - return (string) time() . ':' . uniqid(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - private function getErrors(): array { |
|
| 100 | - return self::$errors; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - private function showErrors(): string { |
|
| 104 | - return "Errors:\n" . implode("\n", array_map(fn ($e) => "- $e", self::getErrors())); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - private function resetErrors(): void { |
|
| 108 | - self::$errors = []; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public static function addError(string $msg, array $page): void { |
|
| 112 | - self::$errors[] = sprintf( |
|
| 113 | - '%s pour %s: %s', |
|
| 114 | - $msg, |
|
| 115 | - $page['source'], |
|
| 116 | - self::trace_contexte($page['contexte']) |
|
| 117 | - ); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - private static function trace_contexte(array $contexte): string { |
|
| 121 | - foreach ($contexte as $k => $v) { |
|
| 122 | - if (str_starts_with($k, 'date_') || $k === 'salt') { |
|
| 123 | - unset($contexte[$k]); |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - if (isset($contexte['caller']) && str_starts_with($contexte['caller'], 'tests/squelettes/')) { |
|
| 127 | - $contexte['caller'] = substr($contexte['caller'], 17); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - return json_encode($contexte, JSON_THROW_ON_ERROR); |
|
| 131 | - } |
|
| 13 | + private static array $errors = []; |
|
| 14 | + private static string $squelettes; |
|
| 15 | + |
|
| 16 | + public static function setUpBeforeClass(): void { |
|
| 17 | + self::$squelettes = self::relativePath(__DIR__ . '/data/squelettes'); |
|
| 18 | + $GLOBALS['dossier_squelettes'] = self::$squelettes; |
|
| 19 | + $GLOBALS['delais'] = 3600; // See boostrap.php qui met delais = 0 (inhibe le cache) |
|
| 20 | + include_spip('inc/invalideur'); |
|
| 21 | + purger_repertoire(_DIR_CACHE . 'calcul/', ['subdir' => true]); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public static function tearDownAfterClass(): void { |
|
| 25 | + $GLOBALS['dossier_squelettes'] = ''; |
|
| 26 | + $GLOBALS['delais'] = 0; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + protected function setUp(): void { |
|
| 30 | + $this->resetErrors(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public function testVerifierPathMajInvalideurs(): void { |
|
| 34 | + $this->assertEquals(self::$squelettes, $GLOBALS['dossier_squelettes'] ?? null); |
|
| 35 | + $this->assertTrue(file_exists(__DIR__ . '/data/squelettes/inc/maj_invalideurs.php')); |
|
| 36 | + $this->assertNotFalse(find_in_path('inc/maj_invalideurs.php')); |
|
| 37 | + $this->assertNotFalse(include_spip('inc/maj_invalideurs')); |
|
| 38 | + $this->assertEquals('inc_maj_invalideurs', charger_fonction('maj_invalideurs', 'inc', true)); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** Vérifier qu’on sait attraper les données de cache */ |
|
| 42 | + #[Depends('testVerifierPathMajInvalideurs')] |
|
| 43 | + #[DataProvider('providerVerifierCaptureMajInvalideurs')] |
|
| 44 | + public function testVerifierCaptureMajInvalideurs(int $expectedCountErrors, string $squelette, bool $session_attendue): void { |
|
| 45 | + $this->runWithSquelette($squelette, $session_attendue); |
|
| 46 | + $this->assertCount($expectedCountErrors, $this->getErrors(), $this->showErrors()); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public static function providerVerifierCaptureMajInvalideurs(): array { |
|
| 50 | + return [ |
|
| 51 | + [0, 'inclure/A_session_wo', false], |
|
| 52 | + [2, 'inclure/A_session_wo', true], |
|
| 53 | + [2, 'inclure/A_session_w', false], |
|
| 54 | + [0, 'inclure/A_session_w', true], |
|
| 55 | + ]; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + #[Depends('testVerifierCaptureMajInvalideurs')] |
|
| 59 | + #[DataProvider('providerCachesSessionnes')] |
|
| 60 | + public function testCachesSessionnes(int $expectedCountErrors, string $squelette, bool $session_attendue): void { |
|
| 61 | + $this->runWithSquelette($squelette, $session_attendue); |
|
| 62 | + $this->assertCount($expectedCountErrors, $this->getErrors(), $this->showErrors()); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public static function providerCachesSessionnes(): array { |
|
| 66 | + return [ |
|
| 67 | + [0, 'cache_session_wo_1', false], |
|
| 68 | + [0, 'cache_session_wo_2', false], |
|
| 69 | + [0, 'cache_session_wo_3', false], |
|
| 70 | + [0, 'cache_session_wo_4', false], |
|
| 71 | + [0, 'cache_session_wo_5', false], |
|
| 72 | + [0, 'cache_session_wo_6', false], |
|
| 73 | + [0, 'cache_session_wo_7', false], |
|
| 74 | + [0, 'cache_session_w_1', true], |
|
| 75 | + [0, 'cache_session_w_2', true], |
|
| 76 | + [0, 'cache_session_w_3', true], |
|
| 77 | + ]; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + private function runWithSquelette(string $fond, bool $session_attendue) { |
|
| 81 | + unset($GLOBALS['cache_utilise_session']); |
|
| 82 | + recuperer_fond($fond, [ |
|
| 83 | + 'assert_session' => $session_attendue, |
|
| 84 | + 'caller' => 'none', |
|
| 85 | + 'salt' => $this->saltContext(), |
|
| 86 | + ]); |
|
| 87 | + unset($GLOBALS['cache_utilise_session']); |
|
| 88 | + recuperer_fond('root', [ |
|
| 89 | + 'sousfond' => $fond, |
|
| 90 | + 'inc_assert_session' => $session_attendue, |
|
| 91 | + 'salt' => $this->saltContext(), |
|
| 92 | + ]); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + private function saltContext(): string { |
|
| 96 | + return (string) time() . ':' . uniqid(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + private function getErrors(): array { |
|
| 100 | + return self::$errors; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + private function showErrors(): string { |
|
| 104 | + return "Errors:\n" . implode("\n", array_map(fn ($e) => "- $e", self::getErrors())); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + private function resetErrors(): void { |
|
| 108 | + self::$errors = []; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public static function addError(string $msg, array $page): void { |
|
| 112 | + self::$errors[] = sprintf( |
|
| 113 | + '%s pour %s: %s', |
|
| 114 | + $msg, |
|
| 115 | + $page['source'], |
|
| 116 | + self::trace_contexte($page['contexte']) |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + private static function trace_contexte(array $contexte): string { |
|
| 121 | + foreach ($contexte as $k => $v) { |
|
| 122 | + if (str_starts_with($k, 'date_') || $k === 'salt') { |
|
| 123 | + unset($contexte[$k]); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + if (isset($contexte['caller']) && str_starts_with($contexte['caller'], 'tests/squelettes/')) { |
|
| 127 | + $contexte['caller'] = substr($contexte['caller'], 17); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + return json_encode($contexte, JSON_THROW_ON_ERROR); |
|
| 131 | + } |
|
| 132 | 132 | } |
@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | private static string $squelettes; |
| 15 | 15 | |
| 16 | 16 | public static function setUpBeforeClass(): void { |
| 17 | - self::$squelettes = self::relativePath(__DIR__ . '/data/squelettes'); |
|
| 17 | + self::$squelettes = self::relativePath(__DIR__.'/data/squelettes'); |
|
| 18 | 18 | $GLOBALS['dossier_squelettes'] = self::$squelettes; |
| 19 | 19 | $GLOBALS['delais'] = 3600; // See boostrap.php qui met delais = 0 (inhibe le cache) |
| 20 | 20 | include_spip('inc/invalideur'); |
| 21 | - purger_repertoire(_DIR_CACHE . 'calcul/', ['subdir' => true]); |
|
| 21 | + purger_repertoire(_DIR_CACHE.'calcul/', ['subdir' => true]); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public static function tearDownAfterClass(): void { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function testVerifierPathMajInvalideurs(): void { |
| 34 | 34 | $this->assertEquals(self::$squelettes, $GLOBALS['dossier_squelettes'] ?? null); |
| 35 | - $this->assertTrue(file_exists(__DIR__ . '/data/squelettes/inc/maj_invalideurs.php')); |
|
| 35 | + $this->assertTrue(file_exists(__DIR__.'/data/squelettes/inc/maj_invalideurs.php')); |
|
| 36 | 36 | $this->assertNotFalse(find_in_path('inc/maj_invalideurs.php')); |
| 37 | 37 | $this->assertNotFalse(include_spip('inc/maj_invalideurs')); |
| 38 | 38 | $this->assertEquals('inc_maj_invalideurs', charger_fonction('maj_invalideurs', 'inc', true)); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | private function saltContext(): string { |
| 96 | - return (string) time() . ':' . uniqid(); |
|
| 96 | + return (string) time().':'.uniqid(); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | private function getErrors(): array { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | private function showErrors(): string { |
| 104 | - return "Errors:\n" . implode("\n", array_map(fn ($e) => "- $e", self::getErrors())); |
|
| 104 | + return "Errors:\n".implode("\n", array_map(fn ($e) => "- $e", self::getErrors())); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | private function resetErrors(): void { |
@@ -11,45 +11,45 @@ |
||
| 11 | 11 | |
| 12 | 12 | class DocumentsTest extends SquelettesTestCase |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * D'abord une image uploadee en vignette, et sans titre |
|
| 16 | - * On teste le rendu de son src, width, height |
|
| 17 | - */ |
|
| 18 | - #[DataProvider('providerDocumentSansTitreModeles')] |
|
| 19 | - public function testDocumentSansTitreModeles(string $modele): void { |
|
| 20 | - $id_document = $this->getIdDocumentImageSansTitreNiDescriptif(); |
|
| 21 | - $modele = sprintf($modele, $id_document); |
|
| 22 | - $this->assertOkCode(<<<SPIP |
|
| 14 | + /** |
|
| 15 | + * D'abord une image uploadee en vignette, et sans titre |
|
| 16 | + * On teste le rendu de son src, width, height |
|
| 17 | + */ |
|
| 18 | + #[DataProvider('providerDocumentSansTitreModeles')] |
|
| 19 | + public function testDocumentSansTitreModeles(string $modele): void { |
|
| 20 | + $id_document = $this->getIdDocumentImageSansTitreNiDescriptif(); |
|
| 21 | + $modele = sprintf($modele, $id_document); |
|
| 22 | + $this->assertOkCode(<<<SPIP |
|
| 23 | 23 | [(#SET{modele,[(#ENV*{modele}|propre)]})] |
| 24 | 24 | [(#SET{src,#GET{modele}|extraire_balise{img}|extraire_attribut{src}})] |
| 25 | 25 | [(#GET{src}|quote_amp|=={#URL_DOCUMENT}|oui)OK ] |
| 26 | 26 | \<img#ID_DOCUMENT\> src pas bon: "#URL_DOCUMENT" != "[(#GET{src})]" |
| 27 | 27 | SPIP, |
| 28 | - [ |
|
| 29 | - 'id_document' => $id_document, |
|
| 30 | - 'modele' => $modele, |
|
| 31 | - ] |
|
| 32 | - ); |
|
| 33 | - } |
|
| 28 | + [ |
|
| 29 | + 'id_document' => $id_document, |
|
| 30 | + 'modele' => $modele, |
|
| 31 | + ] |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - public static function providerDocumentSansTitreModeles() { |
|
| 36 | - return [ |
|
| 37 | - 'img' => ['<img%s>'], |
|
| 38 | - 'doc' => ['<doc%s>'], |
|
| 39 | - 'emb' => ['<emb%s>'], |
|
| 40 | - ]; |
|
| 41 | - } |
|
| 35 | + public static function providerDocumentSansTitreModeles() { |
|
| 36 | + return [ |
|
| 37 | + 'img' => ['<img%s>'], |
|
| 38 | + 'doc' => ['<doc%s>'], |
|
| 39 | + 'emb' => ['<emb%s>'], |
|
| 40 | + ]; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - private function getIdDocumentImageSansTitreNiDescriptif(): int { |
|
| 44 | - $templating = Templating::fromString(); |
|
| 45 | - $result = $templating->render(<<<SPIP |
|
| 43 | + private function getIdDocumentImageSansTitreNiDescriptif(): int { |
|
| 44 | + $templating = Templating::fromString(); |
|
| 45 | + $result = $templating->render(<<<SPIP |
|
| 46 | 46 | <BOUCLE_d(DOCUMENTS){mode=image}{titre=''}{descriptif=''}{0,1}>#ID_DOCUMENT</BOUCLE_d> |
| 47 | 47 | NA Ce test exige une image chargee en mode "image" et n'ayant ni titre ni descriptif |
| 48 | 48 | <//B_d> |
| 49 | 49 | SPIP); |
| 50 | - if ($this->isNa($result)) { |
|
| 51 | - $this->markTestSkipped($result); |
|
| 52 | - } |
|
| 53 | - return (int) $result; |
|
| 54 | - } |
|
| 50 | + if ($this->isNa($result)) { |
|
| 51 | + $this->markTestSkipped($result); |
|
| 52 | + } |
|
| 53 | + return (int) $result; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -9,84 +9,84 @@ |
||
| 9 | 9 | |
| 10 | 10 | class BoucleJointuresTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testJointureArticleIdmot1(): void { |
|
| 13 | - // S'assurer que la seconde boucle est bien optimisée en l'absence de id_mot dans le env |
|
| 14 | - $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE:</BOUCLE>'; |
|
| 15 | - $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE:</BOUCLE>'; |
|
| 12 | + public function testJointureArticleIdmot1(): void { |
|
| 13 | + // S'assurer que la seconde boucle est bien optimisée en l'absence de id_mot dans le env |
|
| 14 | + $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE:</BOUCLE>'; |
|
| 15 | + $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE:</BOUCLE>'; |
|
| 16 | 16 | |
| 17 | - $templating = Templating::fromString(); |
|
| 18 | - $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 19 | - if (empty($result1)) { |
|
| 20 | - $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 21 | - } |
|
| 22 | - $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 23 | - $this->assertNotEquals( |
|
| 24 | - $result1, |
|
| 25 | - $result2, |
|
| 26 | - "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 27 | - ); |
|
| 17 | + $templating = Templating::fromString(); |
|
| 18 | + $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 19 | + if (empty($result1)) { |
|
| 20 | + $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 21 | + } |
|
| 22 | + $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 23 | + $this->assertNotEquals( |
|
| 24 | + $result1, |
|
| 25 | + $result2, |
|
| 26 | + "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 27 | + ); |
|
| 28 | 28 | |
| 29 | - $templating = Templating::fromString(); |
|
| 30 | - $result1 = $templating->render($code1, []); |
|
| 31 | - $result2 = $templating->render($code2, []); |
|
| 32 | - $this->assertEquals( |
|
| 33 | - $result1, |
|
| 34 | - $result2, |
|
| 35 | - "La jointure conditionnelle {id_mot?} n'est pas neutre en l'absence de id_mot dans le contexte" |
|
| 36 | - ); |
|
| 37 | - } |
|
| 29 | + $templating = Templating::fromString(); |
|
| 30 | + $result1 = $templating->render($code1, []); |
|
| 31 | + $result2 = $templating->render($code2, []); |
|
| 32 | + $this->assertEquals( |
|
| 33 | + $result1, |
|
| 34 | + $result2, |
|
| 35 | + "La jointure conditionnelle {id_mot?} n'est pas neutre en l'absence de id_mot dans le contexte" |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - public function testJointureArticleIdmot2(): void { |
|
| 40 | - // S'assurer que la seconde boucle est bien optimisée en l'absence de id_mot dans le env |
|
| 41 | - $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE+#ENV{id_mot}:</BOUCLE>'; |
|
| 42 | - $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE+#ENV{id_mot}:</BOUCLE>'; |
|
| 39 | + public function testJointureArticleIdmot2(): void { |
|
| 40 | + // S'assurer que la seconde boucle est bien optimisée en l'absence de id_mot dans le env |
|
| 41 | + $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE+#ENV{id_mot}:</BOUCLE>'; |
|
| 42 | + $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE+#ENV{id_mot}:</BOUCLE>'; |
|
| 43 | 43 | |
| 44 | - $templating = Templating::fromString(); |
|
| 45 | - $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 46 | - if (empty($result1)) { |
|
| 47 | - $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 48 | - } |
|
| 49 | - $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 50 | - $this->assertNotEquals( |
|
| 51 | - $result1, |
|
| 52 | - $result2, |
|
| 53 | - "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 54 | - ); |
|
| 44 | + $templating = Templating::fromString(); |
|
| 45 | + $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 46 | + if (empty($result1)) { |
|
| 47 | + $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 48 | + } |
|
| 49 | + $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 50 | + $this->assertNotEquals( |
|
| 51 | + $result1, |
|
| 52 | + $result2, |
|
| 53 | + "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 54 | + ); |
|
| 55 | 55 | |
| 56 | - $templating = Templating::fromString(); |
|
| 57 | - $result1 = $templating->render($code1, []); |
|
| 58 | - $result2 = $templating->render($code2, []); |
|
| 59 | - $this->assertEquals( |
|
| 60 | - $result1, |
|
| 61 | - $result2, |
|
| 62 | - "La jointure conditionnelle {id_mot?} n'est pas neutre en l'absence de id_mot dans le contexte" |
|
| 63 | - ); |
|
| 64 | - } |
|
| 56 | + $templating = Templating::fromString(); |
|
| 57 | + $result1 = $templating->render($code1, []); |
|
| 58 | + $result2 = $templating->render($code2, []); |
|
| 59 | + $this->assertEquals( |
|
| 60 | + $result1, |
|
| 61 | + $result2, |
|
| 62 | + "La jointure conditionnelle {id_mot?} n'est pas neutre en l'absence de id_mot dans le contexte" |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function testJointureArticleIdmot3(): void { |
|
| 67 | - // S'assurer que la seconde boucle conserve sa jointure sur id_mot du fait de l'utilisation de #ID_MOT dans la boucle |
|
| 68 | - $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE+#ID_MOT:</BOUCLE>'; |
|
| 69 | - $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE+#ID_MOT:</BOUCLE>'; |
|
| 66 | + public function testJointureArticleIdmot3(): void { |
|
| 67 | + // S'assurer que la seconde boucle conserve sa jointure sur id_mot du fait de l'utilisation de #ID_MOT dans la boucle |
|
| 68 | + $code1 = '<BOUCLE(ARTICLES){id_rubrique?}{par id_article}{0,3}>:#ID_ARTICLE+#ID_MOT:</BOUCLE>'; |
|
| 69 | + $code2 = '<BOUCLE(ARTICLES){id_rubrique?}{id_mot?}{par id_article}{0,3}>:#ID_ARTICLE+#ID_MOT:</BOUCLE>'; |
|
| 70 | 70 | |
| 71 | - $templating = Templating::fromString(); |
|
| 72 | - $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 73 | - if (empty($result1)) { |
|
| 74 | - $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 75 | - } |
|
| 76 | - $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 77 | - $this->assertNotEquals( |
|
| 78 | - $result1, |
|
| 79 | - $result2, |
|
| 80 | - "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 81 | - ); |
|
| 71 | + $templating = Templating::fromString(); |
|
| 72 | + $result1 = $templating->render($code1, ['id_mot' => 1]); |
|
| 73 | + if (empty($result1)) { |
|
| 74 | + $this->markTestSkipped("Pas d'articles dans la base pour tester la jointure id_mot"); |
|
| 75 | + } |
|
| 76 | + $result2 = $templating->render($code2, ['id_mot' => 1]); |
|
| 77 | + $this->assertNotEquals( |
|
| 78 | + $result1, |
|
| 79 | + $result2, |
|
| 80 | + "La jointure conditionnelle {id_mot?} n'a pas d'effet si un id_mot est dans le contexte" |
|
| 81 | + ); |
|
| 82 | 82 | |
| 83 | - $templating = Templating::fromString(); |
|
| 84 | - $result1 = $templating->render($code1, []); |
|
| 85 | - $result2 = $templating->render($code2, []); |
|
| 86 | - $this->assertNotEquals( |
|
| 87 | - $result1, |
|
| 88 | - $result2, |
|
| 89 | - "La jointure conditionnelle {id_mot?} n'a pas été conservée en l'absence de id_mot dans le contexte" |
|
| 90 | - ); |
|
| 91 | - } |
|
| 83 | + $templating = Templating::fromString(); |
|
| 84 | + $result1 = $templating->render($code1, []); |
|
| 85 | + $result2 = $templating->render($code2, []); |
|
| 86 | + $this->assertNotEquals( |
|
| 87 | + $result1, |
|
| 88 | + $result2, |
|
| 89 | + "La jointure conditionnelle {id_mot?} n'a pas été conservée en l'absence de id_mot dans le contexte" |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -8,42 +8,42 @@ |
||
| 8 | 8 | |
| 9 | 9 | class BoucleGeneriqueTest extends SquelettesTestCase |
| 10 | 10 | { |
| 11 | - public function testBoucleMetaSimple(): void { |
|
| 12 | - $this->assertNotEmptyCode('<BOUCLE_meta(spip_meta)>#NOM</BOUCLE_meta>'); |
|
| 13 | - $this->assertOkCode('ok<BOUCLE_meta(spip_meta)> </BOUCLE_meta>'); |
|
| 14 | - $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok'); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function testBoucleMetaSimpleRaccourcisFinBoucle(): void { |
|
| 18 | - $this->assertOkCode('<BOUCLE_meta(spip_meta) />ok'); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function testBoucleMetaSimpleAvantApres(): void { |
|
| 22 | - $this->assertOkCode('<B_meta>ok<BOUCLE_meta(spip_meta)> </BOUCLE_meta>'); |
|
| 23 | - $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok</B_meta>'); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public function testBoucleMetaSimpleSinon(): void { |
|
| 27 | - $this->assertNotOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok<//B_meta>'); |
|
| 28 | - $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok</B_meta>non<//B_meta>'); |
|
| 29 | - |
|
| 30 | - $this->assertOkCode('<BOUCLE_meta(spip_meta)></BOUCLE_meta>ok<//B_meta>'); |
|
| 31 | - $this->assertOkCode('<BOUCLE_meta(spip_meta)></BOUCLE_meta>non</B_meta>ok<//B_meta>'); |
|
| 32 | - |
|
| 33 | - $this->assertOkCode('<BOUCLE_meta(spip_meta) />ok<//B_meta>'); |
|
| 34 | - $this->assertOkCode('<BOUCLE_meta(spip_meta) />non</B_meta>ok<//B_meta>'); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function testBoucleMetaSimpleCritere(): void { |
|
| 38 | - $this->assertEqualsCode($GLOBALS['meta']['nom_site'], '<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 39 | - $this->assertEmptyCode('<BOUCLE_meta(spip_meta){nom=gristinapolitainsic}>#VALEUR</BOUCLE_meta>'); |
|
| 40 | - $this->assertOkCode('<BOUCLE_meta(spip_meta){nom=gristinapolitainsic}>#VALEUR</BOUCLE_meta>ok<//B_meta>'); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @link http://trac.rezo.net/trac/spip/ticket/1931 |
|
| 45 | - */ |
|
| 46 | - public function testBoucleVide(): void { |
|
| 47 | - $this->assertOkSquelette(__DIR__ . '/data/boucle_vide.html'); |
|
| 48 | - } |
|
| 11 | + public function testBoucleMetaSimple(): void { |
|
| 12 | + $this->assertNotEmptyCode('<BOUCLE_meta(spip_meta)>#NOM</BOUCLE_meta>'); |
|
| 13 | + $this->assertOkCode('ok<BOUCLE_meta(spip_meta)> </BOUCLE_meta>'); |
|
| 14 | + $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok'); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function testBoucleMetaSimpleRaccourcisFinBoucle(): void { |
|
| 18 | + $this->assertOkCode('<BOUCLE_meta(spip_meta) />ok'); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function testBoucleMetaSimpleAvantApres(): void { |
|
| 22 | + $this->assertOkCode('<B_meta>ok<BOUCLE_meta(spip_meta)> </BOUCLE_meta>'); |
|
| 23 | + $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok</B_meta>'); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public function testBoucleMetaSimpleSinon(): void { |
|
| 27 | + $this->assertNotOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok<//B_meta>'); |
|
| 28 | + $this->assertOkCode('<BOUCLE_meta(spip_meta)> </BOUCLE_meta>ok</B_meta>non<//B_meta>'); |
|
| 29 | + |
|
| 30 | + $this->assertOkCode('<BOUCLE_meta(spip_meta)></BOUCLE_meta>ok<//B_meta>'); |
|
| 31 | + $this->assertOkCode('<BOUCLE_meta(spip_meta)></BOUCLE_meta>non</B_meta>ok<//B_meta>'); |
|
| 32 | + |
|
| 33 | + $this->assertOkCode('<BOUCLE_meta(spip_meta) />ok<//B_meta>'); |
|
| 34 | + $this->assertOkCode('<BOUCLE_meta(spip_meta) />non</B_meta>ok<//B_meta>'); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function testBoucleMetaSimpleCritere(): void { |
|
| 38 | + $this->assertEqualsCode($GLOBALS['meta']['nom_site'], '<BOUCLE_meta(spip_meta){nom=nom_site}>#VALEUR</BOUCLE_meta>'); |
|
| 39 | + $this->assertEmptyCode('<BOUCLE_meta(spip_meta){nom=gristinapolitainsic}>#VALEUR</BOUCLE_meta>'); |
|
| 40 | + $this->assertOkCode('<BOUCLE_meta(spip_meta){nom=gristinapolitainsic}>#VALEUR</BOUCLE_meta>ok<//B_meta>'); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @link http://trac.rezo.net/trac/spip/ticket/1931 |
|
| 45 | + */ |
|
| 46 | + public function testBoucleVide(): void { |
|
| 47 | + $this->assertOkSquelette(__DIR__ . '/data/boucle_vide.html'); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -44,6 +44,6 @@ |
||
| 44 | 44 | * @link http://trac.rezo.net/trac/spip/ticket/1931 |
| 45 | 45 | */ |
| 46 | 46 | public function testBoucleVide(): void { |
| 47 | - $this->assertOkSquelette(__DIR__ . '/data/boucle_vide.html'); |
|
| 47 | + $this->assertOkSquelette(__DIR__.'/data/boucle_vide.html'); |
|
| 48 | 48 | } |
| 49 | 49 | } |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | class BoucleRecursiveTest extends SquelettesTestCase |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * @link http://trac.rezo.net/trac/spip/ticket/764 |
|
| 13 | - */ |
|
| 14 | - public function testBoucleRecursiveSet(): void { |
|
| 15 | - $this->assertOkSquelette(__DIR__ . '/data/bug764.html'); |
|
| 16 | - } |
|
| 11 | + /** |
|
| 12 | + * @link http://trac.rezo.net/trac/spip/ticket/764 |
|
| 13 | + */ |
|
| 14 | + public function testBoucleRecursiveSet(): void { |
|
| 15 | + $this->assertOkSquelette(__DIR__ . '/data/bug764.html'); |
|
| 16 | + } |
|
| 17 | 17 | } |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | * @link http://trac.rezo.net/trac/spip/ticket/764 |
| 13 | 13 | */ |
| 14 | 14 | public function testBoucleRecursiveSet(): void { |
| 15 | - $this->assertOkSquelette(__DIR__ . '/data/bug764.html'); |
|
| 15 | + $this->assertOkSquelette(__DIR__.'/data/bug764.html'); |
|
| 16 | 16 | } |
| 17 | 17 | } |