DocumentTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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\Node\Block;
  15. use League\CommonMark\Node\Block\AbstractBlock;
  16. use League\CommonMark\Node\Block\Document;
  17. use League\CommonMark\Parser\Cursor;
  18. use League\CommonMark\Reference\ReferenceMap;
  19. use League\CommonMark\Reference\ReferenceMapInterface;
  20. use PHPUnit\Framework\TestCase;
  21. final class DocumentTest extends TestCase
  22. {
  23. public function testDefaultConstructorAndGetReferenceMap(): void
  24. {
  25. $document = new Document();
  26. $this->assertInstanceOf(ReferenceMap::class, $document->getReferenceMap());
  27. }
  28. public function testReferenceMapPassedIntoConstructor(): void
  29. {
  30. $map = $this->createMock(ReferenceMapInterface::class);
  31. $document = new Document($map);
  32. $this->assertSame($map, $document->getReferenceMap());
  33. }
  34. public function testCanContain(): void
  35. {
  36. $document = new Document();
  37. $block = $this->createMock(AbstractBlock::class);
  38. $this->assertTrue($document->canContain($block));
  39. }
  40. public function testIsCode(): void
  41. {
  42. $document = new Document();
  43. $this->assertFalse($document->isCode());
  44. }
  45. public function testMatchesNextLine(): void
  46. {
  47. $document = new Document();
  48. $cursor = $this->createMock(Cursor::class);
  49. $this->assertTrue($document->matchesNextLine($cursor));
  50. }
  51. }