[General] PHP-CS-FIXER

This commit is contained in:
Carlos Buenosvinos
2022-03-12 16:14:33 +01:00
parent b104921c28
commit d753b4d7d6
20 changed files with 53 additions and 75 deletions

View File

@@ -8,8 +8,6 @@ use Cheeper\Chapter2\Author;
use Cheeper\Chapter2\Hexagonal\Application\CheepService;
use Cheeper\Chapter2\Hexagonal\DomainModel\AuthorRepository;
use Cheeper\Chapter2\Hexagonal\DomainModel\CheepRepository;
use Cheeper\Chapter2\Layered\AuthorDAO;
use Cheeper\Chapter2\Layered\CheepDAO;
use PHPUnit\Framework\TestCase;
//snippet cheep-service-test

View File

@@ -8,13 +8,10 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\Chapter4\Application\Author\Command\FollowCommand;
use Cheeper\Chapter4\Application\Author\Command\FollowCommandHandler;
use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpCommandHandler;
use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpCommand;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpCommandHandler;
use Cheeper\Chapter4\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use Cheeper\Chapter4\Infrastructure\DomainModel\Cheep\InMemoryCheepRepository;
use Cheeper\Chapter4\Infrastructure\DomainModel\Follow\InMemoryFollowRepository;
use Cheeper\Tests\Helper\SendsCommands;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;

View File

@@ -14,9 +14,9 @@ use Cheeper\Chapter4\DomainModel\Author\NewAuthorSigned;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter4\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use DateTimeImmutable;
use function Functional\first;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
use function Functional\first;
final class SignUpCommandHandlerTest extends TestCase
{
@@ -268,14 +268,13 @@ final class SignUpCommandHandlerTest extends TestCase
(new DateTimeImmutable())->format('Y-m-d')
)
);
}
protected function getToday(): DateTimeImmutable
{
return new DateTimeImmutable(
'now', new \DateTimeZone('UTC')
'now',
new \DateTimeZone('UTC')
);
}
}

View File

@@ -9,14 +9,14 @@ use Cheeper\Chapter4\Application\Author\Command\SignUpWithoutEvents\SignUpComman
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
final class SignUpCommandBuilderMock {
final class SignUpCommandBuilderMock
{
//snippet builder-method
public static function builder(
string $authorId,
string $userName,
string $email
): SignUpCommandBuilder
{
): SignUpCommandBuilder {
return SignUpCommandBuilder::create($authorId, $userName, $email);
}
//end-snippet

View File

@@ -8,17 +8,17 @@ use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
use Cheeper\AllChapters\DomainModel\Clock;
use Cheeper\AllChapters\DomainModel\Clock\DateCollectionClockStrategy;
use Cheeper\Chapter4\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommand;
use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommandHandler;
use Cheeper\Chapter4\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter4\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use Cheeper\Chapter4\Infrastructure\DomainModel\Cheep\InMemoryCheepRepository;
use Cheeper\Tests\AllChapters\DomainModel\Author\AuthorTestDataBuilder;
use DateTimeImmutable;
use function Functional\first;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
use function Functional\first;
//snippet post-cheep-handler-test
final class PostCheepCommandHandlerTest extends TestCase
@@ -43,7 +43,8 @@ final class PostCheepCommandHandlerTest extends TestCase
protected function getToday(): DateTimeImmutable
{
return new DateTimeImmutable(
'now', new \DateTimeZone('UTC')
'now',
new \DateTimeZone('UTC')
);
}

View File

@@ -12,9 +12,9 @@ use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommand;
use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommandHandler;
use Cheeper\Chapter4\Application\Cheep\Command\UpdateCheepMessageCommand;
use Cheeper\Chapter4\Application\Cheep\Command\UpdateCheepMessageCommandHandler;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter4\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use Cheeper\Chapter4\Infrastructure\DomainModel\Cheep\InMemoryCheepRepository;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;

View File

@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter5\Application\Author\Query\CountFollowersQueryHandler\WithDbAccess;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\WithDbAccess\CountFollowersQueryHandler;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
@@ -51,7 +51,7 @@ final class CountFollowersQueryHandlerTest extends TestCase
$this->buildEntityManagerMockReturning([
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers
'followers' => $authorFollowers,
])
);
@@ -75,10 +75,12 @@ final class CountFollowersQueryHandlerTest extends TestCase
);
$connectionMock = new class($fakeReturn) {
public function __construct(private $toReturn) {
public function __construct(private $toReturn)
{
}
public function fetchAssociative($query, $params): mixed {
public function fetchAssociative($query, $params): mixed
{
return $this->toReturn;
}
};
@@ -90,4 +92,4 @@ final class CountFollowersQueryHandlerTest extends TestCase
return $mock;
}
}
//end-snippet
//end-snippet

View File

@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter5\Application\Author\Query\CountFollowersQueryHandler\WithRedisAccess;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\WithRedisAccess\CountFollowersQueryHandler;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use PHPUnit\Framework\TestCase;
use Redis;
@@ -51,7 +51,7 @@ final class CountFollowersQueryHandlerTest extends TestCase
json_encode([
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers
'followers' => $authorFollowers,
])
)
);

View File

@@ -10,10 +10,10 @@ use Cheeper\AllChapters\DomainModel\Author\EmailAddress;
use Cheeper\AllChapters\DomainModel\Author\UserName;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorRepository;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\WithRepositoriesAccess\CountFollowersQueryHandler;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersQuery;
use Cheeper\Chapter4\DomainModel\Follow\FollowRepository;
use PHPUnit\Framework\TestCase;
final class CountFollowersQueryHandlerTest extends TestCase
@@ -84,7 +84,8 @@ final class CountFollowersQueryHandlerTest extends TestCase
return $mock;
}
private function buildFollowRepositoryMockReturning(array $fakeReturn): FollowRepository {
private function buildFollowRepositoryMockReturning(array $fakeReturn): FollowRepository
{
$mock = $this->createStub(FollowRepository::class);
$mock->method('fromAuthorId')->willReturn(

View File

@@ -11,20 +11,19 @@ use Cheeper\AllChapters\DomainModel\Author\UserName;
use Cheeper\AllChapters\DomainModel\Clock;
use Cheeper\AllChapters\DomainModel\Clock\DateCollectionClockStrategy;
use Cheeper\AllChapters\DomainModel\Follow\FollowDoesAlreadyExistException;
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
use Cheeper\Chapter4\DomainModel\Follow\Follow;
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
use Cheeper\Chapter4\DomainModel\Author\Author;
use Cheeper\Chapter4\DomainModel\Author\AuthorFollowed;
use Cheeper\Chapter4\DomainModel\Follow\Follow;
use Cheeper\Chapter4\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter4\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use Cheeper\Chapter4\Infrastructure\DomainModel\Follow\InMemoryFollowRepository;
use Cheeper\Chapter6\Application\Author\Command\FollowCommand;
use Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler;
use DateTimeImmutable;
use function Functional\first;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\UuidV4;
use Symfony\Component\Validator\Constraints\Uuid;
use function Functional\first;
final class FollowCommandHandlerTest extends TestCase
{

View File

@@ -61,7 +61,7 @@ final class CountFollowersProjectionHandlerTest extends TestCase
[
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers
'followers' => $authorFollowers,
]
)
)
@@ -70,7 +70,7 @@ final class CountFollowersProjectionHandlerTest extends TestCase
$dbMock = $this->buildEntityManagerMockReturning([
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers
'followers' => $authorFollowers,
]);
$handler = new CountFollowersProjectionHandler(
@@ -88,10 +88,12 @@ final class CountFollowersProjectionHandlerTest extends TestCase
$mock = $this->createStub(EntityManagerInterface::class);
$connectionMock = new class($fakeReturn) {
public function __construct(private $toReturn) {
public function __construct(private $toReturn)
{
}
public function fetchAssociative($query, $params): mixed {
public function fetchAssociative($query, $params): mixed
{
return $this->toReturn;
}
};
@@ -103,4 +105,4 @@ final class CountFollowersProjectionHandlerTest extends TestCase
return $mock;
}
}
#end-snippet
#end-snippet

View File

@@ -187,14 +187,13 @@ final class FollowCommandHandlerTest extends TestCase
string $followId,
string $fromAuthorId,
string $toAuthorId
): FollowCommand
{
): FollowCommand {
$this->eventBus->reset();
$command = FollowCommand::fromArray([
'follow_id' => $followId,
'from_author_id' => $fromAuthorId,
'to_author_id' => $toAuthorId
'to_author_id' => $toAuthorId,
]);
(new FollowCommandHandler(

View File

@@ -5,10 +5,6 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter7\Application\Author\Projection;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepDate;
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepMessage;
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjection;
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandler;
use Doctrine\ORM\EntityManagerInterface;
@@ -77,14 +73,17 @@ final class CountFollowersProjectionHandlerTest extends TestCase
);
}
private function buildEntityManagerMockReturning($fakeReturn) {
private function buildEntityManagerMockReturning($fakeReturn)
{
$mock = $this->createStub(EntityManagerInterface::class);
$connectionMock = new class($fakeReturn) {
public function __construct(private $toReturn) {
public function __construct(private $toReturn)
{
}
public function fetchAssociative($query, $params): mixed {
public function fetchAssociative($query, $params): mixed
{
return $this->toReturn;
}
};

View File

@@ -51,7 +51,7 @@ final class CountFollowersQueryHandlerTest extends TestCase
json_encode([
'id' => $authorId,
'username' => $authorUsername,
'followers' => $authorFollowers
'followers' => $authorFollowers,
])
)
);

View File

@@ -4,10 +4,6 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter7\Application\Author\Query;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\Chapter5\Application\Author\Query\CountFollowersQueryHandler\CountFollowersResponse;
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQuery;
use Cheeper\Chapter7\Application\Author\Query\CountFollowersQueryHandler;
use Cheeper\Chapter7\Application\Author\Query\TimelineQuery;
use Cheeper\Chapter7\Application\Author\Query\TimelineQueryHandler;
use PHPUnit\Framework\TestCase;

View File

@@ -16,9 +16,9 @@ use Cheeper\Chapter7\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter7\Infrastructure\Application\InMemoryEventBus;
use Cheeper\Chapter7\Infrastructure\DomainModel\Author\InMemoryAuthorRepository;
use Cheeper\Chapter7\Infrastructure\DomainModel\Cheep\InMemoryCheepRepository;
use function Functional\first;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
use function Functional\first;
//snippet post-cheep-handler-test
final class PostCheepCommandHandlerTest extends TestCase

View File

@@ -4,23 +4,18 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter7\Application\Cheep\Event;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepDate;
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepMessage;
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
use Cheeper\Chapter7\Application\Author\Event\AuthorFollowedEventHandler;
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandler;
use Cheeper\Chapter7\Application\Cheep\Event\CheepPostedEventHandler;
use Cheeper\Chapter7\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter7\DomainModel\Follow\Follow;
use Cheeper\Chapter7\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter7\Infrastructure\Application\InMemoryProjectionBus;
use Cheeper\Chapter7\Infrastructure\DomainModel\Follow\InMemoryFollowRepository;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
final class CheepPostedEventHandlerTest extends TestCase
{
@@ -71,7 +66,7 @@ final class CheepPostedEventHandlerTest extends TestCase
$rockStarAuthorId = AuthorId::nextIdentity();
$followersList = [];
for($i = 0; $i < 10; $i++) {
for ($i = 0; $i < 10; $i++) {
$followersList[] = Follow::fromAuthorToAuthor(
FollowId::nextIdentity(),
AuthorId::nextIdentity(),

View File

@@ -4,25 +4,14 @@ declare(strict_types=1);
namespace Cheeper\Tests\Chapter7\Application\Cheep\Projection;
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepDate;
use Cheeper\AllChapters\DomainModel\Cheep\CheepId;
use Cheeper\AllChapters\DomainModel\Cheep\CheepMessage;
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
use Cheeper\Chapter7\Application\Author\Event\AuthorFollowedEventHandler;
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandler;
use Cheeper\Chapter7\Application\Cheep\Event\CheepPostedEventHandler;
use Cheeper\Chapter7\Application\Cheep\Projection\AddCheepToTimelineProjection;
use Cheeper\Chapter7\Application\Cheep\Projection\AddCheepToTimelineProjectionHandler;
use Cheeper\Chapter7\DomainModel\Cheep\CheepPosted;
use Cheeper\Chapter7\DomainModel\Follow\Follow;
use Cheeper\Chapter7\DomainModel\Follow\FollowRepository;
use Cheeper\Chapter7\Infrastructure\Application\InMemoryProjectionBus;
use Cheeper\Chapter7\Infrastructure\DomainModel\Follow\InMemoryFollowRepository;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
final class AddCheepToTimelineProjectionHandlerTest extends TestCase
{
@@ -41,10 +30,10 @@ final class AddCheepToTimelineProjectionHandlerTest extends TestCase
$handler = new AddCheepToTimelineProjectionHandler($redisMock);
$handler(new AddCheepToTimelineProjection(
CheepId::nextIdentity()->toString(),
AuthorId::nextIdentity()->toString(),
CheepMessage::write('Hello World!')->message(),
(new CheepDate(
CheepId::nextIdentity()->toString(),
AuthorId::nextIdentity()->toString(),
CheepMessage::write('Hello World!')->message(),
(new CheepDate(
(new DateTimeImmutable(
'now',
new \DateTimeZone('UTC')

View File

@@ -7,12 +7,12 @@ namespace Cheeper\Tests\Helper;
use Cheeper\AllChapters\Infrastructure\Persistence\InMemoryAuthorRepository;
use Cheeper\AllChapters\Infrastructure\Persistence\InMemoryCheepRepository;
use Cheeper\AllChapters\Infrastructure\Persistence\InMemoryFollows;
use Cheeper\Chapter2\Hexagonal\DomainModel\AuthorRepository;
use Cheeper\Chapter2\Hexagonal\DomainModel\CheepRepository;
use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommand;
use Cheeper\Chapter4\Application\Cheep\Command\PostCheepCommandHandler;
use Cheeper\Chapter6\Infrastructure\Application\Event\InMemoryEventBus;
use Cheeper\AllChapters\Infrastructure\Persistence\InMemoryFollows;
trait SendsCommands
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Symfony\Component\Dotenv\Dotenv;