Phred/tests/Feature/ModuleSyncNsTest.php
Funky Waddle 54303282d7
Some checks failed
CI / PHP ${{ matrix.php }} (8.1) (push) Has been cancelled
CI / PHP ${{ matrix.php }} (8.2) (push) Has been cancelled
CI / PHP ${{ matrix.php }} (8.3) (push) Has been cancelled
Too many things
2026-01-06 11:02:05 -06:00

39 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Phred\Tests\Feature;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
class ModuleSyncNsTest extends TestCase
{
private string $composerFile;
private string $originalContent;
protected function setUp(): void
{
$this->composerFile = getcwd() . '/composer.json';
$this->originalContent = file_get_contents($this->composerFile);
}
protected function tearDown(): void
{
file_put_contents($this->composerFile, $this->originalContent);
}
public function test_sync_ns_reports_dead_entries(): void
{
$data = json_decode($this->originalContent, true);
$data['autoload']['psr-4']['Dead\\Namespace\\'] = 'modules/NonExistent/';
file_put_contents($this->composerFile, json_encode($data));
$cmd = require getcwd() . '/src/commands/module_sync_ns.php';
$output = new BufferedOutput();
$cmd->handle(new ArrayInput([]), $output);
$this->assertStringContainsString("Warning: PSR-4 entry 'Dead\Namespace\' points to non-existent directory: modules/NonExistent/", $output->fetch());
}
}