MarkdownInputWithFrontMatterTest.php 1017 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. * This file is part of the league/commonmark package.
  4. *
  5. * (c) Colin O'Dell <colinodell@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace League\CommonMark\Tests\Unit\Extension\FrontMatter\Input;
  12. use League\CommonMark\Extension\FrontMatter\Input\MarkdownInputWithFrontMatter;
  13. use PHPUnit\Framework\TestCase;
  14. final class MarkdownInputWithFrontMatterTest extends TestCase
  15. {
  16. public function testConstructorAndGetters(): void
  17. {
  18. $input = new MarkdownInputWithFrontMatter("this\nis\na\ntest\n", 3, ['foo' => 'bar']);
  19. $this->assertSame("this\nis\na\ntest\n", $input->getContent());
  20. $lines = $input->getLines();
  21. \assert($lines instanceof \Traversable);
  22. $this->assertSame([4 => 'this', 5 => 'is', 6 => 'a', 7 => 'test'], \iterator_to_array($lines));
  23. $this->assertSame(['foo' => 'bar'], $input->getFrontMatter());
  24. }
  25. }