-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Tests\Mocks; | ||
|
||
use Medilies\Xssless\Interfaces\ConfigInterface; | ||
use stdClass; | ||
|
||
class NoInterfaceConfig implements ConfigInterface | ||
{ | ||
public function getClass(): string | ||
{ | ||
return stdClass::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Tests\Mocks; | ||
|
||
use Medilies\Xssless\Interfaces\CliInterface; | ||
use Medilies\Xssless\Interfaces\ConfigInterface; | ||
|
||
class NoSetupDriver implements CliInterface | ||
{ | ||
public function configure(ConfigInterface $config): static | ||
{ | ||
return $this; | ||
} | ||
|
||
public function exec(string $html): string | ||
{ | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Tests\Mocks; | ||
|
||
use Medilies\Xssless\Interfaces\ConfigInterface; | ||
|
||
class NoSetupDriverConfig implements ConfigInterface | ||
{ | ||
public function getClass(): string | ||
{ | ||
return NoSetupDriver::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
<?php | ||
|
||
use Medilies\Xssless\Exceptions\XsslessException; | ||
use Medilies\Xssless\Laravel\Facades\Xssless; | ||
|
||
test('clean()', function () { | ||
expect(Xssless::setup())->toBeTrue(); | ||
|
||
expect(Xssless::clean('foo'))->toBe('foo'); | ||
}); | ||
|
||
it('throws when usingLaravelConfig() with no default driver', function () { | ||
config([ | ||
'xssless.default' => null, | ||
]); | ||
|
||
expect(fn () => Xssless::usingLaravelConfig())->toThrow(XsslessException::class); | ||
}); | ||
|
||
it('throws when usingLaravelConfig() with bad default driver', function () { | ||
config([ | ||
'xssless.default' => 'x', | ||
'xssless.drivers.x' => new stdClass, | ||
]); | ||
|
||
expect(fn () => Xssless::usingLaravelConfig())->toThrow(XsslessException::class); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
<?php | ||
|
||
use Tests\Mocks\NoSetupDriverConfig; | ||
use Tests\OrchestraTestCase; | ||
|
||
test('xssless:setup', function () { | ||
/** @var OrchestraTestCase $this */ | ||
$this->artisan('xssless:setup') | ||
->expectsOutput('Setup done.') | ||
->assertExitCode(0); | ||
}); | ||
|
||
test('NoSetupDriverConfig', function () { | ||
config([ | ||
'xssless.default' => 'no-setup', | ||
'xssless.drivers.no-setup' => new NoSetupDriverConfig, | ||
]); | ||
|
||
$this->artisan('xssless:setup') | ||
->expectsOutput('The current driver has no setup.') | ||
->assertExitCode(0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters