[TASK] Integrate basic TypoScript parsing test 91/19491/2
authorOliver Hader <oliver@typo3.org>
Mon, 1 Apr 2013 14:03:14 +0000 (16:03 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Mon, 1 Apr 2013 14:06:26 +0000 (16:06 +0200)
Resolves: #46839
Releases: 6.0, 6.1
Change-Id: I3dd007908bbd127386b86dd0f31e927c1034bb97
Reviewed-on: https://review.typo3.org/19491
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php

index 51bc89b..41c16f3 100644 (file)
@@ -240,5 +240,142 @@ class TypoScriptParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertEquals($expected, $actualValue);
        }
 
+       /**
+        * @param string $typoScript
+        * @param array $expected
+        * @dataProvider typoScriptIsParsedToArrayDataProvider
+        * @test
+        */
+       public function typoScriptIsParsedToArray($typoScript, array $expected) {
+               $this->typoScriptParser->parse($typoScript);
+               $this->assertEquals($expected, $this->typoScriptParser->setup);
+       }
+
+       /**
+        * @param string $typoScript
+        * @param array $expected
+        * @dataProvider typoScriptIsParsedToArrayDataProvider
+        * @test
+        */
+       public function typoScriptIsStrictlyParsedToArray($typoScript, array $expected) {
+               $this->typoScriptParser->strict = TRUE;
+               $this->typoScriptParser->parse($typoScript);
+               $this->assertEquals($expected, $this->typoScriptParser->setup);
+       }
+
+       /**
+        * @return array
+        */
+       public function typoScriptIsParsedToArrayDataProvider() {
+               return array(
+                       'simple assignment' => array(
+                               'key = value',
+                               array(
+                                       'key' => 'value',
+                               )
+                       ),
+                       'nested assignment' => array(
+                               'lib.key = value',
+                               array(
+                                       'lib.' => array(
+                                               'key' => 'value',
+                                       ),
+                               ),
+                       ),
+                       'nested structured assignment' => array(
+                               'lib {' . LF .
+                                       'key = value' . LF .
+                               '}',
+                               array(
+                                       'lib.' => array(
+                                               'key' => 'value',
+                                       ),
+                               ),
+                       ),
+                       'multiline assignment' => array(
+                               'key (' . LF .
+                                       'first' . LF .
+                                       'second' . LF .
+                               ')',
+                               array(
+                                       'key' => 'first' . LF . 'second',
+                               ),
+                       ),
+                       'copying values' => array(
+                               'lib.default = value' . LF .
+                               'lib.copy < lib.default',
+                               array(
+                                       'lib.' => array(
+                                               'default' => 'value',
+                                               'copy' => 'value',
+                                       ),
+                               ),
+                       ),
+                       'one-line hash comment' => array(
+                               'first = 1' . LF .
+                               '# ignore = me' . LF .
+                               'second = 2',
+                               array(
+                                       'first' => '1',
+                                       'second' => '2',
+                               ),
+                       ),
+                       'one-line slash comment' => array(
+                               'first = 1' . LF .
+                               '// ignore = me' . LF .
+                               'second = 2',
+                               array(
+                                       'first' => '1',
+                                       'second' => '2',
+                               ),
+                       ),
+                       'multi-line slash comment' => array(
+                               'first = 1' . LF .
+                               '/*' . LF .
+                                       'ignore = me' . LF .
+                               '*/' . LF .
+                               'second = 2',
+                               array(
+                                       'first' => '1',
+                                       'second' => '2',
+                               ),
+                       ),
+                       'CSC example #1' => array(
+                               'linkParams.ATagParams.dataWrap =  class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"',
+                               array(
+                                       'linkParams.' => array(
+                                               'ATagParams.' => array(
+                                                       'dataWrap' => 'class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"',
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       'CSC example #2' => array(
+                               'linkParams.ATagParams {' . LF .
+                                       'dataWrap = class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"' . LF .
+                               '}',
+                               array(
+                                       'linkParams.' => array(
+                                               'ATagParams.' => array(
+                                                       'dataWrap' => 'class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"',
+                                               ),
+                                       ),
+                               ),
+                       ),
+                       'CSC example #3' => array(
+                               'linkParams.ATagParams.dataWrap (' . LF .
+                                       'class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"' . LF .
+                               ')',
+                               array(
+                                       'linkParams.' => array(
+                                               'ATagParams.' => array(
+                                                       'dataWrap' => 'class="{$styles.content.imgtext.linkWrap.lightboxCssClass}" rel="{$styles.content.imgtext.linkWrap.lightboxRelAttribute}"',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+       }
+
 }
 ?>
\ No newline at end of file