Completed
Push — master ( f129a6...32f3bd )
by Tomáš
02:23
created

AsynchronousMessagesExampleIntegrationTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 44
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvoke_WithTestConfig_BySavingNewAggregateToRepostory_ShouldPublishExpectedMessageToExpectedProducerRo() 0 12 1
A givenTestRepository() 0 7 1
A givenTestAggregate() 0 4 1
A whenAggregateSaved() 0 4 1
A getPublishedEventsFromTestBridge() 0 7 1
1
<?php declare(strict_types = 1);
2
3
namespace TomCizek\SymfonyProoph\Tests\AsynchronousMessages;
4
5
use TomCizek\SymfonyProoph\Tests\AsynchronousMessages\FakeImplementations\TestAsynchronousMessageProducerBridge;
6
use TomCizek\SymfonyProoph\Tests\EventSourcing\FakeImplementations\MemoryTestRepository;
7
use TomCizek\SymfonyProoph\Tests\EventSourcing\FakeImplementations\TestAggregateRoot;
8
9
class AsynchronousMessagesExampleIntegrationTest extends AbstractAsynchronousMessagesTestCase
10
{
11
	const FIXTURE_CONFIG_FILE = 'FullTestConfig.yml';
12
	const TEST_PRODUCER_ROUTE_KEY = 'producerRouteKey';
13
14
	public function testInvoke_WithTestConfig_BySavingNewAggregateToRepostory_ShouldPublishExpectedMessageToExpectedProducerRouteKey(
15
	)
16
	{
17
		$this->givenContainerWithLoadedBundlesWithGivenConfig(self::FIXTURE_CONFIG_FILE);
18
19
		$repository = $this->givenTestRepository();
20
		$aggregate = $this->givenTestAggregate();
21
22
		$this->whenAggregateSaved($repository, $aggregate);
23
24
		$this->thenShouldPublishExpectedMessageToExpectedProducerRouteKey(self::TEST_PRODUCER_ROUTE_KEY);
25
	}
26
27
	private function givenTestRepository(): MemoryTestRepository
28
	{
29
		/** @var MemoryTestRepository $repository */
30
		$repository = $this->container->get(MemoryTestRepository::class);
31
32
		return $repository;
33
	}
34
35
	private function givenTestAggregate(): TestAggregateRoot
36
	{
37
		return TestAggregateRoot::create();
38
	}
39
40
	private function whenAggregateSaved(MemoryTestRepository $repository, TestAggregateRoot $aggregate): void
41
	{
42
		$repository->save($aggregate);
43
	}
44
45
	protected function getPublishedEventsFromTestBridge(): array
46
	{
47
		/** @var TestAsynchronousMessageProducerBridge $testProducerBridge */
48
		$testProducerBridge = $this->container->get(TestAsynchronousMessageProducerBridge::class);
49
50
		return $testProducerBridge->getPublished();
51
	}
52
}
53