loadEnvironmentFrom('.env.example'); $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); $compiledPath = sys_get_temp_dir().'/moonwell-sitemap-'.bin2hex(random_bytes(8)); mkdir($compiledPath); config(['app.url' => 'https://moon-well.online', 'view.compiled' => $compiledPath]); try { $app['blade.compiler']->compile(resource_path('views/seo/sitemap.blade.php')); echo view('seo.sitemap', [ 'seo' => app(App\Services\SeoService::class), 'articles' => collect([(new App\Models\News)->forceFill([ 'id' => 42, 'updated_at' => '2026-10-20 12:00:00', ])]), ])->render(); } finally { (new Illuminate\Filesystem\Filesystem)->deleteDirectory($compiledPath); } PHP; $process = new Process([PHP_BINARY, '-d', 'short_open_tag='.$setting, '-r', $script, base_path()]); $process->run(); $this->assertTrue($process->isSuccessful(), $process->getErrorOutput().$process->getOutput()); $this->assertStringStartsWith('', $process->getOutput()); $xml = simplexml_load_string($process->getOutput()); $this->assertNotFalse($xml); $xml->registerXPathNamespace('s', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $this->assertSame('https://moon-well.online/news/42', (string) $xml->xpath('//s:url[3]/s:loc')[0]); $this->assertSame('2026-10-20T12:00:00+00:00', (string) $xml->xpath('//s:lastmod')[0]); } public static function shortOpenTagSettings(): array { return [ 'production: enabled' => ['1'], 'development: disabled' => ['0'], ]; } }