51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace RprtCli\Tests\Kernel;
|
||
|
|
||
|
use PHPUnit\Framework\TestCase;
|
||
|
use Symfony\Component\Console\Application;
|
||
|
use Symfony\Component\Console\Tester\CommandTester;
|
||
|
use DI\ContainerBuilder;
|
||
|
use RprtCli\Commands\InvoiceCommand;
|
||
|
use RprtCli\Commands\ReportCommand;
|
||
|
|
||
|
class ReportCommandTest extends TestCase {
|
||
|
|
||
|
public function testExecute() {
|
||
|
$builder = new ContainerBuilder();
|
||
|
$builder->addDefinitions(__DIR__ . '/../test-dependencies.php');
|
||
|
$container = $builder->build();
|
||
|
|
||
|
$application = new Application('Command Line Tool to process Youtrack Reports', '0.1.0');
|
||
|
|
||
|
$invoiceCommand = $container->get(InvoiceCommand::class);
|
||
|
$application->add($invoiceCommand);
|
||
|
$reportCommand = $container->get(ReportCommand::class);
|
||
|
$application->add($reportCommand);
|
||
|
|
||
|
|
||
|
$command = $application->find('report');
|
||
|
$commandTester = new CommandTester($command);
|
||
|
$commandTester->execute([
|
||
|
// pass arguments to the helper
|
||
|
'--file' => __DIR__ . '/../data/21-03.csv',
|
||
|
|
||
|
// prefix the key with two dashes when passing options,
|
||
|
// e.g: '--some-option' => 'option_value',
|
||
|
// use brackets for testing array value,
|
||
|
// e.g: '--some-option' => ['option_value'],
|
||
|
]);
|
||
|
|
||
|
$commandTester->assertCommandIsSuccessful();
|
||
|
|
||
|
// the output of the command in the console
|
||
|
$output = $commandTester->getDisplay();
|
||
|
var_dump($output);
|
||
|
$this->assertStringContainsString('21-03.csv', $output);
|
||
|
|
||
|
// ...
|
||
|
}
|
||
|
}
|