Static analysis of unittest code.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2023-07-10 09:20:36 +00:00
parent 534c8cdbe6
commit 3b9cea1c70
6 changed files with 81 additions and 65 deletions

View File

@ -1,12 +1,19 @@
<?php
<?php
declare(strict_types=1);
namespace App\Tests;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use App\CommandShow;
class CommandShowTest extends \PHPUnit\Framework\TestCase
#[CoversClass(CommandShow::class)]
final class CommandShowTest extends \PHPUnit\Framework\TestCase
{
public function testInvalidConfig()
public function testInvalidConfig(): void
{
$applicationd = new Application('backup', "1.1.1");
@ -16,16 +23,16 @@ class CommandShowTest extends \PHPUnit\Framework\TestCase
$command = $applicationd->find('show');
$commandTester = new CommandTester($command);
$commandTester->execute(['config'=>"bad_file"]);
$commandTester->execute(['config' => "bad_file"]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('[ERROR] Configuration error: File "bad_file" does not exist.', $output);
}
public function testGoodConfig()
public function testGoodConfig(): void
{
exec('rclone test makefiles temp/source 2>&1');
$applicationd = new Application('backup', "1.1.1");
$applicationd->add(new CommandShow());
@ -33,13 +40,11 @@ class CommandShowTest extends \PHPUnit\Framework\TestCase
$command = $applicationd->find('show');
$commandTester = new CommandTester($command);
$commandTester->execute(['config'=>"config.example.yml"]);
$commandTester->execute(['config' => "config.example.yml"]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('Example', $output);
$this->assertStringContainsString('temp/source', $output);
$this->assertStringContainsString('temp/destination', $output);
}
}
}