Skip to content

Commit

Permalink
Test Laravel integration
Browse files Browse the repository at this point in the history
  • Loading branch information
medilies committed Aug 13, 2024
1 parent 63ed838 commit ce11445
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 3 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -74,4 +74,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
16 changes: 16 additions & 0 deletions tests/OrchestraTestCase.php
Original file line number Diff line number Diff line change
@@ -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,
];
}
}
3 changes: 3 additions & 0 deletions tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use PHPUnit\Framework\TestCase;
use Tests\OrchestraTestCase;

uses(TestCase::class)->in(__DIR__.'/unit');

uses(OrchestraTestCase::class)->in(__DIR__.'/laravel');
9 changes: 9 additions & 0 deletions tests/laravel/FacadeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Medilies\Xssless\Laravel\Facades\Xssless;

test('clean()', function () {
expect(Xssless::setup())->toBeTrue();

expect(Xssless::clean('foo'))->toBe('foo');
});
9 changes: 9 additions & 0 deletions tests/laravel/SetupCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use Tests\OrchestraTestCase;

test('xssless:setup', function () {
/** @var OrchestraTestCase $this */
$this->artisan('xssless:setup')
->assertExitCode(0);
});
10 changes: 10 additions & 0 deletions tests/laravel/StartCommandTest.php
Original file line number Diff line number Diff line change
@@ -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);
});
5 changes: 5 additions & 0 deletions tests/laravel/configTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

test('config is loaded', function () {
expect(config('xssless.default'))->toBe('dompurify-cli');
});

0 comments on commit ce11445

Please sign in to comment.