MarkdownConverterTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
  9. * - (c) John MacFarlane
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace League\CommonMark\Tests\Unit;
  15. use League\CommonMark\Environment\Environment;
  16. use League\CommonMark\Environment\EnvironmentInterface;
  17. use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
  18. use League\CommonMark\MarkdownConverter;
  19. use PHPUnit\Framework\TestCase;
  20. final class MarkdownConverterTest extends TestCase
  21. {
  22. public function testConstructorAndGetEnvironment(): void
  23. {
  24. $environment = $this->createMock(EnvironmentInterface::class);
  25. $converter = new MarkdownConverter($environment);
  26. $this->assertSame($environment, $converter->getEnvironment());
  27. }
  28. public function testInvokeReturnsSameOutputAsConvert(): void
  29. {
  30. $inputMarkdown = '**Strong**';
  31. $expectedHtml = "<p><strong>Strong</strong></p>\n";
  32. $environment = new Environment();
  33. $environment->addExtension(new CommonMarkCoreExtension());
  34. $converter = new MarkdownConverter($environment);
  35. $this->assertSame($expectedHtml, (string) $converter->convert($inputMarkdown));
  36. $this->assertSame($expectedHtml, (string) $converter($inputMarkdown));
  37. }
  38. }