Skip to content

Commit bbca383

Browse files
author
Galin Denev
committed
Phpunit
1 parent 4702025 commit bbca383

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

composer.lock

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
4+
backupGlobals="false"
5+
colors="true"
6+
bootstrap="vendor/autoload.php"
7+
>
8+
<php>
9+
<ini name="error_reporting" value="-1" />
10+
</php>
11+
<testsuites>
12+
<testsuite name="AnyB1s DDD Framework">
13+
<directory>./tests</directory>
14+
</testsuite>
15+
</testsuites>
16+
<filter>
17+
<whitelist>
18+
<directory>./src</directory>
19+
<exclude>
20+
<directory>./tests</directory>
21+
</exclude>
22+
</whitelist>
23+
</filter>
24+
</phpunit>

src/Common/EventStore/Storage/DatabaseStorageFacility.php src/Common/EventStore/Storage/MysqlStorageFacility.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
use PDO;
99
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
1010

11-
final class DatabaseStorageFacility implements StorageFacility
11+
/**
12+
* Class MysqlStorageFacility
13+
* @package AnyB1s\Data\Common\EventSourcing\EventStore\Storage
14+
*/
15+
final class MysqlStorageFacility implements StorageFacility
1216
{
1317
/** @var PDO $connection */
1418
private $connection;
@@ -31,6 +35,11 @@ public function __construct(PDO $connection, string $table)
3135
$this->table = $table;
3236
}
3337

38+
/**
39+
* @param string $aggregateType
40+
* @param string $aggregateId
41+
* @return array
42+
*/
3443
public function loadEventsOf(string $aggregateType, string $aggregateId): array
3544
{
3645
$statement = $this->connection->prepare(
@@ -42,13 +51,19 @@ public function loadEventsOf(string $aggregateType, string $aggregateId): array
4251
return $statement->fetchAll(PDO::FETCH_COLUMN);
4352
}
4453

54+
/**
55+
* @return array
56+
*/
4557
public function loadAllEvents(): array
4658
{
4759
return $this->connection
4860
->prepare("SELECT `payload` FROM `{$this->table}`")
4961
->fetchAll(PDO::FETCH_COLUMN);
5062
}
5163

64+
/**
65+
* @param EventEnvelope $eventEnvelope
66+
*/
5267
public function append(EventEnvelope $eventEnvelope): void
5368
{
5469
$statement = $this->connection->prepare("INSERT INTO `{$this->table}` VALUES (?, ?)");
@@ -58,6 +73,9 @@ public function append(EventEnvelope $eventEnvelope): void
5873
$statement->execute();
5974
}
6075

76+
/**
77+
*
78+
*/
6179
public function deleteAll(): void
6280
{
6381
$this->connection->query("DELETE FROM `{$this->table}`");

0 commit comments

Comments
 (0)