Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #234

Merged
merged 8 commits into from
Oct 19, 2024
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
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = Finder::create()

Check failure on line 9 in .php-cs-fixer.dist.php

View workflow job for this annotation

GitHub Actions / Psalm (8.2)

UndefinedClass

.php-cs-fixer.dist.php:9:11: UndefinedClass: Class, interface or enum named PhpCsFixer\Finder does not exist (see https://psalm.dev/019)
->in(__DIR__)
->exclude('build')
->exclude('docs')
Expand All @@ -22,12 +22,13 @@
// Rule sets
'@PER-CS' => true,
'@PHP80Migration:risky' => true,
'@PHP81Migration' => true,
'@PHP82Migration' => true,
'@PHPUnit100Migration:risky' => true,

// Rules
'no_unused_imports' => true,
'ordered_imports' => true,
'heredoc_indentation' => false,
//'php_unit_test_class_requires_covers' => true,
])
->setFinder($finder)
Expand Down
4 changes: 2 additions & 2 deletions build/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ fi
# <<< psalm

# >>> PHPUnit
PHPUNIT="bin/phpunit"
PHPUNIT="tools/phpunit/vendor/bin/phpunit"
if [ -x $PHPUNIT ]; then
__info "Running phpunit"
XDEBUG_MODE=off php -dxdebug.mode=off $PHPUNIT --testsuite unit
XDEBUG_MODE=off php -dxdebug.mode=off -dapc.enable_cli=1 $PHPUNIT --testsuite=all
if [ $? -ne 0 ]; then
__fail "Unit Tests failed, fix your shit. Can also use --no-verify to skip checks"
fi
Expand Down
75 changes: 75 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests\Console;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\Console\Application;
use SonsOfPHP\Bard\Console\Command\AddCommand;
use SonsOfPHP\Bard\Console\Command\CopyCommand;
use SonsOfPHP\Bard\Console\Command\InitCommand;
use SonsOfPHP\Bard\Console\Command\InstallCommand;
use SonsOfPHP\Bard\Console\Command\MergeCommand;
use SonsOfPHP\Bard\Console\Command\PullCommand;
use SonsOfPHP\Bard\Console\Command\PushCommand;
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
use SonsOfPHP\Bard\Console\Command\SplitCommand;

;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;

#[Group('bard')]
#[CoversClass(Application::class)]
#[UsesClass(AddCommand::class)]
#[UsesClass(CopyCommand::class)]
#[UsesClass(InitCommand::class)]
#[UsesClass(InstallCommand::class)]
#[UsesClass(MergeCommand::class)]
#[UsesClass(PullCommand::class)]
#[UsesClass(PushCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
final class ApplicationTest extends TestCase
{
private Application $application;

protected function setUp(): void
{
$this->application = new Application();
}

public function testItsNameIsCorrect(): void
{
$this->assertSame('Bard', $this->application->getName());
}

public function testItHasAddCommand(): void
{
$this->assertTrue($this->application->has('add'));
}

public function testItHasCopyCommand(): void
{
$this->assertTrue($this->application->has('copy'));
}

public function testItHasInitCommand(): void
{
$this->assertTrue($this->application->has('init'));
}

public function testItHasInstallCommand(): void
{
$this->assertTrue($this->application->has('install'));
}

public function testItHasMergeCommand(): void
{
$this->assertTrue($this->application->has('merge'));
}
}
67 changes: 67 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests\Console\Command;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\Console\Application;
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
use SonsOfPHP\Bard\Console\Command\AddCommand;
use SonsOfPHP\Bard\Console\Command\CopyCommand;
use SonsOfPHP\Bard\Console\Command\InitCommand;
use SonsOfPHP\Bard\Console\Command\InstallCommand;
use SonsOfPHP\Bard\Console\Command\MergeCommand;
use SonsOfPHP\Bard\Console\Command\PullCommand;
use SonsOfPHP\Bard\Console\Command\PushCommand;
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
use Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(AddCommand::class)]
#[UsesClass(Application::class)]
#[UsesClass(AbstractCommand::class)]
#[UsesClass(CopyCommand::class)]
#[UsesClass(InitCommand::class)]
#[UsesClass(InstallCommand::class)]
#[UsesClass(MergeCommand::class)]
#[UsesClass(PullCommand::class)]
#[UsesClass(PushCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
#[UsesClass(AddPackageWorker::class)]
final class AddCommandTest extends TestCase
{
private Application $application;

private AddCommand $command;

protected function setUp(): void
{
$this->application = new Application();
$this->command = $this->application->get('add');
}

public function testItsNameIsCorrect(): void
{
$commandTester = new CommandTester($this->command);

$commandTester->execute([
'path' => 'tmp/repo',
'repository' => 'git@repo:repo.git',
'--dry-run' => true,
'-vvv' => true,
]);

$commandTester->assertCommandIsSuccessful();
}
}
66 changes: 66 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/CopyCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests\Console\Command;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\Console\Application;
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
use SonsOfPHP\Bard\Console\Command\AddCommand;
use SonsOfPHP\Bard\Console\Command\CopyCommand;
use SonsOfPHP\Bard\Console\Command\InitCommand;
use SonsOfPHP\Bard\Console\Command\InstallCommand;
use SonsOfPHP\Bard\Console\Command\MergeCommand;
use SonsOfPHP\Bard\Console\Command\PullCommand;
use SonsOfPHP\Bard\Console\Command\PushCommand;
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
use Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(CopyCommand::class)]
#[UsesClass(Application::class)]
#[UsesClass(AbstractCommand::class)]
#[UsesClass(AddCommand::class)]
#[UsesClass(InitCommand::class)]
#[UsesClass(InstallCommand::class)]
#[UsesClass(MergeCommand::class)]
#[UsesClass(PullCommand::class)]
#[UsesClass(PushCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
#[UsesClass(AddPackageWorker::class)]
final class CopyCommandTest extends TestCase
{
private Application $application;

private CopyCommand $command;

protected function setUp(): void
{
$this->application = new Application();
$this->command = $this->application->get('copy');
}

public function testItExecutesSuccessfully(): void
{
$commandTester = new CommandTester($this->command);

$commandTester->execute([
'source' => 'LICENSE',
'--dry-run' => true,
'-vvv' => true,
]);

$commandTester->assertCommandIsSuccessful();
}
}
85 changes: 85 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/MergeCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests\Console\Command;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\Console\Application;
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
use SonsOfPHP\Bard\Console\Command\AddCommand;
use SonsOfPHP\Bard\Console\Command\CopyCommand;
use SonsOfPHP\Bard\Console\Command\InitCommand;
use SonsOfPHP\Bard\Console\Command\InstallCommand;
use SonsOfPHP\Bard\Console\Command\MergeCommand;
use SonsOfPHP\Bard\Console\Command\PullCommand;
use SonsOfPHP\Bard\Console\Command\PushCommand;
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
use SonsOfPHP\Bard\Worker\File\Composer\Package\Authors;
use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
use Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(MergeCommand::class)]
#[UsesClass(Application::class)]
#[UsesClass(AbstractCommand::class)]
#[UsesClass(AddCommand::class)]
#[UsesClass(CopyCommand::class)]
#[UsesClass(InitCommand::class)]
#[UsesClass(InstallCommand::class)]
#[UsesClass(PullCommand::class)]
#[UsesClass(PushCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
#[UsesClass(Authors::class)]
#[UsesClass(BranchAlias::class)]
#[UsesClass(Funding::class)]
#[UsesClass(Support::class)]
#[UsesClass(ClearSection::class)]
#[UsesClass(UpdateAutoloadDevSection::class)]
#[UsesClass(UpdateAutoloadSection::class)]
#[UsesClass(UpdateProvideSection::class)]
#[UsesClass(UpdateReplaceSection::class)]
#[UsesClass(UpdateRequireSection::class)]
#[UsesClass(UpdateRequireDevSection::class)]
final class MergeCommandTest extends TestCase
{
private Application $application;

private MergeCommand $command;

protected function setUp(): void
{
$this->application = new Application();
$this->command = $this->application->get('merge');
}

public function testItExecutesSuccessfully(): void
{
$commandTester = new CommandTester($this->command);

$commandTester->execute([
'--dry-run' => true,
'-vvv' => true,
]);

$commandTester->assertCommandIsSuccessful();
}
}
65 changes: 65 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/PushCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bard\Tests\Console\Command;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use SonsOfPHP\Bard\Console\Application;
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
use SonsOfPHP\Bard\Console\Command\AddCommand;
use SonsOfPHP\Bard\Console\Command\CopyCommand;
use SonsOfPHP\Bard\Console\Command\InitCommand;
use SonsOfPHP\Bard\Console\Command\InstallCommand;
use SonsOfPHP\Bard\Console\Command\MergeCommand;
use SonsOfPHP\Bard\Console\Command\PullCommand;
use SonsOfPHP\Bard\Console\Command\PushCommand;
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
use SonsOfPHP\Bard\Console\Command\SplitCommand;
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
use SonsOfPHP\Bard\JsonFile;
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
use Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(PushCommand::class)]
#[UsesClass(Application::class)]
#[UsesClass(AbstractCommand::class)]
#[UsesClass(AddCommand::class)]
#[UsesClass(CopyCommand::class)]
#[UsesClass(InitCommand::class)]
#[UsesClass(InstallCommand::class)]
#[UsesClass(MergeCommand::class)]
#[UsesClass(PullCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
#[UsesClass(AddPackageWorker::class)]
final class PushCommandTest extends TestCase
{
private Application $application;

private PushCommand $command;

protected function setUp(): void
{
$this->application = new Application();
$this->command = $this->application->get('push');
}

public function testItExecutesSuccessfully(): void
{
$commandTester = new CommandTester($this->command);

$commandTester->execute([
'--dry-run' => true,
'-vvv' => true,
]);

$commandTester->assertCommandIsSuccessful();
}
}
Loading
Loading