Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes committed Oct 19, 2024
1 parent 45ff673 commit 97b7119
Show file tree
Hide file tree
Showing 7 changed files with 413 additions and 20 deletions.
6 changes: 4 additions & 2 deletions src/SonsOfPHP/Bard/Tests/Console/Command/AddCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ 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
{
$command = $this->application->get('add');
$commandTester = new CommandTester($command);
$commandTester = new CommandTester($this->command);

$commandTester->execute([
'path' => 'tmp/repo',
Expand Down
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();
}
}
72 changes: 72 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/ReleaseCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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\UpdateVersionWorker;
use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
use SonsOfPHP\Component\Version\Version;
use Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(ReleaseCommand::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(PushCommand::class)]
#[UsesClass(SplitCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
#[UsesClass(UpdateVersionWorker::class)]
#[UsesClass(BranchAlias::class)]
#[UsesClass(UpdateReplaceSection::class)]
#[UsesClass(Version::class)]
final class ReleaseCommandTest extends TestCase
{
private Application $application;

private ReleaseCommand $command;

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

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

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

$commandTester->assertCommandIsSuccessful();
}
}
63 changes: 63 additions & 0 deletions src/SonsOfPHP/Bard/Tests/Console/Command/SplitCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?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 Symfony\Component\Console\Tester\CommandTester;

#[Group('bard')]
#[CoversClass(SplitCommand::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(PushCommand::class)]
#[UsesClass(ReleaseCommand::class)]
#[UsesClass(UpdateCommand::class)]
#[UsesClass(JsonFile::class)]
final class SplitCommandTest extends TestCase
{
private Application $application;

private SplitCommand $command;

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

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

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

$commandTester->assertCommandIsSuccessful();
}
}
Loading

0 comments on commit 97b7119

Please sign in to comment.