gl-website-deployer/vendor/doctrine/rst-parser/tests/BuilderInvalidReferences/BuilderInvalidReferencesTest.php

51 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2024-11-19 08:02:04 +01:00
<?php
declare(strict_types=1);
namespace Doctrine\Tests\RST\BuilderInvalidReferences;
use Doctrine\RST\Builder;
use Doctrine\RST\Configuration;
use Doctrine\RST\Kernel;
use Doctrine\Tests\RST\BaseBuilderTest;
use Throwable;
class BuilderInvalidReferencesTest extends BaseBuilderTest
{
/** @var Configuration */
private $configuration;
protected function setUp(): void
{
$this->configuration = new Configuration();
$this->configuration->setUseCachedMetas(false);
$this->configuration->silentOnError(true);
$this->builder = new Builder(new Kernel($this->configuration));
}
public function testInvalidReference(): void
{
$this->expectException(Throwable::class);
$this->expectExceptionMessage('Found invalid reference "does_not_exist" in file "index"');
$this->builder->build($this->sourceFile(), $this->targetFile());
}
public function testInvalidReferenceIgnored(): void
{
$this->configuration->setIgnoreInvalidReferences(true);
$this->builder->build($this->sourceFile(), $this->targetFile());
$contents = $this->getFileContents($this->targetFile('index.html'));
self::assertStringContainsString('<p>Test unresolved reference</p>', $contents);
}
protected function getFixturesDirectory(): string
{
return 'BuilderInvalidReferences';
}
}