TestCase::reconstituteAggregateFromHistory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests;
6
7
use App\Kernel;
8
use Prooph\EventSourcing\Aggregate\AggregateType;
0 ignored issues
show
Bug introduced by
The type Prooph\EventSourcing\Aggregate\AggregateType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Prooph\EventSourcing\AggregateRoot;
0 ignored issues
show
Bug introduced by
The type Prooph\EventSourcing\AggregateRoot was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator;
0 ignored issues
show
Bug introduced by
The type Prooph\EventSourcing\Eve...ion\AggregateTranslator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Symfony\Component\DependencyInjection\Container;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\DependencyInjection\Container was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
13
class TestCase extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
{
15
    /**
16
     * @var Container|null
17
     */
18
    protected $container;
19
20
    /**
21
     * @var Kernel
22
     */
23
    private $kernel;
24
25
    protected function setUp(): void
26
    {
27
        parent::setUp(); // TODO: Change the autogenerated stub
28
        $this->kernel = new Kernel('test', true);
29
        $this->kernel->boot();
30
        $this->container = $this->kernel->getContainer();
31
    }
32
33
    /**
34
     * @var AggregateTranslator
35
     */
36
    private $aggregateTranslator;
37
38
    protected function popRecordedEvent(AggregateRoot $aggregateRoot): array
39
    {
40
        return $this->getAggregateTranslator()->extractPendingStreamEvents($aggregateRoot);
41
    }
42
43
    /**
44
     * @return object
45
     */
46
    protected function reconstituteAggregateFromHistory(string $aggregateRootClass, array $events): object
47
    {
48
        return $this->getAggregateTranslator()->reconstituteAggregateFromHistory(
49
            AggregateType::fromAggregateRootClass($aggregateRootClass),
50
            new \ArrayIterator($events)
51
        );
52
    }
53
54
    private function getAggregateTranslator(): AggregateTranslator
55
    {
56
        if (null === $this->aggregateTranslator) {
57
            $this->aggregateTranslator = new AggregateTranslator();
58
        }
59
60
        return $this->aggregateTranslator;
61
    }
62
}
63