From c6b6c6f71f75a0976463d251692c0c04edf0b0b2 Mon Sep 17 00:00:00 2001 From: Mohammad ALTAWEEL Date: Tue, 28 Jun 2022 16:26:54 +0300 Subject: [PATCH] Add test and update README --- README.md | 8 ++++++++ tests/BrowsershotTest.php | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index 522c1875..63be32e6 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,14 @@ Browsershot also can get the body of an html page after JavaScript has been exec Browsershot::url('https://example.com')->bodyHtml(); // returns the html of the body ``` +If you want to set a custom temp path, you can use the `setCustomTempPath` method: + +```php +Browsershot::url('https://example.com') + ->setCustomTempPath(storage_path('browsershot')) + ->pdf(); +``` + If you wish to retrieve an array list with all of the requests that the page triggered you can do so: ```php diff --git a/tests/BrowsershotTest.php b/tests/BrowsershotTest.php index 62a93c5a..ea0f6050 100644 --- a/tests/BrowsershotTest.php +++ b/tests/BrowsershotTest.php @@ -1525,3 +1525,15 @@ ->and($failedRequests[0]['status'])->toBe(404) ->and($failedRequests[0]['url'])->toBe('https://bitsofco.de/broken.jpg/'); }); + +it('can set the custom temp path', function () { + $output = Browsershot::url('https://example.com') + ->setCustomTempPath(__DIR__.'/temp/') + ->pdf(); + + $finfo = finfo_open(); + + $mimeType = finfo_buffer($finfo, $output, FILEINFO_MIME_TYPE); + + expect('application/pdf')->toEqual($mimeType); +});