diff --git a/composer.json b/composer.json index 30f2877..55d9fdb 100644 --- a/composer.json +++ b/composer.json @@ -30,13 +30,13 @@ "laravel/framework": "^11 || 10", "laravel/pint": "^1.14", "nunomaduro/collision": "^8.1.1||^7.10.0", + "orchestra/testbench": "^9.2", "pestphp/pest": "^2.34", "pestphp/pest-plugin-arch": "^2.7", "phpstan/extension-installer": "^1.3", "phpstan/phpstan": "^1.11", "phpstan/phpstan-deprecation-rules": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "symfony/var-dumper": "^7.1" + "phpstan/phpstan-phpunit": "^1.3" }, "autoload": { "psr-4": { @@ -74,4 +74,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} \ No newline at end of file +} diff --git a/tests/OrchestraTestCase.php b/tests/OrchestraTestCase.php new file mode 100644 index 0000000..7b19e64 --- /dev/null +++ b/tests/OrchestraTestCase.php @@ -0,0 +1,16 @@ +<?php + +namespace Tests; + +use Medilies\Xssless\Laravel\XsslessServiceProvider; +use Orchestra\Testbench\TestCase as Orchestra; + +class OrchestraTestCase extends Orchestra +{ + protected function getPackageProviders($app) + { + return [ + XsslessServiceProvider::class, + ]; + } +} diff --git a/tests/Pest.php b/tests/Pest.php index 6799f9c..fd58caa 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,8 @@ <?php use PHPUnit\Framework\TestCase; +use Tests\OrchestraTestCase; uses(TestCase::class)->in(__DIR__.'/unit'); + +uses(OrchestraTestCase::class)->in(__DIR__.'/laravel'); diff --git a/tests/laravel/FacadeTest.php b/tests/laravel/FacadeTest.php new file mode 100644 index 0000000..8f12b4a --- /dev/null +++ b/tests/laravel/FacadeTest.php @@ -0,0 +1,7 @@ +<?php + +use Medilies\Xssless\Laravel\Facades\Xssless; + +test('clean()', function () { + expect(Xssless::clean('foo'))->toBe('foo'); +}); diff --git a/tests/laravel/SetupCommandTest.php b/tests/laravel/SetupCommandTest.php new file mode 100644 index 0000000..94ab8dd --- /dev/null +++ b/tests/laravel/SetupCommandTest.php @@ -0,0 +1,9 @@ +<?php + +use Tests\OrchestraTestCase; + +test('xssless:setup', function () { + /** @var OrchestraTestCase $this */ + $this->artisan('xssless:setup') + ->assertExitCode(0); +}); diff --git a/tests/laravel/StartCommandTest.php b/tests/laravel/StartCommandTest.php new file mode 100644 index 0000000..7196c3b --- /dev/null +++ b/tests/laravel/StartCommandTest.php @@ -0,0 +1,10 @@ +<?php + +use Tests\OrchestraTestCase; + +test('xssless:start with non-startable driver', function () { + /** @var OrchestraTestCase $this */ + $this->artisan('xssless:start') + ->expectsOutput('The current driver is not a service to start.') + ->assertExitCode(0); +}); diff --git a/tests/laravel/configTest.php b/tests/laravel/configTest.php new file mode 100644 index 0000000..c94a767 --- /dev/null +++ b/tests/laravel/configTest.php @@ -0,0 +1,5 @@ +<?php + +test('config is loaded', function () { + expect(config('xssless.default'))->toBe('dompurify-cli'); +});