Skip to content

Commit

Permalink
updates (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes authored Oct 19, 2024
1 parent 6c09a8b commit 775dae5
Show file tree
Hide file tree
Showing 23 changed files with 875 additions and 126 deletions.
3 changes: 2 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 775dae5

Please sign in to comment.