Specify output for compilerException
This commit is contained in:
parent
fb9d7a660c
commit
ae4d9f74ef
|
@ -25,7 +25,9 @@ abstract class BaseCompiler implements Responsable
|
|||
exec($this->command($document), $output, $returnVar);
|
||||
$this->refreshFile();
|
||||
|
||||
throw_unless($this->file->isFile(), CompilerException::class, 'Compilation failed.');
|
||||
if (!$this->file->isFile()) {
|
||||
throw (new CompilerException('Compilation failed.'))->setOutput($output);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -6,4 +6,12 @@ use Exception;
|
|||
|
||||
class CompilerException extends Exception
|
||||
{
|
||||
public string $output;
|
||||
|
||||
public function setOutput(array $output): self
|
||||
{
|
||||
$this->output = implode("\n", $output);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zoomyboy\Tex;
|
||||
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
abstract class Document
|
||||
{
|
||||
abstract public function basename(): string;
|
||||
|
@ -19,6 +21,15 @@ abstract class Document
|
|||
->render();
|
||||
}
|
||||
|
||||
public function assertHasContent(string $content): void
|
||||
{
|
||||
Assert::assertStringContainsString(
|
||||
$content,
|
||||
$this->renderBody(),
|
||||
"Failed asserting that Content contains {$content}"
|
||||
);
|
||||
}
|
||||
|
||||
public function hasContent(string $content): bool
|
||||
{
|
||||
return str_contains($this->renderBody(), $content);
|
||||
|
|
Loading…
Reference in New Issue