Skip to content

Commit 775dae5

Browse files
authored
updates (#234)
1 parent 6c09a8b commit 775dae5

23 files changed

+875
-126
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
// Rule sets
2323
'@PER-CS' => true,
2424
'@PHP80Migration:risky' => true,
25-
'@PHP81Migration' => true,
25+
'@PHP82Migration' => true,
2626
'@PHPUnit100Migration:risky' => true,
2727

2828
// Rules
2929
'no_unused_imports' => true,
3030
'ordered_imports' => true,
31+
'heredoc_indentation' => false,
3132
//'php_unit_test_class_requires_covers' => true,
3233
])
3334
->setFinder($finder)

build/hooks/pre-commit

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ fi
8888
# <<< psalm
8989

9090
# >>> PHPUnit
91-
PHPUNIT="bin/phpunit"
91+
PHPUNIT="tools/phpunit/vendor/bin/phpunit"
9292
if [ -x $PHPUNIT ]; then
9393
__info "Running phpunit"
94-
XDEBUG_MODE=off php -dxdebug.mode=off $PHPUNIT --testsuite unit
94+
XDEBUG_MODE=off php -dxdebug.mode=off -dapc.enable_cli=1 $PHPUNIT --testsuite=all
9595
if [ $? -ne 0 ]; then
9696
__fail "Unit Tests failed, fix your shit. Can also use --no-verify to skip checks"
9797
fi
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SonsOfPHP\Bard\Tests\Console;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use SonsOfPHP\Bard\Console\Application;
12+
use SonsOfPHP\Bard\Console\Command\AddCommand;
13+
use SonsOfPHP\Bard\Console\Command\CopyCommand;
14+
use SonsOfPHP\Bard\Console\Command\InitCommand;
15+
use SonsOfPHP\Bard\Console\Command\InstallCommand;
16+
use SonsOfPHP\Bard\Console\Command\MergeCommand;
17+
use SonsOfPHP\Bard\Console\Command\PullCommand;
18+
use SonsOfPHP\Bard\Console\Command\PushCommand;
19+
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
20+
use SonsOfPHP\Bard\Console\Command\SplitCommand;
21+
22+
;
23+
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
24+
25+
#[Group('bard')]
26+
#[CoversClass(Application::class)]
27+
#[UsesClass(AddCommand::class)]
28+
#[UsesClass(CopyCommand::class)]
29+
#[UsesClass(InitCommand::class)]
30+
#[UsesClass(InstallCommand::class)]
31+
#[UsesClass(MergeCommand::class)]
32+
#[UsesClass(PullCommand::class)]
33+
#[UsesClass(PushCommand::class)]
34+
#[UsesClass(ReleaseCommand::class)]
35+
#[UsesClass(SplitCommand::class)]
36+
#[UsesClass(UpdateCommand::class)]
37+
final class ApplicationTest extends TestCase
38+
{
39+
private Application $application;
40+
41+
protected function setUp(): void
42+
{
43+
$this->application = new Application();
44+
}
45+
46+
public function testItsNameIsCorrect(): void
47+
{
48+
$this->assertSame('Bard', $this->application->getName());
49+
}
50+
51+
public function testItHasAddCommand(): void
52+
{
53+
$this->assertTrue($this->application->has('add'));
54+
}
55+
56+
public function testItHasCopyCommand(): void
57+
{
58+
$this->assertTrue($this->application->has('copy'));
59+
}
60+
61+
public function testItHasInitCommand(): void
62+
{
63+
$this->assertTrue($this->application->has('init'));
64+
}
65+
66+
public function testItHasInstallCommand(): void
67+
{
68+
$this->assertTrue($this->application->has('install'));
69+
}
70+
71+
public function testItHasMergeCommand(): void
72+
{
73+
$this->assertTrue($this->application->has('merge'));
74+
}
75+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SonsOfPHP\Bard\Tests\Console\Command;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use SonsOfPHP\Bard\Console\Application;
12+
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
13+
use SonsOfPHP\Bard\Console\Command\AddCommand;
14+
use SonsOfPHP\Bard\Console\Command\CopyCommand;
15+
use SonsOfPHP\Bard\Console\Command\InitCommand;
16+
use SonsOfPHP\Bard\Console\Command\InstallCommand;
17+
use SonsOfPHP\Bard\Console\Command\MergeCommand;
18+
use SonsOfPHP\Bard\Console\Command\PullCommand;
19+
use SonsOfPHP\Bard\Console\Command\PushCommand;
20+
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
21+
use SonsOfPHP\Bard\Console\Command\SplitCommand;
22+
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
23+
use SonsOfPHP\Bard\JsonFile;
24+
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
25+
use Symfony\Component\Console\Tester\CommandTester;
26+
27+
#[Group('bard')]
28+
#[CoversClass(AddCommand::class)]
29+
#[UsesClass(Application::class)]
30+
#[UsesClass(AbstractCommand::class)]
31+
#[UsesClass(CopyCommand::class)]
32+
#[UsesClass(InitCommand::class)]
33+
#[UsesClass(InstallCommand::class)]
34+
#[UsesClass(MergeCommand::class)]
35+
#[UsesClass(PullCommand::class)]
36+
#[UsesClass(PushCommand::class)]
37+
#[UsesClass(ReleaseCommand::class)]
38+
#[UsesClass(SplitCommand::class)]
39+
#[UsesClass(UpdateCommand::class)]
40+
#[UsesClass(JsonFile::class)]
41+
#[UsesClass(AddPackageWorker::class)]
42+
final class AddCommandTest extends TestCase
43+
{
44+
private Application $application;
45+
46+
private AddCommand $command;
47+
48+
protected function setUp(): void
49+
{
50+
$this->application = new Application();
51+
$this->command = $this->application->get('add');
52+
}
53+
54+
public function testItsNameIsCorrect(): void
55+
{
56+
$commandTester = new CommandTester($this->command);
57+
58+
$commandTester->execute([
59+
'path' => 'tmp/repo',
60+
'repository' => 'git@repo:repo.git',
61+
'--dry-run' => true,
62+
'-vvv' => true,
63+
]);
64+
65+
$commandTester->assertCommandIsSuccessful();
66+
}
67+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SonsOfPHP\Bard\Tests\Console\Command;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use SonsOfPHP\Bard\Console\Application;
12+
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
13+
use SonsOfPHP\Bard\Console\Command\AddCommand;
14+
use SonsOfPHP\Bard\Console\Command\CopyCommand;
15+
use SonsOfPHP\Bard\Console\Command\InitCommand;
16+
use SonsOfPHP\Bard\Console\Command\InstallCommand;
17+
use SonsOfPHP\Bard\Console\Command\MergeCommand;
18+
use SonsOfPHP\Bard\Console\Command\PullCommand;
19+
use SonsOfPHP\Bard\Console\Command\PushCommand;
20+
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
21+
use SonsOfPHP\Bard\Console\Command\SplitCommand;
22+
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
23+
use SonsOfPHP\Bard\JsonFile;
24+
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
25+
use Symfony\Component\Console\Tester\CommandTester;
26+
27+
#[Group('bard')]
28+
#[CoversClass(CopyCommand::class)]
29+
#[UsesClass(Application::class)]
30+
#[UsesClass(AbstractCommand::class)]
31+
#[UsesClass(AddCommand::class)]
32+
#[UsesClass(InitCommand::class)]
33+
#[UsesClass(InstallCommand::class)]
34+
#[UsesClass(MergeCommand::class)]
35+
#[UsesClass(PullCommand::class)]
36+
#[UsesClass(PushCommand::class)]
37+
#[UsesClass(ReleaseCommand::class)]
38+
#[UsesClass(SplitCommand::class)]
39+
#[UsesClass(UpdateCommand::class)]
40+
#[UsesClass(JsonFile::class)]
41+
#[UsesClass(AddPackageWorker::class)]
42+
final class CopyCommandTest extends TestCase
43+
{
44+
private Application $application;
45+
46+
private CopyCommand $command;
47+
48+
protected function setUp(): void
49+
{
50+
$this->application = new Application();
51+
$this->command = $this->application->get('copy');
52+
}
53+
54+
public function testItExecutesSuccessfully(): void
55+
{
56+
$commandTester = new CommandTester($this->command);
57+
58+
$commandTester->execute([
59+
'source' => 'LICENSE',
60+
'--dry-run' => true,
61+
'-vvv' => true,
62+
]);
63+
64+
$commandTester->assertCommandIsSuccessful();
65+
}
66+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SonsOfPHP\Bard\Tests\Console\Command;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use SonsOfPHP\Bard\Console\Application;
12+
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
13+
use SonsOfPHP\Bard\Console\Command\AddCommand;
14+
use SonsOfPHP\Bard\Console\Command\CopyCommand;
15+
use SonsOfPHP\Bard\Console\Command\InitCommand;
16+
use SonsOfPHP\Bard\Console\Command\InstallCommand;
17+
use SonsOfPHP\Bard\Console\Command\MergeCommand;
18+
use SonsOfPHP\Bard\Console\Command\PullCommand;
19+
use SonsOfPHP\Bard\Console\Command\PushCommand;
20+
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
21+
use SonsOfPHP\Bard\Console\Command\SplitCommand;
22+
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
23+
use SonsOfPHP\Bard\JsonFile;
24+
use SonsOfPHP\Bard\Worker\File\Composer\Package\Authors;
25+
use SonsOfPHP\Bard\Worker\File\Composer\Package\BranchAlias;
26+
use SonsOfPHP\Bard\Worker\File\Composer\Package\Funding;
27+
use SonsOfPHP\Bard\Worker\File\Composer\Package\Support;
28+
use SonsOfPHP\Bard\Worker\File\Composer\Root\ClearSection;
29+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadDevSection;
30+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateAutoloadSection;
31+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateProvideSection;
32+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateReplaceSection;
33+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireDevSection;
34+
use SonsOfPHP\Bard\Worker\File\Composer\Root\UpdateRequireSection;
35+
use Symfony\Component\Console\Tester\CommandTester;
36+
37+
#[Group('bard')]
38+
#[CoversClass(MergeCommand::class)]
39+
#[UsesClass(Application::class)]
40+
#[UsesClass(AbstractCommand::class)]
41+
#[UsesClass(AddCommand::class)]
42+
#[UsesClass(CopyCommand::class)]
43+
#[UsesClass(InitCommand::class)]
44+
#[UsesClass(InstallCommand::class)]
45+
#[UsesClass(PullCommand::class)]
46+
#[UsesClass(PushCommand::class)]
47+
#[UsesClass(ReleaseCommand::class)]
48+
#[UsesClass(SplitCommand::class)]
49+
#[UsesClass(UpdateCommand::class)]
50+
#[UsesClass(JsonFile::class)]
51+
#[UsesClass(Authors::class)]
52+
#[UsesClass(BranchAlias::class)]
53+
#[UsesClass(Funding::class)]
54+
#[UsesClass(Support::class)]
55+
#[UsesClass(ClearSection::class)]
56+
#[UsesClass(UpdateAutoloadDevSection::class)]
57+
#[UsesClass(UpdateAutoloadSection::class)]
58+
#[UsesClass(UpdateProvideSection::class)]
59+
#[UsesClass(UpdateReplaceSection::class)]
60+
#[UsesClass(UpdateRequireSection::class)]
61+
#[UsesClass(UpdateRequireDevSection::class)]
62+
final class MergeCommandTest extends TestCase
63+
{
64+
private Application $application;
65+
66+
private MergeCommand $command;
67+
68+
protected function setUp(): void
69+
{
70+
$this->application = new Application();
71+
$this->command = $this->application->get('merge');
72+
}
73+
74+
public function testItExecutesSuccessfully(): void
75+
{
76+
$commandTester = new CommandTester($this->command);
77+
78+
$commandTester->execute([
79+
'--dry-run' => true,
80+
'-vvv' => true,
81+
]);
82+
83+
$commandTester->assertCommandIsSuccessful();
84+
}
85+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SonsOfPHP\Bard\Tests\Console\Command;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\Attributes\Group;
9+
use PHPUnit\Framework\Attributes\UsesClass;
10+
use PHPUnit\Framework\TestCase;
11+
use SonsOfPHP\Bard\Console\Application;
12+
use SonsOfPHP\Bard\Console\Command\AbstractCommand;
13+
use SonsOfPHP\Bard\Console\Command\AddCommand;
14+
use SonsOfPHP\Bard\Console\Command\CopyCommand;
15+
use SonsOfPHP\Bard\Console\Command\InitCommand;
16+
use SonsOfPHP\Bard\Console\Command\InstallCommand;
17+
use SonsOfPHP\Bard\Console\Command\MergeCommand;
18+
use SonsOfPHP\Bard\Console\Command\PullCommand;
19+
use SonsOfPHP\Bard\Console\Command\PushCommand;
20+
use SonsOfPHP\Bard\Console\Command\ReleaseCommand;
21+
use SonsOfPHP\Bard\Console\Command\SplitCommand;
22+
use SonsOfPHP\Bard\Console\Command\UpdateCommand;
23+
use SonsOfPHP\Bard\JsonFile;
24+
use SonsOfPHP\Bard\Worker\File\Bard\AddPackageWorker;
25+
use Symfony\Component\Console\Tester\CommandTester;
26+
27+
#[Group('bard')]
28+
#[CoversClass(PushCommand::class)]
29+
#[UsesClass(Application::class)]
30+
#[UsesClass(AbstractCommand::class)]
31+
#[UsesClass(AddCommand::class)]
32+
#[UsesClass(CopyCommand::class)]
33+
#[UsesClass(InitCommand::class)]
34+
#[UsesClass(InstallCommand::class)]
35+
#[UsesClass(MergeCommand::class)]
36+
#[UsesClass(PullCommand::class)]
37+
#[UsesClass(ReleaseCommand::class)]
38+
#[UsesClass(SplitCommand::class)]
39+
#[UsesClass(UpdateCommand::class)]
40+
#[UsesClass(JsonFile::class)]
41+
#[UsesClass(AddPackageWorker::class)]
42+
final class PushCommandTest extends TestCase
43+
{
44+
private Application $application;
45+
46+
private PushCommand $command;
47+
48+
protected function setUp(): void
49+
{
50+
$this->application = new Application();
51+
$this->command = $this->application->get('push');
52+
}
53+
54+
public function testItExecutesSuccessfully(): void
55+
{
56+
$commandTester = new CommandTester($this->command);
57+
58+
$commandTester->execute([
59+
'--dry-run' => true,
60+
'-vvv' => true,
61+
]);
62+
63+
$commandTester->assertCommandIsSuccessful();
64+
}
65+
}

0 commit comments

Comments
 (0)