Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ public function run(InputInterface $input): int
false === getenv('SYMFONY_VERSION') ? 'master' : getenv('SYMFONY_VERSION')
);
$this->application->getDefinition()->addOption($inputOption);
$this->application->add(new BuildDocsCommand($this->buildConfig));

$command = new BuildDocsCommand($this->buildConfig);

// Application::add() was deprecated in Symfony 7.4 and removed in 8.0,
// in favor of Application::addCommand(), introduced in 7.4

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could probably drop support for old versions of symfony components there. This tool is used by the Symfony website (which is on modern Symfony versions) and by the CI of the symfony-docs repo.

Alternatively, if we never use its CLI, we might drop it entirely

if (method_exists($this->application, 'addCommand')) {
$this->application->addCommand($command);
} else {
$this->application->add($command);
}

return $this->application->run($input);
}
Expand Down
33 changes: 33 additions & 0 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Docs Builder package.
* (c) Ryan Weaver <ryan@symfonycasts.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SymfonyDocsBuilder\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Process;

/**
* The rest of the test suite drives the command through CommandTester, so it
* never runs the binary itself. This makes sure the binary at least boots.
*/
class ApplicationTest extends TestCase
{
public function testTheBinaryRegistersTheBuildDocsCommand()
{
$process = new Process([\PHP_BINARY, __DIR__.'/../bin/docs-builder', 'list', '--no-ansi']);
$process->run();

$this->assertSame(
0,
$process->getExitCode(),
sprintf("The binary failed to run:\n%s", $process->getErrorOutput())
);
$this->assertStringContainsString('build:docs', $process->getOutput());
}
}