/** * @Then /^I should create and download a PDF file$/ */ public function iShouldCreateAndDownloadAPDFFile() { foreach ($this->gist->files() as $file) { $filename = rtrim($file['filename'], '.pdf') . '.pdf'; if (!file_exists($filename)) { throw new Exception("File {$filename} was not found in " . getcwd()); } // verified file exists, now clean up the file unlink($filename); } }
function it_should_create_pdf_files_from_a_given_gist(Gist $gist) { $gist->files()->willReturn([['filename' => 'foo', 'content' => '<h1>bar</h1>']]); $this->beConstructedFromGist($gist); $this->shouldHaveType(Pdf::class); expect(file_exists('foo.pdf'))->toBe(true); }
private function __construct(Gist $gist) { foreach ($gist->files() as $file) { $this->createPdf($file['filename'], $file['content']); } }