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);
|
exec($this->command($document), $output, $returnVar);
|
||||||
$this->refreshFile();
|
$this->refreshFile();
|
||||||
|
|
||||||
throw_unless($this->file->isFile(), CompilerException::class, 'Compilation failed.');
|
if (!$this->file->isFile()) {
|
||||||
|
throw (new CompilerException('Compilation failed.'))->setOutput($output);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,12 @@ use Exception;
|
||||||
|
|
||||||
class CompilerException extends 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;
|
namespace Zoomyboy\Tex;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Assert;
|
||||||
|
|
||||||
abstract class Document
|
abstract class Document
|
||||||
{
|
{
|
||||||
abstract public function basename(): string;
|
abstract public function basename(): string;
|
||||||
|
@ -19,6 +21,15 @@ abstract class Document
|
||||||
->render();
|
->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assertHasContent(string $content): void
|
||||||
|
{
|
||||||
|
Assert::assertStringContainsString(
|
||||||
|
$content,
|
||||||
|
$this->renderBody(),
|
||||||
|
"Failed asserting that Content contains {$content}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function hasContent(string $content): bool
|
public function hasContent(string $content): bool
|
||||||
{
|
{
|
||||||
return str_contains($this->renderBody(), $content);
|
return str_contains($this->renderBody(), $content);
|
||||||
|
|
Loading…
Reference in New Issue