Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ger4003 committed Sep 2, 2021
1 parent 032a6fa commit 5e33781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Fusion/ConvertEmailLinksImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function evaluate()
return $text;
}
if (!is_string($text)) {
throw new Exception(sprintf('Only strings can be processed by this TypoScript object, given: "%s".', gettype($text)), 1409659552);
throw new Exception(sprintf('Only strings can be processed by this Fusion object, given: "%s".', gettype($text)), 1409659552);
}
$currentContext = $this->getRuntime()->getCurrentContext();
$node = $currentContext['node'];
Expand Down
16 changes: 11 additions & 5 deletions Tests/Unit/Fusion/ConvertEmailLinksImplementationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class ConvertEmailLinksImplementationTest extends UnitTestCase
*/
protected $mockNode;

public function setUp()
public function setUp(): void
{
$this->convertEmailLinks = $this->getAccessibleMock(ConvertEmailLinksImplementation::class, ['getValue'], [], '', false);
$this->convertEmailLinks = $this->getAccessibleMock(ConvertEmailLinksImplementation::class, ['fusionValue'], [], '', false);

$this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
$this->mockContext->expects($this->any())->method('getWorkspaceName')->will($this->returnValue('live'));
Expand All @@ -63,7 +63,6 @@ public function setUp()
$linkNameConverter->setReplacementString(' (at) ');
$this->convertEmailLinks->_set('linkNameConverter', $linkNameConverter);
$this->convertEmailLinks->_set('mailToHrefConverter', new Mailto2HrefObfuscatingConverter(15));

}

/**
Expand All @@ -72,13 +71,20 @@ public function setUp()
*/
public function emailsAreConverted($rawText, $expectedText)
{
$this->convertEmailLinks->expects($this->atLeastOnce())->method('getValue')->will($this->returnValue($rawText));
$this->convertEmailLinks
->expects(self::atLeastOnce())
->method('fusionValue')
->will($this->returnValueMap([
['value', $rawText],
['patternMailTo', '/(href=")mailto:([^"]*)/'],
['patternMailDisplay', '/(href="mailto:[^>]*>)([^<]*)/']
]));

$actualResult = $this->convertEmailLinks->evaluate();
$this->assertSame($expectedText, $actualResult);
}

public function emailTexts()
public function emailTexts(): array
{
return [
'just some text not to touch' => [
Expand Down

0 comments on commit 5e33781

Please sign in to comment.