@@ -10,71 +10,71 @@ |
||
| 10 | 10 | |
| 11 | 11 | class IntroductionTest extends SquelettesTestCase |
| 12 | 12 | { |
| 13 | - public function testArticleLongExiste(): void { |
|
| 14 | - $templating = Templating::fromString(); |
|
| 15 | - $id_article = $this->getIdArticleLong(); |
|
| 16 | - $code = '<BOUCLE_a(ARTICLES){id_article}{tout}>OK</BOUCLE_a>NA<//B_a>'; |
|
| 17 | - $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 18 | - if ($this->isNA($result)) { |
|
| 19 | - $this->markTestSkipped($result); |
|
| 20 | - } |
|
| 13 | + public function testArticleLongExiste(): void { |
|
| 14 | + $templating = Templating::fromString(); |
|
| 15 | + $id_article = $this->getIdArticleLong(); |
|
| 16 | + $code = '<BOUCLE_a(ARTICLES){id_article}{tout}>OK</BOUCLE_a>NA<//B_a>'; |
|
| 17 | + $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 18 | + if ($this->isNA($result)) { |
|
| 19 | + $this->markTestSkipped($result); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - $this->assertOK($result); |
|
| 23 | - } |
|
| 22 | + $this->assertOK($result); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - #[Depends('testArticleLongExiste')] |
|
| 26 | - public function testCoupeIntroduction(): void { |
|
| 27 | - $templating = Templating::fromString(); |
|
| 28 | - $id_article = $this->getIdArticleLong(); |
|
| 29 | - $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
|
| 30 | - $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 31 | - $suite = ' (...)'; |
|
| 32 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 33 | - } |
|
| 25 | + #[Depends('testArticleLongExiste')] |
|
| 26 | + public function testCoupeIntroduction(): void { |
|
| 27 | + $templating = Templating::fromString(); |
|
| 28 | + $id_article = $this->getIdArticleLong(); |
|
| 29 | + $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
|
| 30 | + $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 31 | + $suite = ' (...)'; |
|
| 32 | + $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - #[Depends('testArticleLongExiste')] |
|
| 36 | - public function testCoupeIntroductionSuite(): void { |
|
| 37 | - $templating = Templating::fromString(); |
|
| 38 | - $id_article = $this->getIdArticleLong(); |
|
| 39 | - $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{…}</BOUCLE_a>'; |
|
| 40 | - $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 41 | - $suite = '…'; |
|
| 42 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 35 | + #[Depends('testArticleLongExiste')] |
|
| 36 | + public function testCoupeIntroductionSuite(): void { |
|
| 37 | + $templating = Templating::fromString(); |
|
| 38 | + $id_article = $this->getIdArticleLong(); |
|
| 39 | + $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{…}</BOUCLE_a>'; |
|
| 40 | + $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 41 | + $suite = '…'; |
|
| 42 | + $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 43 | 43 | |
| 44 | - $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{#ENV{suite}}</BOUCLE_a>'; |
|
| 45 | - $result = $templating->render($code, [ |
|
| 46 | - 'id_article' => $id_article, |
|
| 47 | - 'suite' => $suite, |
|
| 48 | - ]); |
|
| 49 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 50 | - } |
|
| 44 | + $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{#ENV{suite}}</BOUCLE_a>'; |
|
| 45 | + $result = $templating->render($code, [ |
|
| 46 | + 'id_article' => $id_article, |
|
| 47 | + 'suite' => $suite, |
|
| 48 | + ]); |
|
| 49 | + $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - #[Depends('testCoupeIntroduction')] |
|
| 53 | - public function testCoupeIntroductionConstante(): void { |
|
| 54 | - $id_article = $this->getIdArticleLong(); |
|
| 55 | - $templating = Templating::fromString([ |
|
| 56 | - 'fonctions' => " |
|
| 52 | + #[Depends('testCoupeIntroduction')] |
|
| 53 | + public function testCoupeIntroductionConstante(): void { |
|
| 54 | + $id_article = $this->getIdArticleLong(); |
|
| 55 | + $templating = Templating::fromString([ |
|
| 56 | + 'fonctions' => " |
|
| 57 | 57 | if (!defined('_INTRODUCTION_SUITE')) { |
| 58 | 58 | define('_INTRODUCTION_SUITE', '!!!'); |
| 59 | 59 | } |
| 60 | 60 | ", |
| 61 | - ]); |
|
| 62 | - $code = '#CACHE{0}<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
|
| 63 | - $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 64 | - $suite = _INTRODUCTION_SUITE; |
|
| 65 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 66 | - } |
|
| 61 | + ]); |
|
| 62 | + $code = '#CACHE{0}<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
|
| 63 | + $result = $templating->render($code, ['id_article' => $id_article]); |
|
| 64 | + $suite = _INTRODUCTION_SUITE; |
|
| 65 | + $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - protected function getIdArticleLong(): int { |
|
| 69 | - include_spip('base/abstract_sql'); |
|
| 70 | - $id_article = sql_getfetsel( |
|
| 71 | - 'id_article', |
|
| 72 | - 'spip_articles', |
|
| 73 | - "descriptif='' AND LENGTH(CONCAT(chapo, texte)) > 520 AND texte!='' AND LENGTH(chapo) > 100", |
|
| 74 | - '', |
|
| 75 | - 'id_article', |
|
| 76 | - '0,1' |
|
| 77 | - ); |
|
| 78 | - return intval($id_article); |
|
| 79 | - } |
|
| 68 | + protected function getIdArticleLong(): int { |
|
| 69 | + include_spip('base/abstract_sql'); |
|
| 70 | + $id_article = sql_getfetsel( |
|
| 71 | + 'id_article', |
|
| 72 | + 'spip_articles', |
|
| 73 | + "descriptif='' AND LENGTH(CONCAT(chapo, texte)) > 520 AND texte!='' AND LENGTH(chapo) > 100", |
|
| 74 | + '', |
|
| 75 | + 'id_article', |
|
| 76 | + '0,1' |
|
| 77 | + ); |
|
| 78 | + return intval($id_article); |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
| 30 | 30 | $result = $templating->render($code, ['id_article' => $id_article]); |
| 31 | 31 | $suite = ' (...)'; |
| 32 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 32 | + $this->assertMatchesRegularExpression('#'.preg_quote($suite.'</p>', '#').'$#', $result); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | #[Depends('testArticleLongExiste')] |
@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{…}</BOUCLE_a>'; |
| 40 | 40 | $result = $templating->render($code, ['id_article' => $id_article]); |
| 41 | 41 | $suite = '…'; |
| 42 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 42 | + $this->assertMatchesRegularExpression('#'.preg_quote($suite.'</p>', '#').'$#', $result); |
|
| 43 | 43 | |
| 44 | 44 | $code = '<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION{#ENV{suite}}</BOUCLE_a>'; |
| 45 | 45 | $result = $templating->render($code, [ |
| 46 | 46 | 'id_article' => $id_article, |
| 47 | 47 | 'suite' => $suite, |
| 48 | 48 | ]); |
| 49 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 49 | + $this->assertMatchesRegularExpression('#'.preg_quote($suite.'</p>', '#').'$#', $result); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | #[Depends('testCoupeIntroduction')] |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $code = '#CACHE{0}<BOUCLE_a(ARTICLES){id_article}{tout}{0,1}>#INTRODUCTION</BOUCLE_a>'; |
| 63 | 63 | $result = $templating->render($code, ['id_article' => $id_article]); |
| 64 | 64 | $suite = _INTRODUCTION_SUITE; |
| 65 | - $this->assertMatchesRegularExpression('#' . preg_quote($suite . '</p>', '#') . '$#', $result); |
|
| 65 | + $this->assertMatchesRegularExpression('#'.preg_quote($suite.'</p>', '#').'$#', $result); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | protected function getIdArticleLong(): int { |
@@ -8,13 +8,13 @@ |
||
| 8 | 8 | |
| 9 | 9 | class AutoriserTest extends SquelettesTestCase |
| 10 | 10 | { |
| 11 | - public function testAutoriserSqueletteOkNiet(): void { |
|
| 12 | - $this->assertOkCode('[(#AUTORISER{ok})ok]'); |
|
| 13 | - $this->assertOkCode('[(#AUTORISER{niet}|sinon{ok})]'); |
|
| 14 | - $this->assertOkCode(' |
|
| 11 | + public function testAutoriserSqueletteOkNiet(): void { |
|
| 12 | + $this->assertOkCode('[(#AUTORISER{ok})ok]'); |
|
| 13 | + $this->assertOkCode('[(#AUTORISER{niet}|sinon{ok})]'); |
|
| 14 | + $this->assertOkCode(' |
|
| 15 | 15 | [(#AUTORISER{niet}|?{Ah ben non !! il faut pas..., |
| 16 | 16 | [(#AUTORISER{ok}|?{OK,Allez quoi dis-moi oui!})] |
| 17 | 17 | })] |
| 18 | 18 | '); |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | |
| 9 | 9 | class SelfTest extends SquelettesTestCase |
| 10 | 10 | { |
| 11 | - public function testBaliseSelf(): never { |
|
| 12 | - $this->assertEqualsCode('./', '#SELF'); |
|
| 13 | - $this->markTestIncomplete('More tests needed, but requires SPIP evolution with RequestInterface or so'); |
|
| 14 | - } |
|
| 11 | + public function testBaliseSelf(): never { |
|
| 12 | + $this->assertEqualsCode('./', '#SELF'); |
|
| 13 | + $this->markTestIncomplete('More tests needed, but requires SPIP evolution with RequestInterface or so'); |
|
| 14 | + } |
|
| 15 | 15 | } |
@@ -9,19 +9,19 @@ |
||
| 9 | 9 | |
| 10 | 10 | class LesauteursTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testLesAuteursRenvoieQqc(): void { |
|
| 13 | - $templating = Templating::fromString(); |
|
| 14 | - $result = $templating->render( |
|
| 15 | - "<BOUCLE_a(ARTICLES){id_auteur>0}{0,1}> |
|
| 12 | + public function testLesAuteursRenvoieQqc(): void { |
|
| 13 | + $templating = Templating::fromString(); |
|
| 14 | + $result = $templating->render( |
|
| 15 | + "<BOUCLE_a(ARTICLES){id_auteur>0}{0,1}> |
|
| 16 | 16 | [(#LESAUTEURS|?{OK,'LESAUTEURS a echoue'})] |
| 17 | 17 | </BOUCLE_a> |
| 18 | 18 | NA Ce test ne fonctionne que s'il existe un article ayant un auteur ! |
| 19 | 19 | <//B_a>" |
| 20 | - ); |
|
| 21 | - if ($this->isNa($result)) { |
|
| 22 | - $this->markTestSkipped($result); |
|
| 23 | - } |
|
| 20 | + ); |
|
| 21 | + if ($this->isNa($result)) { |
|
| 22 | + $this->markTestSkipped($result); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - $this->assertOk($result); |
|
| 26 | - } |
|
| 25 | + $this->assertOk($result); |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -9,65 +9,65 @@ |
||
| 9 | 9 | |
| 10 | 10 | class InclureStatiqueTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testInclureInlineNormal(): 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 testInclureInlineNormal(): 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('#CACHE{0}[(#INCLURE{fond=carabistouille/de/montignac/absente}|non)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('#CACHE{0}[(#INCLURE{fond=carabistouille/de/montignac/absente}|non)ok]'); |
|
| 71 | + $this->assertCount(1, $infos['erreurs']); |
|
| 72 | + } |
|
| 73 | 73 | } |
@@ -11,52 +11,52 @@ |
||
| 11 | 11 | { |
| 12 | 12 | public function testInclureInlineNormal(): 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 | } |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | |
| 9 | 9 | class EvalTest extends SquelettesTestCase |
| 10 | 10 | { |
| 11 | - public function testBaliseEval(): void { |
|
| 12 | - $this->assertEmptyCode("#EVAL{''}"); |
|
| 13 | - $this->assertOkCode('#EVAL{"\'ok\'"}'); |
|
| 14 | - $this->assertEqualsCode('1', '#EVAL{1}'); |
|
| 15 | - $this->assertEqualsCode(_DIR_CACHE, '#EVAL{_DIR_CACHE}'); |
|
| 16 | - $this->assertEqualsCode('20', '#EVAL{3*5+5}'); |
|
| 17 | - } |
|
| 11 | + public function testBaliseEval(): void { |
|
| 12 | + $this->assertEmptyCode("#EVAL{''}"); |
|
| 13 | + $this->assertOkCode('#EVAL{"\'ok\'"}'); |
|
| 14 | + $this->assertEqualsCode('1', '#EVAL{1}'); |
|
| 15 | + $this->assertEqualsCode(_DIR_CACHE, '#EVAL{_DIR_CACHE}'); |
|
| 16 | + $this->assertEqualsCode('20', '#EVAL{3*5+5}'); |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -9,65 +9,65 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class BaliseGeneriqueTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testBaliseInexistante(): void { |
|
| 13 | - $this->assertEmptyCode('#JENEXISTEPAS'); |
|
| 14 | - $this->assertEmptyCode('[(#JENEXISTEPAS)]'); |
|
| 15 | - $this->assertEmptyCode('[avant(#JENEXISTEPAS)apres]'); |
|
| 12 | + public function testBaliseInexistante(): void { |
|
| 13 | + $this->assertEmptyCode('#JENEXISTEPAS'); |
|
| 14 | + $this->assertEmptyCode('[(#JENEXISTEPAS)]'); |
|
| 15 | + $this->assertEmptyCode('[avant(#JENEXISTEPAS)apres]'); |
|
| 16 | 16 | |
| 17 | - // ceux-ci sont plus etonnant mais c'est ce qui se passe effectivement |
|
| 18 | - $this->assertEqualsCode('{rien}', '#JENEXISTEPAS{rien}'); |
|
| 19 | - $this->assertEqualsCode('{rien}', '[(#JENEXISTEPAS{rien})]'); |
|
| 20 | - $this->assertEqualsCode('avant{rien}apres', '[avant(#JENEXISTEPAS{rien})apres]'); |
|
| 21 | - } |
|
| 17 | + // ceux-ci sont plus etonnant mais c'est ce qui se passe effectivement |
|
| 18 | + $this->assertEqualsCode('{rien}', '#JENEXISTEPAS{rien}'); |
|
| 19 | + $this->assertEqualsCode('{rien}', '[(#JENEXISTEPAS{rien})]'); |
|
| 20 | + $this->assertEqualsCode('avant{rien}apres', '[avant(#JENEXISTEPAS{rien})apres]'); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function testBaliseDeclaree(): void { |
|
| 24 | - $templating = Templating::fromString([ |
|
| 25 | - 'fonctions' => ' |
|
| 23 | + public function testBaliseDeclaree(): void { |
|
| 24 | + $templating = Templating::fromString([ |
|
| 25 | + 'fonctions' => ' |
|
| 26 | 26 | function balise_JEXISTE_dist($p){ |
| 27 | 27 | $p->code = "\'ok\'"; |
| 28 | 28 | return $p; |
| 29 | 29 | } |
| 30 | 30 | ', |
| 31 | - ]); |
|
| 32 | - $this->assertOkTemplate($templating, '#JEXISTE'); |
|
| 33 | - $this->assertOkTemplate($templating, '[(#JEXISTE)]'); |
|
| 34 | - } |
|
| 31 | + ]); |
|
| 32 | + $this->assertOkTemplate($templating, '#JEXISTE'); |
|
| 33 | + $this->assertOkTemplate($templating, '[(#JEXISTE)]'); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public function testBaliseDeclareeAvantApres(): void { |
|
| 37 | - $templating = Templating::fromString([ |
|
| 38 | - 'fonctions' => ' |
|
| 36 | + public function testBaliseDeclareeAvantApres(): void { |
|
| 37 | + $templating = Templating::fromString([ |
|
| 38 | + 'fonctions' => ' |
|
| 39 | 39 | function balise_JEXISTE_dist($p){ |
| 40 | 40 | $p->code = "\'ok\'"; |
| 41 | 41 | return $p; |
| 42 | 42 | } |
| 43 | 43 | ', |
| 44 | - ]); |
|
| 44 | + ]); |
|
| 45 | 45 | |
| 46 | - $this->assertEqualsTemplate('avantokapres', $templating, '[avant(#JEXISTE)apres]'); |
|
| 47 | - $this->assertEqualsTemplate('avant apres', $templating, '[avant(#JEXISTE|oui)apres]'); |
|
| 48 | - $this->assertEqualsTemplate('', $templating, '[avant(#JEXISTE|non)apres]'); |
|
| 49 | - } |
|
| 46 | + $this->assertEqualsTemplate('avantokapres', $templating, '[avant(#JEXISTE)apres]'); |
|
| 47 | + $this->assertEqualsTemplate('avant apres', $templating, '[avant(#JEXISTE|oui)apres]'); |
|
| 48 | + $this->assertEqualsTemplate('', $templating, '[avant(#JEXISTE|non)apres]'); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function testBaliseDeclareeEtParams(): void { |
|
| 52 | - $templating = Templating::fromString([ |
|
| 53 | - 'fonctions' => ' |
|
| 51 | + public function testBaliseDeclareeEtParams(): void { |
|
| 52 | + $templating = Templating::fromString([ |
|
| 53 | + 'fonctions' => ' |
|
| 54 | 54 | function balise_JEXISTE_dist($p){ |
| 55 | 55 | $p->code = "\'ok\'"; |
| 56 | 56 | return $p; |
| 57 | 57 | } |
| 58 | 58 | ', |
| 59 | - ]); |
|
| 59 | + ]); |
|
| 60 | 60 | |
| 61 | - $this->assertOkTemplate($templating, '#JEXISTE{param}'); |
|
| 62 | - $this->assertOkTemplate($templating, '#JEXISTE{param,param}'); |
|
| 63 | - $this->assertOkTemplate($templating, '#JEXISTE{#SELF,#SQUELETTE}'); |
|
| 64 | - $this->assertOkTemplate($templating, '#JEXISTE{#VAL{#SELF}}'); |
|
| 65 | - $this->assertOkTemplate($templating, '[(#JEXISTE{[(#VAL{[(#SELF)]})]})]'); |
|
| 66 | - } |
|
| 61 | + $this->assertOkTemplate($templating, '#JEXISTE{param}'); |
|
| 62 | + $this->assertOkTemplate($templating, '#JEXISTE{param,param}'); |
|
| 63 | + $this->assertOkTemplate($templating, '#JEXISTE{#SELF,#SQUELETTE}'); |
|
| 64 | + $this->assertOkTemplate($templating, '#JEXISTE{#VAL{#SELF}}'); |
|
| 65 | + $this->assertOkTemplate($templating, '[(#JEXISTE{[(#VAL{[(#SELF)]})]})]'); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function testBaliseDeclareeEtParamsUtiles(): void { |
|
| 69 | - $templating = Templating::fromString([ |
|
| 70 | - 'fonctions' => ' |
|
| 68 | + public function testBaliseDeclareeEtParamsUtiles(): void { |
|
| 69 | + $templating = Templating::fromString([ |
|
| 70 | + 'fonctions' => ' |
|
| 71 | 71 | function balise_ZEXISTE_dist($p){ |
| 72 | 72 | if (!$p1 = interprete_argument_balise(1,$p)) |
| 73 | 73 | $p1 = "\'\'"; |
@@ -78,17 +78,17 @@ discard block |
||
| 78 | 78 | return $p1; |
| 79 | 79 | } |
| 80 | 80 | ', |
| 81 | - ]); |
|
| 82 | - $this->assertEmptyTemplate($templating, '#ZEXISTE'); |
|
| 83 | - $this->assertOkTemplate($templating, '#ZEXISTE{ok}'); |
|
| 84 | - $this->assertEqualsTemplate('avantokapres', $templating, '[avant(#ZEXISTE{ok})apres]'); |
|
| 85 | - $this->assertEqualsTemplate('avant apres', $templating, '[avant(#ZEXISTE{ok}|oui)apres]'); |
|
| 86 | - $this->assertEmptyTemplate($templating, '[avant(#ZEXISTE{ok}|non)apres]'); |
|
| 87 | - } |
|
| 81 | + ]); |
|
| 82 | + $this->assertEmptyTemplate($templating, '#ZEXISTE'); |
|
| 83 | + $this->assertOkTemplate($templating, '#ZEXISTE{ok}'); |
|
| 84 | + $this->assertEqualsTemplate('avantokapres', $templating, '[avant(#ZEXISTE{ok})apres]'); |
|
| 85 | + $this->assertEqualsTemplate('avant apres', $templating, '[avant(#ZEXISTE{ok}|oui)apres]'); |
|
| 86 | + $this->assertEmptyTemplate($templating, '[avant(#ZEXISTE{ok}|non)apres]'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public function testBaliseSurchargee(): void { |
|
| 90 | - $templating = Templating::fromString([ |
|
| 91 | - 'fonctions' => ' |
|
| 89 | + public function testBaliseSurchargee(): void { |
|
| 90 | + $templating = Templating::fromString([ |
|
| 91 | + 'fonctions' => ' |
|
| 92 | 92 | function balise_REXISTE_dist($p){ |
| 93 | 93 | $p->code = "\'oups\'"; |
| 94 | 94 | return $p; |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | return $p1; |
| 105 | 105 | } |
| 106 | 106 | ', |
| 107 | - ]); |
|
| 107 | + ]); |
|
| 108 | 108 | |
| 109 | - $this->assertEmptyTemplate($templating, '#REXISTE'); |
|
| 110 | - $this->assertOkTemplate($templating, '#REXISTE{ok}'); |
|
| 111 | - } |
|
| 109 | + $this->assertEmptyTemplate($templating, '#REXISTE'); |
|
| 110 | + $this->assertOkTemplate($templating, '#REXISTE{ok}'); |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | |
| 11 | 11 | class DossierSqueletteTest extends SquelettesTestCase |
| 12 | 12 | { |
| 13 | - public function testBaliseDossierSquelette(): void { |
|
| 14 | - $loader = new StringLoader(); |
|
| 15 | - $templating = new Templating($loader); |
|
| 16 | - $expected = dirname($loader->getSourceFile('#DOSSIER_SQUELETTE')); |
|
| 17 | - $this->assertEqualsTemplate($expected, $templating, "#DOSSIER_SQUELETTE"); |
|
| 18 | - } |
|
| 13 | + public function testBaliseDossierSquelette(): void { |
|
| 14 | + $loader = new StringLoader(); |
|
| 15 | + $templating = new Templating($loader); |
|
| 16 | + $expected = dirname($loader->getSourceFile('#DOSSIER_SQUELETTE')); |
|
| 17 | + $this->assertEqualsTemplate($expected, $templating, "#DOSSIER_SQUELETTE"); |
|
| 18 | + } |
|
| 19 | 19 | } |
@@ -9,182 +9,182 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class ConfigTest extends SquelettesTestCase |
| 11 | 11 | { |
| 12 | - public function testConfigNomAbsent(): void { |
|
| 13 | - $templating = $this->getTemplating(); |
|
| 14 | - $this->assertOkTemplate($templating, '[(#CONFIG{pasla}|non)ok]'); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function testConfigNomAbsentAvecDefaut(): void { |
|
| 18 | - $templating = $this->getTemplating(); |
|
| 19 | - $this->assertOkTemplate($templating, '[(#CONFIG{pasla,defaut}|=={defaut}|oui)ok]'); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function testConfigChaine(): void { |
|
| 23 | - $templating = $this->getTemplating(); |
|
| 24 | - $this->assertOkTemplate($templating, '[(#CONFIG{chaine}|=={une chaine}|oui)ok]'); |
|
| 25 | - $this->assertOkTemplate($templating, '[(#CONFIG{chaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - public function testConfigValeurZero(): void { |
|
| 29 | - $templating = $this->getTemplating(); |
|
| 30 | - $this->assertOkTemplate($templating, '[(#CONFIG{zero}|=={0}|oui)ok]'); |
|
| 31 | - $this->assertOkTemplate($templating, '[(#CONFIG{zero,defaut}|=={0}|oui)ok]'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public function testConfigChaineZero(): void { |
|
| 35 | - $templating = $this->getTemplating(); |
|
| 36 | - $this->assertOkTemplate($templating, "[(#CONFIG{zeroc}|=={'0'}|oui)ok]"); |
|
| 37 | - $this->assertOkTemplate($templating, "[(#CONFIG{zeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public function testArrayAssoc(): void { |
|
| 41 | - $templating = $this->getTemplating(); |
|
| 42 | - $this->assertOkTemplate($templating, "[(#CONFIG{assoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 43 | - $this->assertOkTemplate($templating, "[(#CONFIG{assoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function testArraySerialize(): void { |
|
| 47 | - $templating = $this->getTemplating(); |
|
| 48 | - $this->assertOkTemplate( |
|
| 49 | - $templating, |
|
| 50 | - '[(#CONFIG{serie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 51 | - ); |
|
| 52 | - $this->assertOkTemplate( |
|
| 53 | - $templating, |
|
| 54 | - '[(#CONFIG{serie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - public function testMetaConfigNomAbsent(): void { |
|
| 59 | - $templating = $this->getTemplating(); |
|
| 60 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/pasla}|non)ok]'); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function testMetaConfigNomAbsentAvecDefaut(): void { |
|
| 64 | - $templating = $this->getTemplating(); |
|
| 65 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/pasla,defaut}|=={defaut}|oui)ok]'); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public function testMetaConfigChaine(): void { |
|
| 69 | - $templating = $this->getTemplating(); |
|
| 70 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/chaine}|=={une chaine}|oui)ok]'); |
|
| 71 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/chaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function testMetaConfigValeurZero(): void { |
|
| 75 | - $templating = $this->getTemplating(); |
|
| 76 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/zero}|=={0}|oui)ok]'); |
|
| 77 | - $this->assertOkTemplate($templating, '[(#CONFIG{/meta/zero,defaut}|=={0}|oui)ok]'); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - public function testMetaConfigChaineZero(): void { |
|
| 81 | - $templating = $this->getTemplating(); |
|
| 82 | - $this->assertOkTemplate($templating, "[(#CONFIG{/meta/zeroc}|=={'0'}|oui)ok]"); |
|
| 83 | - $this->assertOkTemplate($templating, "[(#CONFIG{/meta/zeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - public function testMetaArrayAssoc(): void { |
|
| 87 | - $templating = $this->getTemplating(); |
|
| 88 | - $this->assertOkTemplate($templating, "[(#CONFIG{/meta/assoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 89 | - $this->assertOkTemplate( |
|
| 90 | - $templating, |
|
| 91 | - "[(#CONFIG{/meta/assoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]" |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function testMetaArraySerialize(): void { |
|
| 96 | - $templating = $this->getTemplating(); |
|
| 97 | - $this->assertOkTemplate( |
|
| 98 | - $templating, |
|
| 99 | - '[(#CONFIG{/meta/serie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 100 | - ); |
|
| 101 | - $this->assertOkTemplate( |
|
| 102 | - $templating, |
|
| 103 | - '[(#CONFIG{/meta/serie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 104 | - ); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function testAutreTableConfigNomAbsent(): void { |
|
| 108 | - $templating = $this->getTemplatingOtherTable(); |
|
| 109 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tpasla}|non)ok]'); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function testAutreTableConfigNomAbsentAvecDefaut(): void { |
|
| 113 | - $templating = $this->getTemplatingOtherTable(); |
|
| 114 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tpasla,defaut}|=={defaut}|oui)ok]'); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - public function testAutreTableConfigChaine(): void { |
|
| 118 | - $templating = $this->getTemplatingOtherTable(); |
|
| 119 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tchaine}|=={une chaine}|oui)ok]'); |
|
| 120 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tchaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - public function testAutreTableConfigValeurZero(): void { |
|
| 124 | - $templating = $this->getTemplatingOtherTable(); |
|
| 125 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tzero}|=={0}|oui)ok]'); |
|
| 126 | - $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tzero,defaut}|=={0}|oui)ok]'); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - public function testAutreTableConfigChaineZero(): void { |
|
| 130 | - $templating = $this->getTemplatingOtherTable(); |
|
| 131 | - $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tzeroc}|=={'0'}|oui)ok]"); |
|
| 132 | - $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tzeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - public function testAutreTableArrayAssoc(): void { |
|
| 136 | - $templating = $this->getTemplatingOtherTable(); |
|
| 137 | - $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tassoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 138 | - $this->assertOkTemplate( |
|
| 139 | - $templating, |
|
| 140 | - "[(#CONFIG{/toto/tassoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]" |
|
| 141 | - ); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - public function testAutreTableArraySerialize(): void { |
|
| 145 | - $templating = $this->getTemplatingOtherTable(); |
|
| 146 | - $this->assertOkTemplate( |
|
| 147 | - $templating, |
|
| 148 | - '[(#CONFIG{/toto/tserie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 149 | - ); |
|
| 150 | - $this->assertOkTemplate( |
|
| 151 | - $templating, |
|
| 152 | - '[(#CONFIG{/toto/tserie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 153 | - ); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - private function getFakeMetaData(): array { |
|
| 157 | - $assoc = [ |
|
| 158 | - 'one' => 'element 1', |
|
| 159 | - 'two' => 'element 2', |
|
| 160 | - ]; |
|
| 161 | - return [ |
|
| 162 | - 'zero' => 0, |
|
| 163 | - 'zeroc' => '0', |
|
| 164 | - 'chaine' => 'une chaine', |
|
| 165 | - 'assoc' => $assoc, |
|
| 166 | - 'serie' => serialize($assoc), |
|
| 167 | - ]; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - private function getFakeMetaDataT(): array { |
|
| 171 | - $assoc = [ |
|
| 172 | - 'one' => 'element 1', |
|
| 173 | - 'two' => 'element 2', |
|
| 174 | - ]; |
|
| 175 | - return [ |
|
| 176 | - 'tzero' => 0, |
|
| 177 | - 'tzeroc' => '0', |
|
| 178 | - 'tchaine' => 'une chaine', |
|
| 179 | - 'tassoc' => $assoc, |
|
| 180 | - 'tserie' => serialize($assoc), |
|
| 181 | - ]; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - private function getTemplating(): Templating { |
|
| 185 | - $fake = var_export($this->getFakeMetaData(), true); |
|
| 186 | - return Templating::fromString([ |
|
| 187 | - 'fonctions' => " |
|
| 12 | + public function testConfigNomAbsent(): void { |
|
| 13 | + $templating = $this->getTemplating(); |
|
| 14 | + $this->assertOkTemplate($templating, '[(#CONFIG{pasla}|non)ok]'); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function testConfigNomAbsentAvecDefaut(): void { |
|
| 18 | + $templating = $this->getTemplating(); |
|
| 19 | + $this->assertOkTemplate($templating, '[(#CONFIG{pasla,defaut}|=={defaut}|oui)ok]'); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function testConfigChaine(): void { |
|
| 23 | + $templating = $this->getTemplating(); |
|
| 24 | + $this->assertOkTemplate($templating, '[(#CONFIG{chaine}|=={une chaine}|oui)ok]'); |
|
| 25 | + $this->assertOkTemplate($templating, '[(#CONFIG{chaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + public function testConfigValeurZero(): void { |
|
| 29 | + $templating = $this->getTemplating(); |
|
| 30 | + $this->assertOkTemplate($templating, '[(#CONFIG{zero}|=={0}|oui)ok]'); |
|
| 31 | + $this->assertOkTemplate($templating, '[(#CONFIG{zero,defaut}|=={0}|oui)ok]'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public function testConfigChaineZero(): void { |
|
| 35 | + $templating = $this->getTemplating(); |
|
| 36 | + $this->assertOkTemplate($templating, "[(#CONFIG{zeroc}|=={'0'}|oui)ok]"); |
|
| 37 | + $this->assertOkTemplate($templating, "[(#CONFIG{zeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public function testArrayAssoc(): void { |
|
| 41 | + $templating = $this->getTemplating(); |
|
| 42 | + $this->assertOkTemplate($templating, "[(#CONFIG{assoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 43 | + $this->assertOkTemplate($templating, "[(#CONFIG{assoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function testArraySerialize(): void { |
|
| 47 | + $templating = $this->getTemplating(); |
|
| 48 | + $this->assertOkTemplate( |
|
| 49 | + $templating, |
|
| 50 | + '[(#CONFIG{serie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 51 | + ); |
|
| 52 | + $this->assertOkTemplate( |
|
| 53 | + $templating, |
|
| 54 | + '[(#CONFIG{serie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + public function testMetaConfigNomAbsent(): void { |
|
| 59 | + $templating = $this->getTemplating(); |
|
| 60 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/pasla}|non)ok]'); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function testMetaConfigNomAbsentAvecDefaut(): void { |
|
| 64 | + $templating = $this->getTemplating(); |
|
| 65 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/pasla,defaut}|=={defaut}|oui)ok]'); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public function testMetaConfigChaine(): void { |
|
| 69 | + $templating = $this->getTemplating(); |
|
| 70 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/chaine}|=={une chaine}|oui)ok]'); |
|
| 71 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/chaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function testMetaConfigValeurZero(): void { |
|
| 75 | + $templating = $this->getTemplating(); |
|
| 76 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/zero}|=={0}|oui)ok]'); |
|
| 77 | + $this->assertOkTemplate($templating, '[(#CONFIG{/meta/zero,defaut}|=={0}|oui)ok]'); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + public function testMetaConfigChaineZero(): void { |
|
| 81 | + $templating = $this->getTemplating(); |
|
| 82 | + $this->assertOkTemplate($templating, "[(#CONFIG{/meta/zeroc}|=={'0'}|oui)ok]"); |
|
| 83 | + $this->assertOkTemplate($templating, "[(#CONFIG{/meta/zeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + public function testMetaArrayAssoc(): void { |
|
| 87 | + $templating = $this->getTemplating(); |
|
| 88 | + $this->assertOkTemplate($templating, "[(#CONFIG{/meta/assoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 89 | + $this->assertOkTemplate( |
|
| 90 | + $templating, |
|
| 91 | + "[(#CONFIG{/meta/assoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]" |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function testMetaArraySerialize(): void { |
|
| 96 | + $templating = $this->getTemplating(); |
|
| 97 | + $this->assertOkTemplate( |
|
| 98 | + $templating, |
|
| 99 | + '[(#CONFIG{/meta/serie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 100 | + ); |
|
| 101 | + $this->assertOkTemplate( |
|
| 102 | + $templating, |
|
| 103 | + '[(#CONFIG{/meta/serie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 104 | + ); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function testAutreTableConfigNomAbsent(): void { |
|
| 108 | + $templating = $this->getTemplatingOtherTable(); |
|
| 109 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tpasla}|non)ok]'); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function testAutreTableConfigNomAbsentAvecDefaut(): void { |
|
| 113 | + $templating = $this->getTemplatingOtherTable(); |
|
| 114 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tpasla,defaut}|=={defaut}|oui)ok]'); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + public function testAutreTableConfigChaine(): void { |
|
| 118 | + $templating = $this->getTemplatingOtherTable(); |
|
| 119 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tchaine}|=={une chaine}|oui)ok]'); |
|
| 120 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tchaine,defaut}|=={une chaine}|oui)ok]'); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + public function testAutreTableConfigValeurZero(): void { |
|
| 124 | + $templating = $this->getTemplatingOtherTable(); |
|
| 125 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tzero}|=={0}|oui)ok]'); |
|
| 126 | + $this->assertOkTemplate($templating, '[(#CONFIG{/toto/tzero,defaut}|=={0}|oui)ok]'); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + public function testAutreTableConfigChaineZero(): void { |
|
| 130 | + $templating = $this->getTemplatingOtherTable(); |
|
| 131 | + $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tzeroc}|=={'0'}|oui)ok]"); |
|
| 132 | + $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tzeroc,defaut}|=={'0'}|oui)ok]"); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + public function testAutreTableArrayAssoc(): void { |
|
| 136 | + $templating = $this->getTemplatingOtherTable(); |
|
| 137 | + $this->assertOkTemplate($templating, "[(#CONFIG{/toto/tassoc,'',''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]"); |
|
| 138 | + $this->assertOkTemplate( |
|
| 139 | + $templating, |
|
| 140 | + "[(#CONFIG{/toto/tassoc,defaut,''}|=={#ARRAY{one,element 1,two,element 2}}|oui)ok]" |
|
| 141 | + ); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + public function testAutreTableArraySerialize(): void { |
|
| 145 | + $templating = $this->getTemplatingOtherTable(); |
|
| 146 | + $this->assertOkTemplate( |
|
| 147 | + $templating, |
|
| 148 | + '[(#CONFIG{/toto/tserie}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 149 | + ); |
|
| 150 | + $this->assertOkTemplate( |
|
| 151 | + $templating, |
|
| 152 | + '[(#CONFIG{/toto/tserie,defaut}|=={a:2:{s:3:"one";s:9:"element 1";s:3:"two";s:9:"element 2";}}oui)ok]' |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + private function getFakeMetaData(): array { |
|
| 157 | + $assoc = [ |
|
| 158 | + 'one' => 'element 1', |
|
| 159 | + 'two' => 'element 2', |
|
| 160 | + ]; |
|
| 161 | + return [ |
|
| 162 | + 'zero' => 0, |
|
| 163 | + 'zeroc' => '0', |
|
| 164 | + 'chaine' => 'une chaine', |
|
| 165 | + 'assoc' => $assoc, |
|
| 166 | + 'serie' => serialize($assoc), |
|
| 167 | + ]; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + private function getFakeMetaDataT(): array { |
|
| 171 | + $assoc = [ |
|
| 172 | + 'one' => 'element 1', |
|
| 173 | + 'two' => 'element 2', |
|
| 174 | + ]; |
|
| 175 | + return [ |
|
| 176 | + 'tzero' => 0, |
|
| 177 | + 'tzeroc' => '0', |
|
| 178 | + 'tchaine' => 'une chaine', |
|
| 179 | + 'tassoc' => $assoc, |
|
| 180 | + 'tserie' => serialize($assoc), |
|
| 181 | + ]; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + private function getTemplating(): Templating { |
|
| 185 | + $fake = var_export($this->getFakeMetaData(), true); |
|
| 186 | + return Templating::fromString([ |
|
| 187 | + 'fonctions' => " |
|
| 188 | 188 | function test_meta(\$raz = 0) { |
| 189 | 189 | static \$meta = []; |
| 190 | 190 | if (!\$meta) { |
@@ -196,15 +196,15 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | ", |
| 199 | - 'avant_code' => '[(#VAL|test_meta)]', |
|
| 200 | - 'apres_code' => '[(#VAL{1}|test_meta)]', |
|
| 201 | - ]); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - private function getTemplatingOtherTable(): Templating { |
|
| 205 | - $fake = var_export($this->getFakeMetaDataT(), true); |
|
| 206 | - return Templating::fromString([ |
|
| 207 | - 'fonctions' => " |
|
| 199 | + 'avant_code' => '[(#VAL|test_meta)]', |
|
| 200 | + 'apres_code' => '[(#VAL{1}|test_meta)]', |
|
| 201 | + ]); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + private function getTemplatingOtherTable(): Templating { |
|
| 205 | + $fake = var_export($this->getFakeMetaDataT(), true); |
|
| 206 | + return Templating::fromString([ |
|
| 207 | + 'fonctions' => " |
|
| 208 | 208 | function test_meta_toto(\$raz = 0) { |
| 209 | 209 | \$GLOBALS['toto'] = {$fake}; |
| 210 | 210 | if (\$raz) { |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | ", |
| 215 | - 'avant_code' => '[(#VAL|test_meta_toto)]', |
|
| 216 | - 'apres_code' => '[(#VAL{1}|test_meta_toto)]', |
|
| 217 | - ]); |
|
| 218 | - } |
|
| 215 | + 'avant_code' => '[(#VAL|test_meta_toto)]', |
|
| 216 | + 'apres_code' => '[(#VAL{1}|test_meta_toto)]', |
|
| 217 | + ]); |
|
| 218 | + } |
|
| 219 | 219 | } |