39 lines
1.2 KiB
PHP
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());
|
||
|
|
}
|
||
|
|
}
|