-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable calling convertToHtml as a function
Adding Converter::__invoke as an alias to Converter::convertToHtml to enable calling Converter object as functions resolves #233
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace League\CommonMark\Tests\Unit; | ||
|
||
use League\CommonMark\Converter; | ||
use PHPUnit_Framework_MockObject_MockObject; | ||
|
||
class ConverterTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testInvokeReturnsSameOutputAsConvertToHtml() | ||
{ | ||
$inputMarkdown = '**Strong**'; | ||
$expectedHtml = '<strong>Strong</strong>'; | ||
|
||
/** @var Converter|PHPUnit_Framework_MockObject_MockObject $converter */ | ||
$converter = $this->getMockBuilder('League\CommonMark\Converter') | ||
->disableOriginalConstructor() | ||
->setMethods(['convertToHtml']) | ||
->getMock(); | ||
$converter->method('convertToHtml')->with($inputMarkdown)->willReturn($expectedHtml); | ||
|
||
$this->assertSame($expectedHtml, $converter($inputMarkdown)); | ||
} | ||
} |