Skip to content

Commit 9a56d21

Browse files
authored
Code Quality using Rector (#211)
## Description ## Checklist - [ ] Updated CHANGELOG files - [ ] Updated Documentation - [ ] Unit Tests Created - [x] php-cs-fixer
1 parent 97d1abe commit 9a56d21

4 files changed

+15
-40
lines changed

CommandMessageBus.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
*/
2525
class CommandMessageBus
2626
{
27-
private MessageBusInterface $messageBus;
2827
private array $stamps = [];
2928

30-
public function __construct(MessageBusInterface $commandBus)
31-
{
32-
$this->messageBus = $commandBus;
33-
}
29+
public function __construct(private MessageBusInterface $messageBus) {}
3430

3531
/**
3632
* Allows you to dispatch the command with additional stamps if

Tests/Command/AbstractOptionsResolverCommandMessageTest.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@
44

55
namespace SonsOfPHP\Bridge\Symfony\Cqrs\Tests\Command;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage;
910
use SonsOfPHP\Bridge\Symfony\Cqrs\Tests\DummyCommand;
1011
use SonsOfPHP\Contract\Cqrs\CommandMessageInterface;
1112

1213
/**
13-
* @coversDefaultClass \SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage
14-
*
1514
* @uses \SonsOfPHP\Bridge\Symfony\Cqrs\Command\AbstractOptionsResolverCommandMessage
15+
* @coversNothing
1616
*/
17+
#[CoversClass(AbstractOptionsResolverCommandMessage::class)]
1718
final class AbstractOptionsResolverCommandMessageTest extends TestCase
1819
{
1920
/**
@@ -26,12 +27,6 @@ public function testItHasTheCorrectInterface(): void
2627
$this->assertInstanceOf(CommandMessageInterface::class, $command); // @phpstan-ignore-line
2728
}
2829

29-
/**
30-
* @covers ::__construct
31-
* @covers ::configureOptions
32-
* @covers ::getOption
33-
* @covers ::getOptions
34-
*/
3530
public function testConstructor(): void
3631
{
3732
DummyCommand::setConfigureOptionsCallback(function ($resolver): void {
@@ -46,10 +41,6 @@ public function testConstructor(): void
4641
$this->assertSame('unique-id', $command->getOption('id'));
4742
}
4843

49-
/**
50-
* @covers ::__get
51-
* @covers ::getOption
52-
*/
5344
public function testMagicMethodGetWorks(): void
5445
{
5546
DummyCommand::setConfigureOptionsCallback(function ($resolver): void {
@@ -62,10 +53,6 @@ public function testMagicMethodGetWorks(): void
6253
$this->assertSame('unique-id', $command->id);
6354
}
6455

65-
/**
66-
* @covers ::__isset
67-
* @covers ::hasOption
68-
*/
6956
public function testMagicMethodIssetWorks(): void
7057
{
7158
DummyCommand::setConfigureOptionsCallback(function ($resolver): void {

Tests/CommandMessageBusTest.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
namespace SonsOfPHP\Bridge\Symfony\Cqrs\Tests;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SonsOfPHP\Bridge\Symfony\Cqrs\CommandMessageBus;
10+
use stdClass;
911
use Symfony\Component\Messenger\Envelope;
1012
use Symfony\Component\Messenger\MessageBusInterface;
1113
use Symfony\Component\Messenger\Stamp\StampInterface;
1214

1315
/**
14-
* @coversDefaultClass \SonsOfPHP\Bridge\Symfony\Cqrs\CommandMessageBus
15-
*
1616
* @internal
17+
* @coversNothing
1718
*/
19+
#[CoversClass(CommandMessageBus::class)]
1820
final class CommandMessageBusTest extends TestCase
1921
{
20-
/**
21-
* @covers ::__construct
22-
* @covers ::withStamps
23-
*/
2422
public function testWithStampsIsImmutable(): void
2523
{
2624
$commandBus = new CommandMessageBus($this->createMock(MessageBusInterface::class));
@@ -32,17 +30,13 @@ public function testWithStampsIsImmutable(): void
3230
$this->assertNotSame($commandBus, $anotherCommandBus);
3331
}
3432

35-
/**
36-
* @covers ::__construct
37-
* @covers ::dispatch
38-
*/
3933
public function testItWillUseMessageBusToDispatchCommand(): void
4034
{
4135
$bus = $this->createMock(MessageBusInterface::class);
4236
$bus->expects($this->once())->method('dispatch')->willReturn(new Envelope($bus));
4337

4438
$commandBus = new CommandMessageBus($bus);
4539

46-
$commandBus->dispatch(new \stdClass());
40+
$commandBus->dispatch(new stdClass());
4741
}
4842
}

Tests/QueryMessageBusTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,29 @@
44

55
namespace SonsOfPHP\Bridge\Symfony\Cqrs\Tests;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use SonsOfPHP\Bridge\Symfony\Cqrs\QueryMessageBus;
10+
use stdClass;
911
use Symfony\Component\Messenger\Envelope;
1012
use Symfony\Component\Messenger\MessageBusInterface;
1113
use Symfony\Component\Messenger\Stamp\HandledStamp;
1214

1315
/**
14-
* @coversDefaultClass \SonsOfPHP\Bridge\Symfony\Cqrs\QueryMessageBus
15-
*
1616
* @internal
17+
* @coversNothing
1718
*/
19+
#[CoversClass(QueryMessageBus::class)]
1820
final class QueryMessageBusTest extends TestCase
1921
{
20-
/**
21-
* @covers ::__construct
22-
* @covers ::handle
23-
*/
2422
public function testItWillUseMessageBusToDispatchQuery(): void
2523
{
2624
$bus = $this->createMock(MessageBusInterface::class);
2725
$bus->expects($this->once())->method('dispatch')->willReturn(
28-
new Envelope(new \stdClass(), [new HandledStamp('result', 'handlerName')])
26+
new Envelope(new stdClass(), [new HandledStamp('result', 'handlerName')])
2927
);
3028
$queryBus = new QueryMessageBus($bus);
3129

32-
$queryBus->handle(new \stdClass());
30+
$queryBus->handle(new stdClass());
3331
}
3432
}

0 commit comments

Comments
 (0)