ldc-sitemap-generator/tests/TestCase.php

68 lines
2 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
namespace Uwil\SitemapGenerator\Tests;
use Illuminate\Support\Facades\File;
use Orchestra\Testbench\TestCase as Orchestra;
use Uwil\SitemapGenerator\Config\SitemapConfig;
use Uwil\SitemapGenerator\SitemapGeneratorServiceProvider;
use Spatie\Sitemap\SitemapServiceProvider;
abstract class TestCase extends Orchestra
{
public string $outputDisk;
public string $outputPath;
#[\Override]
protected function setUp(): void
{
$this->outputDisk = 'local';
$this->outputPath = __DIR__ . '/temp/sitemap.xml';
parent::setUp();
File::ensureDirectoryExists(dirname($this->outputPath));
}
#[\Override]
protected function tearDown(): void
{
if (File::exists($this->outputPath)) {
File::delete($this->outputPath);
}
parent::tearDown();
}
#[\Override]
protected function getPackageProviders($app): array
{
return [
SitemapGeneratorServiceProvider::class,
SitemapServiceProvider::class,
];
}
#[\Override]
protected function defineEnvironment($app): void
{
$app['config']->set('database.default', 'testing');
$app['config']->set('database.connections.testing', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.output.storage_disk', $this->outputDisk);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.output.path', $this->outputPath);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.supported_locales', ['fr', 'en']);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.single_pages', []);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.cruds', []);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.cron', '45 15 * * *');
$app['config']->set(SitemapConfig::CONFIG_KEY . '.schedule', false);
$app['config']->set(SitemapConfig::CONFIG_KEY . '.localizer', 'default');
}
}