More coverage
This commit is contained in:
@@ -41,11 +41,12 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"dama/doctrine-test-bundle": "^6.3",
|
||||
"dg/bypass-finals": "^1.3",
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.3",
|
||||
"elasticsearch/elasticsearch": "^7.14",
|
||||
"fakerphp/faker": "^1.15",
|
||||
"keyvanakbary/mimic": "^1.0",
|
||||
"mockery/mockery": "^1.4",
|
||||
"mockery/mockery": "^1.5",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"symfony/browser-kit": "5.3.*",
|
||||
"symfony/debug-bundle": "^5.3",
|
||||
|
||||
67
composer.lock
generated
67
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8fc4341702b683095d3e39d709c1144b",
|
||||
"content-hash": "1193a295ab80983d728597fbd634b569",
|
||||
"packages": [
|
||||
{
|
||||
"name": "api-platform/core",
|
||||
@@ -8239,6 +8239,59 @@
|
||||
},
|
||||
"time": "2021-11-09T11:55:09+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dg/bypass-finals",
|
||||
"version": "v1.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dg/bypass-finals.git",
|
||||
"reference": "495f5bc762e7bf30a13ed8253f44bb3a701767bb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/dg/bypass-finals/zipball/495f5bc762e7bf30a13ed8253f44bb3a701767bb",
|
||||
"reference": "495f5bc762e7bf30a13ed8253f44bb3a701767bb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"nette/tester": "^2.3",
|
||||
"phpstan/phpstan": "^0.12"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause",
|
||||
"GPL-2.0",
|
||||
"GPL-3.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Grudl",
|
||||
"homepage": "https://davidgrudl.com"
|
||||
}
|
||||
],
|
||||
"description": "Removes final keyword from source code on-the-fly and allows mocking of final methods and classes",
|
||||
"keywords": [
|
||||
"finals",
|
||||
"mocking",
|
||||
"phpunit",
|
||||
"testing",
|
||||
"unit"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/dg/bypass-finals/issues",
|
||||
"source": "https://github.com/dg/bypass-finals/tree/v1.3.1"
|
||||
},
|
||||
"time": "2021-04-09T10:42:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/data-fixtures",
|
||||
"version": "1.5.1",
|
||||
@@ -8746,16 +8799,16 @@
|
||||
},
|
||||
{
|
||||
"name": "mockery/mockery",
|
||||
"version": "1.4.4",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mockery/mockery.git",
|
||||
"reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346"
|
||||
"reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mockery/mockery/zipball/e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
|
||||
"reference": "e01123a0e847d52d186c5eb4b9bf58b0c6d00346",
|
||||
"url": "https://api.github.com/repos/mockery/mockery/zipball/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
|
||||
"reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -8812,9 +8865,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/mockery/mockery/issues",
|
||||
"source": "https://github.com/mockery/mockery/tree/1.4.4"
|
||||
"source": "https://github.com/mockery/mockery/tree/1.5.0"
|
||||
},
|
||||
"time": "2021-09-13T15:28:59+00:00"
|
||||
"time": "2022-01-20T13:18:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
|
||||
@@ -90,18 +90,18 @@ services:
|
||||
Cheeper\Chapter6\:
|
||||
resource: '../src/Cheeper/Chapter6/*'
|
||||
|
||||
Cheeper\Chapter6\Application\Author\Projection\CountFollowerProjectionHandler: ~
|
||||
Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler: ~
|
||||
|
||||
Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler:
|
||||
tags:
|
||||
- { name: messenger.message_handler, bus: command.bus }
|
||||
class: 'Cheeper\Chapter6\Application\Author\Command\WithDomainEvents\FollowCommandHandler'
|
||||
|
||||
Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyCountFollowerProjector:
|
||||
Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyCountFollowersProjector:
|
||||
tags:
|
||||
- { name: messenger.message_handler, bus: command.bus }
|
||||
arguments:
|
||||
- '@Cheeper\Chapter6\Application\Author\Projection\CountFollowerProjectionHandler'
|
||||
- '@Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler'
|
||||
|
||||
Cheeper\Chapter6\Infrastructure\Application\Author\Projection\SymfonyAuthorFollowedHandler:
|
||||
tags:
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true"
|
||||
bootstrap="tests/bootstrap.php" executionOrder="random">
|
||||
bootstrap="tests/bootstrap.php" executionOrder="random"
|
||||
resolveDependencies="true">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">src/Cheeper</directory>
|
||||
|
||||
@@ -6,15 +6,14 @@ namespace Cheeper\Chapter6\Infrastructure\Application\Author\Projection;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Follow\AuthorFollowed;
|
||||
use Cheeper\AllChapters\DomainModel\Follow\AuthorUnfollowed;
|
||||
use Cheeper\Chapter6\Application\Projector\Author\CountFollowerProjectionHandler;
|
||||
use Cheeper\Chapter6\Application\Projector\Author\CountFollowersProjection;
|
||||
use Cheeper\Chapter6\Application\Author\Projection\CountFollowersProjectionHandler;
|
||||
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
|
||||
|
||||
//snippet symfony-projector-count-followers
|
||||
final class SymfonyCountFollowerProjector implements MessageSubscriberInterface
|
||||
final class SymfonyCountFollowersProjector implements MessageSubscriberInterface
|
||||
{
|
||||
public function __construct(
|
||||
private CountFollowerProjectionHandler $projector
|
||||
private CountFollowersProjectionHandler $projector
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ declare(strict_types=1);
|
||||
namespace Cheeper\Chapter7\Application\Author\Event;
|
||||
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjection;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandler;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandlerInterface;
|
||||
use Cheeper\Chapter7\DomainModel\Follow\AuthorFollowed;
|
||||
|
||||
//snippet author-followed-event-handler
|
||||
final class AuthorFollowedEventHandler
|
||||
{
|
||||
public function __construct(
|
||||
private CountFollowersProjectionHandler $projectionHandler
|
||||
private CountFollowersProjectionHandlerInterface $projectionHandler
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
use Redis;
|
||||
|
||||
//snippet projector-count-followers
|
||||
final class CountFollowersProjectionHandler
|
||||
final class CountFollowersProjectionHandler implements CountFollowersProjectionHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private Redis $redis,
|
||||
@@ -40,11 +40,9 @@ final class CountFollowersProjectionHandler
|
||||
$projectionResult = [
|
||||
'id' => $authorId->toString(),
|
||||
'username' => $result['username'],
|
||||
'followers' => 0,
|
||||
'followers' => (int) $result['followers'],
|
||||
];
|
||||
|
||||
$projectionResult['followers'] = (int) $result['followers'];
|
||||
|
||||
$this->redis->set(
|
||||
'author_followers_counter_projection:'.$authorId->toString(),
|
||||
json_encode($projectionResult, JSON_THROW_ON_ERROR)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Cheeper\Chapter7\Application\Author\Projection;
|
||||
|
||||
interface CountFollowersProjectionHandlerInterface
|
||||
{
|
||||
public function __invoke(CountFollowersProjection $projection): void;
|
||||
}
|
||||
@@ -31,6 +31,9 @@
|
||||
"config/packages/test/dama_doctrine_test_bundle.yaml"
|
||||
]
|
||||
},
|
||||
"dg/bypass-finals": {
|
||||
"version": "v1.3.1"
|
||||
},
|
||||
"doctrine/annotations": {
|
||||
"version": "1.0",
|
||||
"recipe": {
|
||||
@@ -186,7 +189,7 @@
|
||||
"version": "1.11.0"
|
||||
},
|
||||
"mockery/mockery": {
|
||||
"version": "1.4.4"
|
||||
"version": "1.5.0"
|
||||
},
|
||||
"monolog/monolog": {
|
||||
"version": "2.0.2"
|
||||
|
||||
@@ -4,25 +4,39 @@ declare(strict_types=1);
|
||||
|
||||
namespace Cheeper\Tests\Chapter7\Application\Author\Event;
|
||||
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorDoesNotExist;
|
||||
use Cheeper\AllChapters\DomainModel\Author\AuthorId;
|
||||
use Cheeper\AllChapters\DomainModel\Follow\FollowId;
|
||||
use Cheeper\Chapter7\Application\Author\Event\AuthorFollowedEventHandler;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandler;
|
||||
use DateTimeImmutable;
|
||||
use Cheeper\Chapter7\Application\Author\Projection\CountFollowersProjectionHandlerInterface;
|
||||
use Cheeper\Chapter7\DomainModel\Follow\AuthorFollowed;
|
||||
use Cheeper\Chapter7\DomainModel\Follow\Follow;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
final class AuthorFollowedEventHandlerTest extends TestCase
|
||||
{
|
||||
|
||||
protected function setUp(): void
|
||||
/**
|
||||
* @test
|
||||
* @Given Non Existing Customer Or Without
|
||||
* @When When
|
||||
* @Then
|
||||
*/
|
||||
public function authorNonExistingOrWithoutFollowers(): void
|
||||
{
|
||||
$mock = $this->createMock(CountFollowersProjectionHandlerInterface::class);
|
||||
$mock->expects($this->once())->method('__invoke');
|
||||
|
||||
}
|
||||
$eventHandler = new AuthorFollowedEventHandler($mock);
|
||||
|
||||
/** @test */
|
||||
public function itDelegatesIntoProjectionHandler(): void
|
||||
{
|
||||
$this->markTestSkipped();
|
||||
$follow = Follow::fromAuthorToAuthor(
|
||||
FollowId::nextIdentity(),
|
||||
AuthorId::nextIdentity(),
|
||||
AuthorId::nextIdentity(),
|
||||
);
|
||||
|
||||
$eventHandler->handle(
|
||||
AuthorFollowed::fromFollow(
|
||||
$follow
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user