diff --git a/.gitignore b/.gitignore
index e6bb23c..d858abb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,6 @@ coverage
phpunit.xml
phpstan.neon
node_modules/
-testbench.yaml
vendor
node_modules
tests/TestSupport/temp/
diff --git a/composer.json b/composer.json
index a5c7bdc..e1d7fb7 100644
--- a/composer.json
+++ b/composer.json
@@ -52,19 +52,17 @@
},
"autoload-dev": {
"psr-4": {
- "Spatie\\LaravelPdf\\Tests\\": "tests/",
- "Workbench\\App\\": "workbench/app/"
+ "Spatie\\LaravelPdf\\Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
- "clear": "@php vendor/bin/testbench package:purge-laravel-pdf --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
"@php vendor/bin/testbench workbench:build --ansi"
],
- "start": [
+ "serve": [
"Composer\\Config::disableProcessTimeout",
"@composer run build",
"@php vendor/bin/testbench serve"
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 5235005..cd42cea 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -28,4 +28,7 @@
./src
+
+
+
diff --git a/testbench.yaml b/testbench.yaml
new file mode 100644
index 0000000..13b650d
--- /dev/null
+++ b/testbench.yaml
@@ -0,0 +1,8 @@
+providers:
+ - Spatie\LaravelPdf\PdfServiceProvider
+ # - Workbench\App\Providers\WorkbenchServiceProvider
+
+workbench:
+ discovers:
+ web: true
+ views: true
diff --git a/tests/FakePdfTest.php b/tests/FakePdfTest.php
index 51b18fe..8bc7372 100644
--- a/tests/FakePdfTest.php
+++ b/tests/FakePdfTest.php
@@ -4,8 +4,6 @@
use Spatie\LaravelPdf\Facades\Pdf;
use Spatie\LaravelPdf\PdfBuilder;
-use function Spatie\LaravelPdf\Support\pdf;
-
beforeEach(function () {
Pdf::fake();
});
diff --git a/tests/PdfReponseTest.php b/tests/PdfReponseTest.php
index 28d1275..50ee83b 100644
--- a/tests/PdfReponseTest.php
+++ b/tests/PdfReponseTest.php
@@ -1,14 +1,6 @@
inline('my-custom-name.pdf');
- });
-
$this
->get('inline-pdf')
->assertHeader('content-type', 'application/pdf')
@@ -16,10 +8,6 @@
});
it('can download the pdf', function () {
- Route::get('download-pdf', function () {
- return pdf('test')->download('my-custom-name.pdf');
- });
-
$this
->get('download-pdf')
->assertHeader('content-type', 'application/pdf')
@@ -27,21 +15,14 @@
});
it('will tack on pdf to the filename if it is missing', function (string $method) {
- Route::get('pdf', function () use ($method) {
- return pdf('test')->{$method}('my-custom-name');
- });
-
$headerMethod = $method === 'inline' ? 'inline' : 'attachment';
$this
- ->get('pdf')
+ ->get("pdf/{$method}")
->assertHeader('content-disposition', $headerMethod.'; filename="my-custom-name.pdf"');
})->with(['inline', 'download']);
it('will inline the pdf by default', function () {
- Route::get('pdf', function () {
- return pdf('test')->name('my-custom-name.pdf');
- });
$this
->get('pdf')
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 8b30e85..400d4b0 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -2,22 +2,10 @@
namespace Spatie\LaravelPdf\Tests;
+use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as Orchestra;
-use Spatie\LaravelPdf\PdfServiceProvider;
class TestCase extends Orchestra
{
- protected function setUp(): void
- {
- parent::setUp();
-
- $this->app->view->addLocation(__DIR__.'/TestSupport/Views');
- }
-
- protected function getPackageProviders($app)
- {
- return [
- PdfServiceProvider::class,
- ];
- }
+ use WithWorkbench;
}
diff --git a/workbench/app/Providers/WorkbenchServiceProvider.php b/workbench/app/Providers/WorkbenchServiceProvider.php
index 001d06d..e8cec9c 100644
--- a/workbench/app/Providers/WorkbenchServiceProvider.php
+++ b/workbench/app/Providers/WorkbenchServiceProvider.php
@@ -2,7 +2,6 @@
namespace Workbench\App\Providers;
-use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
class WorkbenchServiceProvider extends ServiceProvider
@@ -20,6 +19,6 @@ public function register(): void
*/
public function boot(): void
{
- Route::view('/', 'welcome');
+ //
}
}
diff --git a/tests/TestSupport/Views/another-test.blade.php b/workbench/resources/views/another-test.blade.php
similarity index 100%
rename from tests/TestSupport/Views/another-test.blade.php
rename to workbench/resources/views/another-test.blade.php
diff --git a/tests/TestSupport/Views/footer.blade.php b/workbench/resources/views/footer.blade.php
similarity index 100%
rename from tests/TestSupport/Views/footer.blade.php
rename to workbench/resources/views/footer.blade.php
diff --git a/tests/TestSupport/Views/header.blade.php b/workbench/resources/views/header.blade.php
similarity index 100%
rename from tests/TestSupport/Views/header.blade.php
rename to workbench/resources/views/header.blade.php
diff --git a/tests/TestSupport/Views/test.blade.php b/workbench/resources/views/test.blade.php
similarity index 100%
rename from tests/TestSupport/Views/test.blade.php
rename to workbench/resources/views/test.blade.php
diff --git a/workbench/routes/web.php b/workbench/routes/web.php
new file mode 100644
index 0000000..f74d858
--- /dev/null
+++ b/workbench/routes/web.php
@@ -0,0 +1,36 @@
+{$method}('my-custom-name');
+});
+
+Route::get('pdf', function () {
+ return pdf('test')->name('my-custom-name.pdf');
+});
+
+Route::get('inline-pdf', function () {
+ return pdf('test')->inline('my-custom-name.pdf');
+});
+
+Route::get('download-pdf', function () {
+ return pdf('test')->download('my-custom-name.pdf');
+});