* deactivate deprecated auto-mapping * use native month-picker with fallback on old browser * bump dependencies to new major versions * replace deprecated ARRAY column type with JSON * named arguments * nullable arguments * native lazy ghosts * update routes to use php config * disable PHP < 8.4 * use static RTL configuration * new qr code package * clear out env file * recipe updates * fix deprecations * preset new env variable if not existing * bump maria db version examples * remove deprecated api-token support * fix validator deprecations * remove timesheet category column * fix broken validator autoconfiguration * stabilize tests * fix migration syntax compatibility * fix doctrine deprecation * fix datetime format * remove constructor dependency * only include visible preferences in invoice templates * fix test container dependency * removed ProjectConstraint multi-constraint logic * allow to disable plugins in certain environments * refactor TimesheetConstraint to non-service * activate new interface methods * prevent update issues with .env * improved customer fixture * removed $user->isExportDecimal()
56 lines
2.1 KiB
PHP
56 lines
2.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Tests\Command;
|
|
|
|
use App\Command\PluginCommand;
|
|
use App\Plugin\PackageManager;
|
|
use App\Plugin\PluginInterface;
|
|
use App\Plugin\PluginManager;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
#[CoversClass(PluginCommand::class)]
|
|
#[Group('integration')]
|
|
class PluginCommandTest extends KernelTestCase
|
|
{
|
|
private Application $application;
|
|
|
|
public function testWithPlugins(): void
|
|
{
|
|
$plugin1 = $this->getMockBuilder(PluginInterface::class)->onlyMethods(['getName', 'getPath'])->getMock();
|
|
$plugin1->expects($this->any())->method('getName')->willReturn('TestBundle');
|
|
$plugin1->expects($this->exactly(2))->method('getPath')->willReturn(__DIR__ . '/../Plugin/Fixtures/TestPlugin');
|
|
|
|
$commandTester = $this->getCommandTester([$plugin1], []);
|
|
$output = $commandTester->getDisplay();
|
|
self::assertStringContainsString(__DIR__, $output);
|
|
self::assertStringContainsString('Plugin/Fixtures/TestPlugin', $output);
|
|
self::assertStringContainsString('TestPlugin from composer.json', $output);
|
|
}
|
|
|
|
private function getCommandTester(array $plugins, array $options = []): CommandTester
|
|
{
|
|
$projectDirectory = __DIR__ . '/../../';
|
|
$kernel = self::bootKernel();
|
|
$this->application = new Application($kernel);
|
|
$this->application->addCommand(new PluginCommand(new PluginManager($plugins), new PackageManager($projectDirectory), $projectDirectory));
|
|
|
|
$command = $this->application->find('kimai:plugins');
|
|
$commandTester = new CommandTester($command);
|
|
$inputs = array_merge(['command' => $command->getName()], $options);
|
|
$commandTester->execute($inputs);
|
|
|
|
return $commandTester;
|
|
}
|
|
}
|