Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
67
vendor/doctrine/rst-parser/tests/FileIncluderTest.php
vendored
Normal file
67
vendor/doctrine/rst-parser/tests/FileIncluderTest.php
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Tests\RST;
|
||||
|
||||
use Doctrine\RST\Environment;
|
||||
use Doctrine\RST\FileIncluder;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
use function trim;
|
||||
|
||||
class FileIncluderTest extends TestCase
|
||||
{
|
||||
/** @var Environment|MockObject */
|
||||
private $environment;
|
||||
|
||||
public function testInclude(): void
|
||||
{
|
||||
$this->environment->expects(self::once())
|
||||
->method('absoluteRelativePath')
|
||||
->with('include.rst')
|
||||
->willReturn(__DIR__ . '/Parser/files/include.rst');
|
||||
|
||||
$fileIncluder = new FileIncluder($this->environment, true, __DIR__ . '/Parser/files');
|
||||
|
||||
$contents = $fileIncluder->includeFiles('.. include:: include.rst');
|
||||
|
||||
self::assertSame('I was actually included', trim($contents));
|
||||
}
|
||||
|
||||
public function testIncludeWithEmptyIncludeRoot(): void
|
||||
{
|
||||
$this->environment->expects(self::once())
|
||||
->method('absoluteRelativePath')
|
||||
->with('include.rst')
|
||||
->willReturn(__DIR__ . '/Parser/files/include.rst');
|
||||
|
||||
$fileIncluder = new FileIncluder($this->environment, true, '');
|
||||
|
||||
$contents = $fileIncluder->includeFiles('.. include:: include.rst');
|
||||
|
||||
self::assertSame('I was actually included', trim($contents));
|
||||
}
|
||||
|
||||
public function testShouldThrowExceptionOnInvalidFileInclude(): void
|
||||
{
|
||||
$this->environment->expects(self::once())
|
||||
->method('absoluteRelativePath')
|
||||
->with('non-existent-file.rst')
|
||||
->willReturn('non-existent-file.rst');
|
||||
|
||||
$fileIncluder = new FileIncluder($this->environment, true, '');
|
||||
|
||||
$this->expectException(RuntimeException::class);
|
||||
$this->expectExceptionMessage('Include ".. include:: non-existent-file.rst" does not exist or is not readable.');
|
||||
|
||||
$fileIncluder->includeFiles('.. include:: non-existent-file.rst');
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->environment = $this->createMock(Environment::class);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue