summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Light <sam@lightscale.co.uk>2025-03-30 22:25:24 +0100
committerSam Light <samlight1994@gmail.com>2025-03-30 22:25:24 +0100
commitd80d1d27c3a5dcea6f341e0bc29653acfde6b5ea (patch)
tree38b3af07b54cb1c3f1c4b0fffef4c7bbb60181be
parent429901b5871707b5c3be911c67fb1a38df04ee30 (diff)
Setup some basic tests
-rw-r--r--tests/Feature/ManifestTest.php7
-rw-r--r--tests/Pest.php17
-rw-r--r--tests/TestCase.php21
-rw-r--r--tests/Unit/ManifestParserTest.php11
4 files changed, 56 insertions, 0 deletions
diff --git a/tests/Feature/ManifestTest.php b/tests/Feature/ManifestTest.php
new file mode 100644
index 0000000..a9e1108
--- /dev/null
+++ b/tests/Feature/ManifestTest.php
@@ -0,0 +1,7 @@
+<?php
+
+use Lightscale\LaralightAssets\Manifest;
+
+it('instantiates', function() {
+ new Manifest('test.json', '/dist');
+})->throwsNoExceptions();
diff --git a/tests/Pest.php b/tests/Pest.php
new file mode 100644
index 0000000..a761fb0
--- /dev/null
+++ b/tests/Pest.php
@@ -0,0 +1,17 @@
+<?php
+
+use Lightscale\LaralightAssets\Tests\TestCase;
+
+/*
+|--------------------------------------------------------------------------
+| Test Case
+|--------------------------------------------------------------------------
+|
+| The closure you provide to your test functions is always bound to a specific PHPUnit test
+| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
+| need to change it using the "pest()" function to bind a different classes or traits.
+|
+*/
+
+pest()->extend(TestCase::class)
+ ->in('Feature');
diff --git a/tests/TestCase.php b/tests/TestCase.php
new file mode 100644
index 0000000..584d026
--- /dev/null
+++ b/tests/TestCase.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Lightscale\LaralightAssets\Tests;
+
+use Lightscale\LaralightAssets\AssetsServiceProvider;
+
+use Orchestra\Testbench\TestCase as Orchestra;
+use Orchestra\Testbench\Concerns\WithWorkbench;
+use function Orchestra\Testbench\workbench_path;
+
+class TestCase extends Orchestra
+{
+ use WithWorkbench;
+
+ protected function getPackageProviders($app)
+ {
+ return [
+ AssetsServiceProvider::class,
+ ];
+ }
+}
diff --git a/tests/Unit/ManifestParserTest.php b/tests/Unit/ManifestParserTest.php
new file mode 100644
index 0000000..fe88daa
--- /dev/null
+++ b/tests/Unit/ManifestParserTest.php
@@ -0,0 +1,11 @@
+<?php
+
+use Lightscale\LaralightAssets\JsonManifestParser;
+
+it('parses json', function() {
+ $data = '{"main.js": "main.testing.js"}';
+ $parser = new JsonManifestParser;
+ $result = $parser->parse($data);
+
+ expect($result)->toMatchArray(['main.js' => 'main.testing.js']);
+});