Init
This commit is contained in:
23 files changed
+1216
No files matched your search
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Mattitja\BadIpBlocker\Tests;
|
||||
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Mattitja\BadIpBlocker\BadIpBlockerServiceProvider;
|
||||
use Mattitja\BadIpBlocker\Facades\BadIpBlocker;
|
||||
use Orchestra\Testbench\TestCase as Orchestra;
|
||||
|
||||
abstract class TestCase extends Orchestra
|
||||
{
|
||||
protected string $storageDir;
|
||||
|
||||
protected function getPackageProviders($app): array
|
||||
{
|
||||
return [BadIpBlockerServiceProvider::class];
|
||||
}
|
||||
|
||||
protected function getPackageAliases($app): array
|
||||
{
|
||||
return ['BadIpBlocker' => BadIpBlocker::class];
|
||||
}
|
||||
|
||||
protected function defineEnvironment($app): void
|
||||
{
|
||||
$this->storageDir = sys_get_temp_dir().'/bad-ip-blocker-tests-'.bin2hex(random_bytes(4));
|
||||
|
||||
$app['config']->set('bad-ip-blocker.storage_path', $this->storageDir.'/bad-ips.json');
|
||||
$app['config']->set('cache.default', 'array');
|
||||
}
|
||||
|
||||
protected function defineRoutes($router): void
|
||||
{
|
||||
$router->get('/', fn () => 'ok');
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
File::deleteDirectory($this->storageDir);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function getFrom(string $uri, string $ip)
|
||||
{
|
||||
return $this->withServerVariables(['REMOTE_ADDR' => $ip])->get($uri);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user