Static analysis of unittest code.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -1,27 +1,31 @@
|
||||
<?php declare(strict_types=1);
|
||||
<?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\CommandBackup;
|
||||
|
||||
class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
#[CoversClass(CommandBackup::class)]
|
||||
final class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
mkdir('temp');
|
||||
mkdir('temp/destination');
|
||||
exec('rclone test makefiles temp/source 2>&1');
|
||||
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
exec('rclone purge temp 2>&1', $output);
|
||||
exec('rclone purge temp 2>&1');
|
||||
}
|
||||
|
||||
|
||||
public function testBadConfig()
|
||||
public function testBadConfig(): void
|
||||
{
|
||||
$applicationd = new Application('backup', "1.1.1");
|
||||
|
||||
@ -30,15 +34,14 @@ class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$command = $applicationd->find('backup');
|
||||
$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
|
||||
{
|
||||
|
||||
$applicationd = new Application('backup', "1.1.1");
|
||||
|
||||
$applicationd->add(new CommandBackup());
|
||||
@ -46,13 +49,13 @@ class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$command = $applicationd->find('backup');
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(['config'=>"config.example.yml"]);
|
||||
$commandTester->execute(['config' => "config.example.yml"]);
|
||||
|
||||
$output = $commandTester->getDisplay();
|
||||
$this->assertStringContainsString('[OK] Complete ', $output);
|
||||
}
|
||||
|
||||
public function testNoDestinationFolder()
|
||||
public function testNoDestinationFolder(): void
|
||||
{
|
||||
exec('rclone purge temp/destination 2>&1', $output);
|
||||
$applicationd = new Application('backup', "1.1.1");
|
||||
@ -62,13 +65,13 @@ class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$command = $applicationd->find('backup');
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(['config'=>"config.example.yml"]);
|
||||
$commandTester->execute(['config' => "config.example.yml"]);
|
||||
|
||||
$output = $commandTester->getDisplay();
|
||||
$this->assertStringContainsString('[OK] Complete ', $output);
|
||||
}
|
||||
|
||||
public function testNoSourceFolder()
|
||||
public function testNoSourceFolder(): void
|
||||
{
|
||||
exec('rclone purge temp/source 2>&1', $output);
|
||||
$applicationd = new Application('backup', "1.1.1");
|
||||
@ -78,9 +81,9 @@ class CommandBackupTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$command = $applicationd->find('backup');
|
||||
$commandTester = new CommandTester($command);
|
||||
$commandTester->execute(['config'=>"config.example.yml"]);
|
||||
$commandTester->execute(['config' => "config.example.yml"]);
|
||||
|
||||
$output = $commandTester->getDisplay();
|
||||
$this->assertStringContainsString('[OK] Complete ', $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user