Skip to content
This repository has been archived by the owner on Oct 29, 2018. It is now read-only.

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed Jun 19, 2017
2 parents 7a6064f + 11586a5 commit 94bbcd4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Classes/Service/AfxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected static function astNodeToFusion($payload, $indentation = '')
$childrenPropertyName = 'content';
}
$childFusion = self::astNodeListToFusion($payload['children'], $indentation . self::INDENTATION);
if ($childFusion !== null) {
if ($childFusion) {
$fusion .= $indentation . self::INDENTATION . $childrenPropertyName . ' = ' . $childFusion . PHP_EOL;
}
}
Expand Down Expand Up @@ -202,7 +202,7 @@ protected static function astNodeListToFusion($payload, $indentation = '')
});

if (count($payload) == 0) {
return '';
return '\'\'';
} elseif (count($payload) == 1) {
return self::astToFusion(array_shift($payload), $indentation);
} else {
Expand Down
34 changes: 34 additions & 0 deletions Tests/Functional/AfxServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function emptyCodeConvertedToEmptyFusion()
{
$afxCode = '';
$expectedFusion = <<<'EOF'
''
EOF;
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}
Expand All @@ -25,6 +26,7 @@ public function whitepaceCodeIsConvertedToEmptyFusion()
{
$afxCode = ' ';
$expectedFusion = <<<'EOF'
''
EOF;
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}
Expand All @@ -43,6 +45,38 @@ public function htmlTagsAreConvertedToFusionTags()
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}

/**
* @test
*/
public function htmlTagsWithSpaceContentAreConvertedToFusionTags()
{
$afxCode = '<h1> </h1>';
$expectedFusion = <<<'EOF'
Neos.Fusion:Tag {
tagName = 'h1'
content = ' '
}
EOF;
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}

/**
* @test
*/
public function htmlTagsWithIgnoredContentAreConvertedToFusionTags()
{
$afxCode = '<h1>
</h1>';
$expectedFusion = <<<'EOF'
Neos.Fusion:Tag {
tagName = 'h1'
content = ''
}
EOF;
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}

/**
* @test
*/
Expand Down

0 comments on commit 94bbcd4

Please sign in to comment.