- Introduced SitemapStorage class for reading, writing, and checking existence of sitemap files. - Updated GenerateSitemapCommand to utilize SitemapStorage for file operations. - Refactored tests to accommodate changes in sitemap file handling. - Enhanced configuration to support output paths and storage disks.
67 lines
2 KiB
PHP
67 lines
2 KiB
PHP
<?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');
|
|
}
|
|
}
|