예제 #1
0
 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);
 }
예제 #2
0
 public function requestFilesFromGist(Gist $gist)
 {
     $client = new Client("https://api.github.com");
     $response = $client->get("/gists/{$gist->getId()}")->send();
     if (!$response->isSuccessful()) {
         throw new \Exception($response->getStatusCode() . ' ' . $response->getReasonPhrase());
     }
     $gist = json_decode($response->getBody(), true);
     return $gist['files'];
 }
예제 #3
0
 /**
  * @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);
     }
 }
예제 #4
0
 function it_can_request_files_from_a_gist(Gist $gist)
 {
     $gist->getId()->willReturn('bb7628ad34c699392f9c');
     $this->requestFilesFromGist($gist)->shouldBeArray();
 }
예제 #5
0
 private function __construct(Gist $gist)
 {
     foreach ($gist->files() as $file) {
         $this->createPdf($file['filename'], $file['content']);
     }
 }