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
10 changes: 6 additions & 4 deletions bin/aspect
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ if (!class_exists(Application::class)) {
}

$app = new Application('Go! AOP', InstalledVersions::getVersion('goaop/framework'));
$app->add(new CacheWarmupCommand());
$app->add(new DebugAspectCommand());
$app->add(new DebugAdvisorCommand());
$app->add(new DebugWeavingCommand());
$app->addCommands([
new CacheWarmupCommand(),
new DebugAspectCommand(),
new DebugAdvisorCommand(),
new DebugWeavingCommand(),
]);
$app->run();
60 changes: 60 additions & 0 deletions tests/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

declare(strict_types=1);
/*
* Go! AOP framework
*
* @copyright Copyright 2025, Lisachenko Alexander <lisachenko.it@gmail.com>
*
* This source file is subject to the license that is bundled
* with this source code in the file LICENSE.
*/

namespace Go\Console;

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

class ApplicationTest extends TestCase
{
private string $console;

public function setUp(): void
{
$this->console = __DIR__ . '/../../bin/aspect';
}

public function testListCommandShowsAllRegisteredCommands(): void
{
$process = $this->runConsoleCommand('list', ['--no-ansi']);

$this->assertTrue($process->isSuccessful(), $process->getErrorOutput() ?: $process->getOutput());
$this->assertStringContainsString('cache:warmup:aop', $process->getOutput());
$this->assertStringContainsString('debug:aspect', $process->getOutput());
$this->assertStringContainsString('debug:advisor', $process->getOutput());
$this->assertStringContainsString('debug:weaving', $process->getOutput());
}

public function testVersionOptionShowsApplicationVersion(): void
{
$process = $this->runConsoleCommand('list', ['--version']);

$this->assertTrue($process->isSuccessful(), $process->getErrorOutput() ?: $process->getOutput());
$this->assertStringContainsString('Go! AOP', $process->getOutput());
}

private function runConsoleCommand(string $command, array $args = []): Process
{
$phpExecutable = (new PhpExecutableFinder())->find();
$commandLine = array_merge(
[$phpExecutable, $this->console, $command],
$args
);

$process = new Process($commandLine);
$process->run();

return $process;
}
}
Loading