@@ -15,18 +15,18 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | class CodeImbriqueTest extends TestCase |
| 17 | 17 | { |
| 18 | - public static function setUpBeforeClass(): void { |
|
| 19 | - find_in_path('inc/texte.php', '', true); |
|
| 20 | - } |
|
| 18 | + public static function setUpBeforeClass(): void { |
|
| 19 | + find_in_path('inc/texte.php', '', true); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - #[DataProvider('providerPropreCodeImbrique')] |
|
| 23 | - public function testPropreCodeImbrique($expected, ...$args): void { |
|
| 24 | - $actual = strlen(propre(...$args)) > 0; |
|
| 25 | - $this->assertSame($expected, $actual); |
|
| 26 | - } |
|
| 22 | + #[DataProvider('providerPropreCodeImbrique')] |
|
| 23 | + public function testPropreCodeImbrique($expected, ...$args): void { |
|
| 24 | + $actual = strlen(propre(...$args)) > 0; |
|
| 25 | + $this->assertSame($expected, $actual); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public static function providerPropreCodeImbrique(): array { |
|
| 29 | - return [[true, '({{{Classificar els resultats}}} |
|
| 28 | + public static function providerPropreCodeImbrique(): array { |
|
| 29 | + return [[true, '({{{Classificar els resultats}}} |
|
| 30 | 30 | |
| 31 | 31 | <html><tt><b>{par</b> <i>critère_de_classement</i><b>}</b></tt></html> iIndica l’ordre en què es presenten els resultats. Aquest criteri de classificació correspon a una de les etiquetes extretes de la base de dades per cada tipus de bucle. Per exemple, podrem classificar els articles per la data <code>{per date}</code>, per la data en què han estat redactats <code>{par date_redac}</code> o per títol <code>{par titre}</code>. (Fixeu-vos que, tot i que les etiquetes es presenten en majúscules, els criteris de classificació es presenten en minúscules.) |
| 32 | 32 | |
@@ -232,5 +232,5 @@ discard block |
||
| 232 | 232 | {{{Divers}}} |
| 233 | 233 | |
| 234 | 234 | {{<code>{logo}</code>}} permet seleccionar només els articles (o seccions, etc) que disposin d\'un logo. Funciona també en el bucle (HIERARCHIE). El criteri invers <code>{!logo}</code> llista els objectes que no tenen logo.']]; |
| 235 | - } |
|
| 235 | + } |
|
| 236 | 236 | } |
@@ -8,38 +8,38 @@ |
||
| 8 | 8 | |
| 9 | 9 | class TraiterModelesTest extends TestCase |
| 10 | 10 | { |
| 11 | - public static function setUpBeforeClass(): void { |
|
| 12 | - find_in_path('inc/modeles.php', '', true); |
|
| 13 | - } |
|
| 14 | - |
|
| 15 | - public function testTraiterModelesDefaut(): void { |
|
| 16 | - unset($GLOBALS['doublons_documents_inclus']); |
|
| 17 | - |
|
| 18 | - $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons'; |
|
| 19 | - traiter_modeles($texte); |
|
| 20 | - $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 21 | - |
|
| 22 | - traiter_modeles($texte, [ |
|
| 23 | - 'documents' => ['doc', 'emb', 'img'], |
|
| 24 | - ]); |
|
| 25 | - $this->assertNotEmpty($GLOBALS['doublons_documents_inclus']); |
|
| 26 | - $this->assertEquals([1, 2, 3], $GLOBALS['doublons_documents_inclus']); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function testTraiterModelesAlbums(): void { |
|
| 30 | - unset($GLOBALS['doublons_documents_inclus']); |
|
| 31 | - unset($GLOBALS['doublons_albums_inclus']); |
|
| 32 | - |
|
| 33 | - $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons'; |
|
| 34 | - |
|
| 35 | - traiter_modeles($texte, ['albums' => ['album']]); |
|
| 36 | - $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 37 | - $this->assertNull($GLOBALS['doublons_albums_inclus'] ?? null); |
|
| 38 | - |
|
| 39 | - $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons avec un album <album4> ?'; |
|
| 40 | - traiter_modeles($texte, ['albums' => ['album']]); |
|
| 41 | - $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 42 | - $this->assertNotEmpty($GLOBALS['doublons_albums_inclus']); |
|
| 43 | - $this->assertEquals([4], $GLOBALS['doublons_albums_inclus']); |
|
| 44 | - } |
|
| 11 | + public static function setUpBeforeClass(): void { |
|
| 12 | + find_in_path('inc/modeles.php', '', true); |
|
| 13 | + } |
|
| 14 | + |
|
| 15 | + public function testTraiterModelesDefaut(): void { |
|
| 16 | + unset($GLOBALS['doublons_documents_inclus']); |
|
| 17 | + |
|
| 18 | + $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons'; |
|
| 19 | + traiter_modeles($texte); |
|
| 20 | + $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 21 | + |
|
| 22 | + traiter_modeles($texte, [ |
|
| 23 | + 'documents' => ['doc', 'emb', 'img'], |
|
| 24 | + ]); |
|
| 25 | + $this->assertNotEmpty($GLOBALS['doublons_documents_inclus']); |
|
| 26 | + $this->assertEquals([1, 2, 3], $GLOBALS['doublons_documents_inclus']); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function testTraiterModelesAlbums(): void { |
|
| 30 | + unset($GLOBALS['doublons_documents_inclus']); |
|
| 31 | + unset($GLOBALS['doublons_albums_inclus']); |
|
| 32 | + |
|
| 33 | + $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons'; |
|
| 34 | + |
|
| 35 | + traiter_modeles($texte, ['albums' => ['album']]); |
|
| 36 | + $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 37 | + $this->assertNull($GLOBALS['doublons_albums_inclus'] ?? null); |
|
| 38 | + |
|
| 39 | + $texte = 'Mon texte <doc1> <img2> <emb3> et paf les doublons avec un album <album4> ?'; |
|
| 40 | + traiter_modeles($texte, ['albums' => ['album']]); |
|
| 41 | + $this->assertNull($GLOBALS['doublons_documents_inclus'] ?? null); |
|
| 42 | + $this->assertNotEmpty($GLOBALS['doublons_albums_inclus']); |
|
| 43 | + $this->assertEquals([4], $GLOBALS['doublons_albums_inclus']); |
|
| 44 | + } |
|
| 45 | 45 | } |
@@ -13,40 +13,40 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | class TraiterRaccourcisTest extends TestCase |
| 15 | 15 | { |
| 16 | - public static function setUpBeforeClass(): void { |
|
| 17 | - find_in_path('inc/texte.php', '', true); |
|
| 18 | - } |
|
| 16 | + public static function setUpBeforeClass(): void { |
|
| 17 | + find_in_path('inc/texte.php', '', true); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - protected function setUp(): void { |
|
| 21 | - $this->preparePropreTraiterRaccourcis(); |
|
| 22 | - } |
|
| 20 | + protected function setUp(): void { |
|
| 21 | + $this->preparePropreTraiterRaccourcis(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - protected function tearDown(): void { |
|
| 25 | - $this->preparePropreTraiterRaccourcis(true); |
|
| 26 | - } |
|
| 24 | + protected function tearDown(): void { |
|
| 25 | + $this->preparePropreTraiterRaccourcis(true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function preparePropreTraiterRaccourcis(bool $revert = false) { |
|
| 29 | - static $mem = [null, null]; |
|
| 30 | - if ($revert) { |
|
| 31 | - $GLOBALS['toujours_paragrapher'] = $mem[0]; |
|
| 32 | - $GLOBALS['puce'] = $mem[1]; |
|
| 33 | - } else { |
|
| 34 | - $mem = [$GLOBALS['toujours_paragrapher'] ?? null, $GLOBALS['puce'] ?? null]; |
|
| 35 | - // ces tests sont prevus pour la variable de personnalisation : |
|
| 36 | - $GLOBALS['toujours_paragrapher'] = false; |
|
| 37 | - $GLOBALS['puce'] = '-'; |
|
| 38 | - } |
|
| 39 | - } |
|
| 28 | + public function preparePropreTraiterRaccourcis(bool $revert = false) { |
|
| 29 | + static $mem = [null, null]; |
|
| 30 | + if ($revert) { |
|
| 31 | + $GLOBALS['toujours_paragrapher'] = $mem[0]; |
|
| 32 | + $GLOBALS['puce'] = $mem[1]; |
|
| 33 | + } else { |
|
| 34 | + $mem = [$GLOBALS['toujours_paragrapher'] ?? null, $GLOBALS['puce'] ?? null]; |
|
| 35 | + // ces tests sont prevus pour la variable de personnalisation : |
|
| 36 | + $GLOBALS['toujours_paragrapher'] = false; |
|
| 37 | + $GLOBALS['puce'] = '-'; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - #[DataProvider('providerPropreTraiterRaccourcis')] |
|
| 42 | - public function testPropreTraiterRaccourcis($expected, ...$args): void { |
|
| 43 | - $actual = traiter_raccourcis(...$args); |
|
| 44 | - $this->assertSame($expected, $actual); |
|
| 45 | - } |
|
| 41 | + #[DataProvider('providerPropreTraiterRaccourcis')] |
|
| 42 | + public function testPropreTraiterRaccourcis($expected, ...$args): void { |
|
| 43 | + $actual = traiter_raccourcis(...$args); |
|
| 44 | + $this->assertSame($expected, $actual); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public static function providerPropreTraiterRaccourcis(): array { |
|
| 48 | - return [ |
|
| 49 | - /* |
|
| 47 | + public static function providerPropreTraiterRaccourcis(): array { |
|
| 48 | + return [ |
|
| 49 | + /* |
|
| 50 | 50 | if (!preg_match($c = ",<p\b.*?>titi</p>\n<p\b.*?>toto</p>,", |
| 51 | 51 | $b = propre( $a = "titi\n\ntoto"))) |
| 52 | 52 | $err[] = htmlentities ("$a -- $b -- $c"); |
@@ -59,21 +59,21 @@ discard block |
||
| 59 | 59 | if (!strpos(propre("Ligne\n\n<br class=\"n\" />\n\nAutre"), '<br class="n" />')) |
| 60 | 60 | $err[] = "erreur le <br class='truc'> n'est pas preserve"; |
| 61 | 61 | */ |
| 62 | - // trois tests un peu identiques sur <br />... |
|
| 63 | - 'div' => ["<div>titi<br />toto</div>\n<p><br />tata</p>\n", '<div>titi<br />toto</div><br />tata'], |
|
| 64 | - 'span' => ['<span>titi<br />toto</span><br />tata', '<span>titi<br />toto</span><br />tata'], |
|
| 65 | - 'table' => [ |
|
| 66 | - "<table><tr><td>titi<br />toto</td></tr></table>\n<p><br />tata</p>\n", |
|
| 67 | - '<table><tr><td>titi<br />toto</td></tr></table><br />tata', |
|
| 68 | - ], |
|
| 69 | - // melanges de \n et de <br /> |
|
| 70 | - '\n_x1_mixte1' => ["titi\n<br />toto<br />", "titi\n<br />toto<br />"], |
|
| 71 | - '\n_x1_mixte2' => ["titi\n<br />\ntoto<br />", "titi\n<br />\ntoto<br />"], |
|
| 72 | - // des tirets en debut de texte |
|
| 73 | - 'tirets1' => ["— chose\n<br />— truc", "-- chose\n-- truc"], |
|
| 74 | - 'tirets2' => ["- chose\n<br />- truc", "- chose\n- truc"], |
|
| 75 | - // ligne horizontale |
|
| 76 | - 'lignehorizontale' => ['<hr class="spip" />', "\n----\n"], |
|
| 77 | - ]; |
|
| 78 | - } |
|
| 62 | + // trois tests un peu identiques sur <br />... |
|
| 63 | + 'div' => ["<div>titi<br />toto</div>\n<p><br />tata</p>\n", '<div>titi<br />toto</div><br />tata'], |
|
| 64 | + 'span' => ['<span>titi<br />toto</span><br />tata', '<span>titi<br />toto</span><br />tata'], |
|
| 65 | + 'table' => [ |
|
| 66 | + "<table><tr><td>titi<br />toto</td></tr></table>\n<p><br />tata</p>\n", |
|
| 67 | + '<table><tr><td>titi<br />toto</td></tr></table><br />tata', |
|
| 68 | + ], |
|
| 69 | + // melanges de \n et de <br /> |
|
| 70 | + '\n_x1_mixte1' => ["titi\n<br />toto<br />", "titi\n<br />toto<br />"], |
|
| 71 | + '\n_x1_mixte2' => ["titi\n<br />\ntoto<br />", "titi\n<br />\ntoto<br />"], |
|
| 72 | + // des tirets en debut de texte |
|
| 73 | + 'tirets1' => ["— chose\n<br />— truc", "-- chose\n-- truc"], |
|
| 74 | + 'tirets2' => ["- chose\n<br />- truc", "- chose\n- truc"], |
|
| 75 | + // ligne horizontale |
|
| 76 | + 'lignehorizontale' => ['<hr class="spip" />', "\n----\n"], |
|
| 77 | + ]; |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -9,84 +9,84 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | class TraiterTableauTest extends TestCase |
| 11 | 11 | { |
| 12 | - public static function setUpBeforeClass(): void { |
|
| 13 | - find_in_path('inc/texte.php', '', true); |
|
| 14 | - } |
|
| 12 | + public static function setUpBeforeClass(): void { |
|
| 13 | + find_in_path('inc/texte.php', '', true); |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - #[DataProvider('providerPropreTraiterTableau')] |
|
| 17 | - public function testPropreTraiterTableau($expected, ...$args): void { |
|
| 18 | - $actual = traiter_raccourcis(...$args); |
|
| 19 | - if (is_array($expected)) { |
|
| 20 | - [$func, $pattern, $result] = $expected; |
|
| 21 | - if ($result) { |
|
| 22 | - $this->assertMatchesRegularExpression($pattern, $actual); |
|
| 23 | - } else { |
|
| 24 | - $this->assertDoesNotMatchRegularExpression($pattern, $actual); |
|
| 25 | - } |
|
| 26 | - } else { |
|
| 27 | - $this->assertSame($expected, $actual); |
|
| 28 | - $this->assertEquals($expected, $actual); |
|
| 29 | - } |
|
| 30 | - } |
|
| 16 | + #[DataProvider('providerPropreTraiterTableau')] |
|
| 17 | + public function testPropreTraiterTableau($expected, ...$args): void { |
|
| 18 | + $actual = traiter_raccourcis(...$args); |
|
| 19 | + if (is_array($expected)) { |
|
| 20 | + [$func, $pattern, $result] = $expected; |
|
| 21 | + if ($result) { |
|
| 22 | + $this->assertMatchesRegularExpression($pattern, $actual); |
|
| 23 | + } else { |
|
| 24 | + $this->assertDoesNotMatchRegularExpression($pattern, $actual); |
|
| 25 | + } |
|
| 26 | + } else { |
|
| 27 | + $this->assertSame($expected, $actual); |
|
| 28 | + $this->assertEquals($expected, $actual); |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public static function providerPropreTraiterTableau(): array { |
|
| 33 | - return [ |
|
| 34 | - // trois tests un peu identiques sur <br />... |
|
| 35 | - 'caption seul' => [ |
|
| 36 | - ['preg_match', ',<caption>\s*titre de mon tableau\s*</caption>,i', true], |
|
| 37 | - '|| titre de mon tableau|| |
|
| 32 | + public static function providerPropreTraiterTableau(): array { |
|
| 33 | + return [ |
|
| 34 | + // trois tests un peu identiques sur <br />... |
|
| 35 | + 'caption seul' => [ |
|
| 36 | + ['preg_match', ',<caption>\s*titre de mon tableau\s*</caption>,i', true], |
|
| 37 | + '|| titre de mon tableau|| |
|
| 38 | 38 | |{{Colonne 0}} | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 39 | 39 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 40 | 40 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 41 | 41 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 42 | 42 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 43 | 43 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 44 | - ], |
|
| 45 | - 'caption' => [ |
|
| 46 | - ['preg_match', ',<caption>\s*titre de mon tableau.*</caption>,i', true], |
|
| 47 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 44 | + ], |
|
| 45 | + 'caption' => [ |
|
| 46 | + ['preg_match', ',<caption>\s*titre de mon tableau.*</caption>,i', true], |
|
| 47 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 48 | 48 | |{{Colonne 0}} | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 49 | 49 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 50 | 50 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 51 | 51 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 52 | 52 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 53 | 53 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 54 | - ], |
|
| 55 | - 'summary' => [ |
|
| 56 | - [ |
|
| 57 | - 'preg_match', ',<table[^>]*aria-describedby="([^"]*)"[^>]*>.*<caption>.* id="(\1)"[^>]*>\s*resume de mon tableau.*</caption>,is', true, |
|
| 58 | - ], |
|
| 59 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 54 | + ], |
|
| 55 | + 'summary' => [ |
|
| 56 | + [ |
|
| 57 | + 'preg_match', ',<table[^>]*aria-describedby="([^"]*)"[^>]*>.*<caption>.* id="(\1)"[^>]*>\s*resume de mon tableau.*</caption>,is', true, |
|
| 58 | + ], |
|
| 59 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 60 | 60 | |{{Colonne 0}} | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 61 | 61 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 62 | 62 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 63 | 63 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 64 | 64 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 65 | 65 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 66 | - ], |
|
| 67 | - 'thead simple' => [ |
|
| 68 | - ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 69 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 66 | + ], |
|
| 67 | + 'thead simple' => [ |
|
| 68 | + ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 69 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 70 | 70 | |{{Colonne 0}} | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 71 | 71 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 72 | 72 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 73 | 73 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 74 | 74 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 75 | 75 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 76 | - ], |
|
| 77 | - 'thead avec une colonne vide' => [ |
|
| 78 | - ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 79 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 76 | + ], |
|
| 77 | + 'thead avec une colonne vide' => [ |
|
| 78 | + ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 79 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 80 | 80 | | | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 81 | 81 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 82 | 82 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 83 | 83 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 84 | 84 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 85 | 85 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 86 | - ], |
|
| 87 | - 'thead avec une colonne vide et un retour ligne' => [ |
|
| 88 | - ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 89 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 86 | + ], |
|
| 87 | + 'thead avec une colonne vide et un retour ligne' => [ |
|
| 88 | + ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', true], |
|
| 89 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 90 | 90 | | | {{Colonne 1}} | {{Colonne 2}} | {{Colonne 3 |
| 91 | 91 | _ avec retour ligne}} | {{Colonne 4}} | |
| 92 | 92 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
@@ -94,23 +94,23 @@ discard block |
||
| 94 | 94 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 95 | 95 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 96 | 96 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 97 | - ], |
|
| 98 | - 'thead errone' => [ |
|
| 99 | - ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', false], |
|
| 100 | - '|| titre de mon tableau | resume de mon tableau || |
|
| 97 | + ], |
|
| 98 | + 'thead errone' => [ |
|
| 99 | + ['preg_match', ',<thead>\s*<tr[^>]*>(:?<th[^>]*>.*</th>){5}\s*</tr>\s*</thead>,Uims', false], |
|
| 100 | + '|| titre de mon tableau | resume de mon tableau || |
|
| 101 | 101 | |{{Colonne 0}} | {Colonne 1}} | {{Colonne 2}} | {{Colonne 3}} | {{Colonne 4}} | |
| 102 | 102 | | {{Bourg-les-Valence}} | 10,39 | 20,14 | 46,02 | 15,99 | |
| 103 | 103 | | {{Valence}} | 16,25 | 23,31 | 49,21 | 13,43 | |
| 104 | 104 | | {{Romans}} | 14,09 | 20,54 | 67,85 | 17 | |
| 105 | 105 | | {{Montelimar}} | 20,15 | 26,43 | 70,21 | 16,82 | |
| 106 | 106 | | {{Bourg-de-Peage}} | 13,22 | 30 | 50 | 14,67 |', |
| 107 | - ], |
|
| 108 | - 'fusion par |<|' => [['preg_match', ',colspan=.*colspan=,is', true], '| {{Bourg-de-Peage}} | 1-2 |<|3-4|<|'], |
|
| 109 | - "fusion |<| avec conservation d'URL dans un raccourci de liens" => [ |
|
| 110 | - ['preg_match', ',colspan=.*->,is', true], |
|
| 111 | - '|test avec fusion dans tous les sens|<| |
|
| 107 | + ], |
|
| 108 | + 'fusion par |<|' => [['preg_match', ',colspan=.*colspan=,is', true], '| {{Bourg-de-Peage}} | 1-2 |<|3-4|<|'], |
|
| 109 | + "fusion |<| avec conservation d'URL dans un raccourci de liens" => [ |
|
| 110 | + ['preg_match', ',colspan=.*->,is', true], |
|
| 111 | + '|test avec fusion dans tous les sens|<| |
|
| 112 | 112 | |test1 |[mon beau lien->http://foo.fr]|', |
| 113 | - ], |
|
| 114 | - ]; |
|
| 115 | - } |
|
| 113 | + ], |
|
| 114 | + ]; |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -15,51 +15,51 @@ |
||
| 15 | 15 | |
| 16 | 16 | class ChevronOuvrantTest extends TestCase |
| 17 | 17 | { |
| 18 | - public static function setUpBeforeClass(): void { |
|
| 19 | - find_in_path('inc/texte.php', '', true); |
|
| 20 | - } |
|
| 18 | + public static function setUpBeforeClass(): void { |
|
| 19 | + find_in_path('inc/texte.php', '', true); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - protected function setUp(): void { |
|
| 23 | - $GLOBALS['meta']['type_urls'] = 'page'; |
|
| 24 | - $GLOBALS['type_urls'] = 'page'; |
|
| 25 | - // initialiser les plugins qui changent les intertitre (Z), et les restaurer juste apres |
|
| 26 | - $mem = [$GLOBALS['debut_intertitre'] ?? null, $GLOBALS['spip_raccourcis_typo'] ?? null]; |
|
| 27 | - propre('rien du tout'); |
|
| 28 | - [$GLOBALS['debut_intertitre'], $GLOBALS['spip_raccourcis_typo']] = $mem; |
|
| 29 | - } |
|
| 22 | + protected function setUp(): void { |
|
| 23 | + $GLOBALS['meta']['type_urls'] = 'page'; |
|
| 24 | + $GLOBALS['type_urls'] = 'page'; |
|
| 25 | + // initialiser les plugins qui changent les intertitre (Z), et les restaurer juste apres |
|
| 26 | + $mem = [$GLOBALS['debut_intertitre'] ?? null, $GLOBALS['spip_raccourcis_typo'] ?? null]; |
|
| 27 | + propre('rien du tout'); |
|
| 28 | + [$GLOBALS['debut_intertitre'], $GLOBALS['spip_raccourcis_typo']] = $mem; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - #[DataProvider('providerPropreChevronOuvrant')] |
|
| 32 | - public function testPropreChevronOuvrant($expected, ...$args): void { |
|
| 33 | - $actual = propre(...$args); |
|
| 34 | - $this->assertSame($expected, $actual); |
|
| 35 | - } |
|
| 31 | + #[DataProvider('providerPropreChevronOuvrant')] |
|
| 32 | + public function testPropreChevronOuvrant($expected, ...$args): void { |
|
| 33 | + $actual = propre(...$args); |
|
| 34 | + $this->assertSame($expected, $actual); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function providerPropreChevronOuvrant(): array { |
|
| 38 | - return [ |
|
| 39 | - 0 => [ |
|
| 40 | - 0 => '<p>a<b</p>', |
|
| 41 | - 1 => 'a<b', |
|
| 42 | - ], |
|
| 43 | - 1 => [ |
|
| 44 | - 0 => '<p><i>a<b</i></p>', |
|
| 45 | - 1 => '{a<b}', |
|
| 46 | - ], |
|
| 47 | - 2 => [ |
|
| 48 | - 0 => '<p><strong>a<b</strong></p>', |
|
| 49 | - 1 => '{{a<b}}', |
|
| 50 | - ], |
|
| 51 | - 3 => [ |
|
| 52 | - 0 => '<h2 class="spip">a<b</h2>', |
|
| 53 | - 1 => '{{{a<b}}}', |
|
| 54 | - ], |
|
| 55 | - 4 => [ |
|
| 56 | - 0 => '<p><i>0 < a < 1</i> et <i>a > 5</i></p>', |
|
| 57 | - 1 => '{0 < a < 1} et {a > 5}', |
|
| 58 | - ], |
|
| 59 | - 5 => [ |
|
| 60 | - 0 => '<p><i>0 < a < 1.0</i> et <i>a > 5</i></p>', |
|
| 61 | - 1 => '{0 < a < 1.0} et {a > 5}', |
|
| 62 | - ], |
|
| 63 | - ]; |
|
| 64 | - } |
|
| 37 | + public static function providerPropreChevronOuvrant(): array { |
|
| 38 | + return [ |
|
| 39 | + 0 => [ |
|
| 40 | + 0 => '<p>a<b</p>', |
|
| 41 | + 1 => 'a<b', |
|
| 42 | + ], |
|
| 43 | + 1 => [ |
|
| 44 | + 0 => '<p><i>a<b</i></p>', |
|
| 45 | + 1 => '{a<b}', |
|
| 46 | + ], |
|
| 47 | + 2 => [ |
|
| 48 | + 0 => '<p><strong>a<b</strong></p>', |
|
| 49 | + 1 => '{{a<b}}', |
|
| 50 | + ], |
|
| 51 | + 3 => [ |
|
| 52 | + 0 => '<h2 class="spip">a<b</h2>', |
|
| 53 | + 1 => '{{{a<b}}}', |
|
| 54 | + ], |
|
| 55 | + 4 => [ |
|
| 56 | + 0 => '<p><i>0 < a < 1</i> et <i>a > 5</i></p>', |
|
| 57 | + 1 => '{0 < a < 1} et {a > 5}', |
|
| 58 | + ], |
|
| 59 | + 5 => [ |
|
| 60 | + 0 => '<p><i>0 < a < 1.0</i> et <i>a > 5</i></p>', |
|
| 61 | + 1 => '{0 < a < 1.0} et {a > 5}', |
|
| 62 | + ], |
|
| 63 | + ]; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -8,31 +8,31 @@ |
||
| 8 | 8 | |
| 9 | 9 | final class IsOk extends Constraint |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * Returns a string representation of the constraint. |
|
| 13 | - */ |
|
| 14 | - public function toString(): string { |
|
| 15 | - return 'is OK'; |
|
| 16 | - } |
|
| 11 | + /** |
|
| 12 | + * Returns a string representation of the constraint. |
|
| 13 | + */ |
|
| 14 | + public function toString(): string { |
|
| 15 | + return 'is OK'; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise. |
|
| 20 | - * |
|
| 21 | - * @param mixed $other value or object to evaluate |
|
| 22 | - */ |
|
| 23 | - protected function matches($other): bool { |
|
| 24 | - return str_starts_with(strtolower(trim($other)), 'ok'); |
|
| 25 | - } |
|
| 18 | + /** |
|
| 19 | + * Evaluates the constraint for parameter $other. Returns true if the constraint is met, false otherwise. |
|
| 20 | + * |
|
| 21 | + * @param mixed $other value or object to evaluate |
|
| 22 | + */ |
|
| 23 | + protected function matches($other): bool { |
|
| 24 | + return str_starts_with(strtolower(trim($other)), 'ok'); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Returns the description of the failure. |
|
| 29 | - * |
|
| 30 | - * The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second |
|
| 31 | - * part of that sentence. |
|
| 32 | - * |
|
| 33 | - * @param mixed $other evaluated value or object |
|
| 34 | - */ |
|
| 35 | - protected function failureDescription($other): string { |
|
| 36 | - return sprintf('"%s" is OK', $other); |
|
| 37 | - } |
|
| 27 | + /** |
|
| 28 | + * Returns the description of the failure. |
|
| 29 | + * |
|
| 30 | + * The beginning of failure messages is "Failed asserting that" in most cases. This method should return the second |
|
| 31 | + * part of that sentence. |
|
| 32 | + * |
|
| 33 | + * @param mixed $other evaluated value or object |
|
| 34 | + */ |
|
| 35 | + protected function failureDescription($other): string { |
|
| 36 | + return sprintf('"%s" is OK', $other); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -8,30 +8,30 @@ |
||
| 8 | 8 | |
| 9 | 9 | class FileLoader implements LoaderInterface |
| 10 | 10 | { |
| 11 | - private readonly int $rootLen; |
|
| 11 | + private readonly int $rootLen; |
|
| 12 | 12 | |
| 13 | - public function __construct() { |
|
| 14 | - $this->rootLen = strlen(_SPIP_TEST_CHDIR) + 1; |
|
| 15 | - } |
|
| 13 | + public function __construct() { |
|
| 14 | + $this->rootLen = strlen(_SPIP_TEST_CHDIR) + 1; |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public function exists(string $name): bool { |
|
| 18 | - $filepath = realpath($name); |
|
| 19 | - return ($filepath !== false) && file_exists($filepath); |
|
| 20 | - } |
|
| 17 | + public function exists(string $name): bool { |
|
| 18 | + $filepath = realpath($name); |
|
| 19 | + return ($filepath !== false) && file_exists($filepath); |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function getCacheKey(string $name): string { |
|
| 23 | - return $this->getSourceFile($name); |
|
| 24 | - } |
|
| 22 | + public function getCacheKey(string $name): string { |
|
| 23 | + return $this->getSourceFile($name); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - public function getSourceFile(string $name): string { |
|
| 27 | - $filepath = realpath($name); |
|
| 28 | - if (!$filepath || !file_exists($filepath)) { |
|
| 29 | - throw new TemplateNotFoundException($name); |
|
| 30 | - } |
|
| 26 | + public function getSourceFile(string $name): string { |
|
| 27 | + $filepath = realpath($name); |
|
| 28 | + if (!$filepath || !file_exists($filepath)) { |
|
| 29 | + throw new TemplateNotFoundException($name); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - $desc = pathinfo($name); |
|
| 33 | - $fond = $desc['dirname'] . '/' . $desc['filename']; |
|
| 32 | + $desc = pathinfo($name); |
|
| 33 | + $fond = $desc['dirname'] . '/' . $desc['filename']; |
|
| 34 | 34 | |
| 35 | - return substr($fond, $this->rootLen); |
|
| 36 | - } |
|
| 35 | + return substr($fond, $this->rootLen); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $desc = pathinfo($name); |
| 33 | - $fond = $desc['dirname'] . '/' . $desc['filename']; |
|
| 33 | + $fond = $desc['dirname'].'/'.$desc['filename']; |
|
| 34 | 34 | |
| 35 | 35 | return substr($fond, $this->rootLen); |
| 36 | 36 | } |
@@ -6,94 +6,94 @@ |
||
| 6 | 6 | |
| 7 | 7 | class StringLoader implements LoaderInterface |
| 8 | 8 | { |
| 9 | - private string $adresse_dernier_fichier_pour_code = ''; |
|
| 10 | - |
|
| 11 | - private string $cacheDirectory = ''; |
|
| 12 | - |
|
| 13 | - private array $options = []; |
|
| 14 | - |
|
| 15 | - public function __construct(array $options = []) { |
|
| 16 | - include_spip('inc/flock'); |
|
| 17 | - $this->cacheDirectory = sous_repertoire(_DIR_CACHE, 'Tests'); |
|
| 18 | - $this->setOptions($options); |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function exists(string $name): bool { |
|
| 22 | - return true; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public function getCacheKey(string $name): string { |
|
| 26 | - return md5($name . serialize($this->options)); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Écrit le code du squelette dans un fichier temporaire de cache |
|
| 31 | - */ |
|
| 32 | - public function getSourceFile(string $name): string { |
|
| 33 | - $fond = $this->cacheDirectory . $this->getCacheKey($name); |
|
| 34 | - $options = $this->options; |
|
| 35 | - $code = $name; |
|
| 36 | - |
|
| 37 | - if (isset($options['avant_code'])) { |
|
| 38 | - $code = $options['avant_code'] . $code; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if (isset($options['apres_code'])) { |
|
| 42 | - $code .= $options['apres_code']; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - $this->ecrire_fichier($fond . '.html', $code); |
|
| 46 | - |
|
| 47 | - if (!empty($options['fonctions'])) { |
|
| 48 | - // un fichier unique pour ces fonctions |
|
| 49 | - $func = $this->cacheDirectory . 'func_' . md5($options['fonctions']) . '.php'; |
|
| 50 | - $this->ecrire_fichier($func, $this->php($options['fonctions'])); |
|
| 51 | - // une inclusion unique de ces fichiers |
|
| 52 | - $this->ecrire_fichier($fond . '_fonctions.php', $this->php(sprintf('include_once(\'%s\');', $func))); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - return $fond; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Définit des options de compilation du code, |
|
| 60 | - * |
|
| 61 | - * Notamment permet de déclarer des filtres (fonctions) pour le code à compiler |
|
| 62 | - * |
|
| 63 | - * Stocke des options : |
|
| 64 | - * - fonctions : pour ajouter un fichier de fonction au squelette cree (on passe le contenu du fichier) |
|
| 65 | - * - avant_code : pour inserer du contenu avant le code |
|
| 66 | - * - apres_code : pour inserer du contenu apres le code |
|
| 67 | - * |
|
| 68 | - * @param array $options : param->valeur des options |
|
| 69 | - */ |
|
| 70 | - private function setOptions(array $options = []): void { |
|
| 71 | - $this->options = $options; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * Retourne "<?php $code ?>" |
|
| 76 | - * |
|
| 77 | - * @param string $code Code php |
|
| 78 | - * @return string Code php complet |
|
| 79 | - */ |
|
| 80 | - private function php(string $code): string { |
|
| 81 | - return '<' . "?php\n" . $code . "\n?" . '>'; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Ecrire un fichier à l'endroit indique |
|
| 86 | - * |
|
| 87 | - * Le réécrit systématiquement. |
|
| 88 | - * |
|
| 89 | - * @param string $filename Adresse du fichier a ecrire |
|
| 90 | - * @param string $content Contenu du fichier |
|
| 91 | - */ |
|
| 92 | - private function ecrire_fichier(string $filename, string $content): void { |
|
| 93 | - if (file_exists($filename)) { |
|
| 94 | - supprimer_fichier($filename); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - ecrire_fichier($filename, $content); |
|
| 98 | - } |
|
| 9 | + private string $adresse_dernier_fichier_pour_code = ''; |
|
| 10 | + |
|
| 11 | + private string $cacheDirectory = ''; |
|
| 12 | + |
|
| 13 | + private array $options = []; |
|
| 14 | + |
|
| 15 | + public function __construct(array $options = []) { |
|
| 16 | + include_spip('inc/flock'); |
|
| 17 | + $this->cacheDirectory = sous_repertoire(_DIR_CACHE, 'Tests'); |
|
| 18 | + $this->setOptions($options); |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function exists(string $name): bool { |
|
| 22 | + return true; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public function getCacheKey(string $name): string { |
|
| 26 | + return md5($name . serialize($this->options)); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Écrit le code du squelette dans un fichier temporaire de cache |
|
| 31 | + */ |
|
| 32 | + public function getSourceFile(string $name): string { |
|
| 33 | + $fond = $this->cacheDirectory . $this->getCacheKey($name); |
|
| 34 | + $options = $this->options; |
|
| 35 | + $code = $name; |
|
| 36 | + |
|
| 37 | + if (isset($options['avant_code'])) { |
|
| 38 | + $code = $options['avant_code'] . $code; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if (isset($options['apres_code'])) { |
|
| 42 | + $code .= $options['apres_code']; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + $this->ecrire_fichier($fond . '.html', $code); |
|
| 46 | + |
|
| 47 | + if (!empty($options['fonctions'])) { |
|
| 48 | + // un fichier unique pour ces fonctions |
|
| 49 | + $func = $this->cacheDirectory . 'func_' . md5($options['fonctions']) . '.php'; |
|
| 50 | + $this->ecrire_fichier($func, $this->php($options['fonctions'])); |
|
| 51 | + // une inclusion unique de ces fichiers |
|
| 52 | + $this->ecrire_fichier($fond . '_fonctions.php', $this->php(sprintf('include_once(\'%s\');', $func))); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + return $fond; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Définit des options de compilation du code, |
|
| 60 | + * |
|
| 61 | + * Notamment permet de déclarer des filtres (fonctions) pour le code à compiler |
|
| 62 | + * |
|
| 63 | + * Stocke des options : |
|
| 64 | + * - fonctions : pour ajouter un fichier de fonction au squelette cree (on passe le contenu du fichier) |
|
| 65 | + * - avant_code : pour inserer du contenu avant le code |
|
| 66 | + * - apres_code : pour inserer du contenu apres le code |
|
| 67 | + * |
|
| 68 | + * @param array $options : param->valeur des options |
|
| 69 | + */ |
|
| 70 | + private function setOptions(array $options = []): void { |
|
| 71 | + $this->options = $options; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * Retourne "<?php $code ?>" |
|
| 76 | + * |
|
| 77 | + * @param string $code Code php |
|
| 78 | + * @return string Code php complet |
|
| 79 | + */ |
|
| 80 | + private function php(string $code): string { |
|
| 81 | + return '<' . "?php\n" . $code . "\n?" . '>'; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Ecrire un fichier à l'endroit indique |
|
| 86 | + * |
|
| 87 | + * Le réécrit systématiquement. |
|
| 88 | + * |
|
| 89 | + * @param string $filename Adresse du fichier a ecrire |
|
| 90 | + * @param string $content Contenu du fichier |
|
| 91 | + */ |
|
| 92 | + private function ecrire_fichier(string $filename, string $content): void { |
|
| 93 | + if (file_exists($filename)) { |
|
| 94 | + supprimer_fichier($filename); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + ecrire_fichier($filename, $content); |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function getCacheKey(string $name): string { |
| 26 | - return md5($name . serialize($this->options)); |
|
| 26 | + return md5($name.serialize($this->options)); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Écrit le code du squelette dans un fichier temporaire de cache |
| 31 | 31 | */ |
| 32 | 32 | public function getSourceFile(string $name): string { |
| 33 | - $fond = $this->cacheDirectory . $this->getCacheKey($name); |
|
| 33 | + $fond = $this->cacheDirectory.$this->getCacheKey($name); |
|
| 34 | 34 | $options = $this->options; |
| 35 | 35 | $code = $name; |
| 36 | 36 | |
| 37 | 37 | if (isset($options['avant_code'])) { |
| 38 | - $code = $options['avant_code'] . $code; |
|
| 38 | + $code = $options['avant_code'].$code; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | if (isset($options['apres_code'])) { |
| 42 | 42 | $code .= $options['apres_code']; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - $this->ecrire_fichier($fond . '.html', $code); |
|
| 45 | + $this->ecrire_fichier($fond.'.html', $code); |
|
| 46 | 46 | |
| 47 | 47 | if (!empty($options['fonctions'])) { |
| 48 | 48 | // un fichier unique pour ces fonctions |
| 49 | - $func = $this->cacheDirectory . 'func_' . md5($options['fonctions']) . '.php'; |
|
| 49 | + $func = $this->cacheDirectory.'func_'.md5($options['fonctions']).'.php'; |
|
| 50 | 50 | $this->ecrire_fichier($func, $this->php($options['fonctions'])); |
| 51 | 51 | // une inclusion unique de ces fichiers |
| 52 | - $this->ecrire_fichier($fond . '_fonctions.php', $this->php(sprintf('include_once(\'%s\');', $func))); |
|
| 52 | + $this->ecrire_fichier($fond.'_fonctions.php', $this->php(sprintf('include_once(\'%s\');', $func))); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $fond; |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return string Code php complet |
| 79 | 79 | */ |
| 80 | 80 | private function php(string $code): string { |
| 81 | - return '<' . "?php\n" . $code . "\n?" . '>'; |
|
| 81 | + return '<'."?php\n".$code."\n?".'>'; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -8,59 +8,59 @@ |
||
| 8 | 8 | |
| 9 | 9 | class ChainLoader implements LoaderInterface |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * @var LoaderInterface[] |
|
| 13 | - */ |
|
| 14 | - private array $loaders = []; |
|
| 15 | - |
|
| 16 | - private array $cache = []; |
|
| 17 | - |
|
| 18 | - public function __construct(array $loaders) { |
|
| 19 | - foreach ($loaders as $loader) { |
|
| 20 | - $this->addLoader($loader); |
|
| 21 | - } |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function exists(string $name): bool { |
|
| 25 | - if (isset($this->cache[$name])) { |
|
| 26 | - return $this->cache[$name]; |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - foreach ($this->loaders as $loader) { |
|
| 30 | - if ($loader->exists($name)) { |
|
| 31 | - return $this->cache[$name] = true; |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - return $this->cache[$name] = false; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - public function getCacheKey(string $name): string { |
|
| 39 | - foreach ($this->loaders as $loader) { |
|
| 40 | - if (!$loader->exists($name)) { |
|
| 41 | - continue; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - return $loader->getCacheKey($name); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - throw new TemplateNotFoundException($name); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public function getSourceFile(string $name): string { |
|
| 51 | - foreach ($this->loaders as $loader) { |
|
| 52 | - if (!$loader->exists($name)) { |
|
| 53 | - continue; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $loader->getSourceFile($name); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - throw new TemplateNotFoundException($name); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - private function addLoader(LoaderInterface $loader) { |
|
| 63 | - $this->loaders[] = $loader; |
|
| 64 | - $this->cache = []; |
|
| 65 | - } |
|
| 11 | + /** |
|
| 12 | + * @var LoaderInterface[] |
|
| 13 | + */ |
|
| 14 | + private array $loaders = []; |
|
| 15 | + |
|
| 16 | + private array $cache = []; |
|
| 17 | + |
|
| 18 | + public function __construct(array $loaders) { |
|
| 19 | + foreach ($loaders as $loader) { |
|
| 20 | + $this->addLoader($loader); |
|
| 21 | + } |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function exists(string $name): bool { |
|
| 25 | + if (isset($this->cache[$name])) { |
|
| 26 | + return $this->cache[$name]; |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + foreach ($this->loaders as $loader) { |
|
| 30 | + if ($loader->exists($name)) { |
|
| 31 | + return $this->cache[$name] = true; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + return $this->cache[$name] = false; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + public function getCacheKey(string $name): string { |
|
| 39 | + foreach ($this->loaders as $loader) { |
|
| 40 | + if (!$loader->exists($name)) { |
|
| 41 | + continue; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + return $loader->getCacheKey($name); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + throw new TemplateNotFoundException($name); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public function getSourceFile(string $name): string { |
|
| 51 | + foreach ($this->loaders as $loader) { |
|
| 52 | + if (!$loader->exists($name)) { |
|
| 53 | + continue; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $loader->getSourceFile($name); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + throw new TemplateNotFoundException($name); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + private function addLoader(LoaderInterface $loader) { |
|
| 63 | + $this->loaders[] = $loader; |
|
| 64 | + $this->cache = []; |
|
| 65 | + } |
|
| 66 | 66 | } |