mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
Merge pull request #1174 from ClaraLeigh/feat/presets
feature(presets): Add security preset
This commit is contained in:
29
src/ArchPresets/Security.php
Normal file
29
src/ArchPresets/Security.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\ArchPresets;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Security extends AbstractPreset
|
||||
{
|
||||
/**
|
||||
* Executes the arch preset.
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
$this->expectations[] = expect([
|
||||
'md5',
|
||||
'sha1',
|
||||
'uniqid',
|
||||
'rand',
|
||||
'mt_rand',
|
||||
'tempnam',
|
||||
'str_shuffle',
|
||||
'shuffle',
|
||||
'array_rand'
|
||||
])->not->toBeUsed();
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ use Pest\Arch\Support\Composer;
|
||||
use Pest\ArchPresets\AbstractPreset;
|
||||
use Pest\ArchPresets\Base;
|
||||
use Pest\ArchPresets\Strict;
|
||||
use Pest\ArchPresets\Security;
|
||||
use Pest\PendingCalls\TestCall;
|
||||
use stdClass;
|
||||
|
||||
@ -47,6 +48,14 @@ final class Preset
|
||||
return $this->executePreset(new Strict($this->baseNamespaces()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses the Pest security preset and returns the test call instance.
|
||||
*/
|
||||
public function security(): AbstractPreset
|
||||
{
|
||||
return $this->executePreset(new Security($this->baseNamespaces()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the given preset.
|
||||
*
|
||||
|
||||
@ -11,6 +11,8 @@ arch()->preset()->base()->ignoring([
|
||||
|
||||
arch()->preset()->strict();
|
||||
|
||||
arch()->preset()->security();
|
||||
|
||||
arch('globals')
|
||||
->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep'])
|
||||
->not->toBeUsed()
|
||||
|
||||
Reference in New Issue
Block a user