ldc-sitemap-generator/tests/TestCase.php

65 lines
1.9 KiB
PHP
Raw 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 $testXmlPath;
#[\Override]
protected function setUp(): void
{
$this->testXmlPath = __DIR__ . '/temp/sitemap.xml';
parent::setUp();
File::ensureDirectoryExists(dirname($this->testXmlPath));
}
#[\Override]
protected function tearDown(): void
{
if (File::exists($this->testXmlPath)) {
File::delete($this->testXmlPath);
}
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_path', $this->testXmlPath);
$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');
}
}