Skip to content

Commit

Permalink
Fixed aggregate root serialized value binding
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosprotung committed May 12, 2017
1 parent 882bddd commit 7e23241
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/PdoSnapshotStore.php
Expand Up @@ -122,7 +122,7 @@ public function save(Snapshot ...$snapshots): void
$statement->bindValue(++$position, $snapshot->aggregateType());
$statement->bindValue(++$position, $snapshot->lastVersion(), PDO::PARAM_INT);
$statement->bindValue(++$position, $snapshot->createdAt()->format('Y-m-d\TH:i:s.u'));
$statement->bindValue(++$position, $this->serializer->serialize($snapshot->aggregateRoot()));
$statement->bindValue(++$position, $this->serializer->serialize($snapshot->aggregateRoot()), PDO::PARAM_LOB);
}
$statements[] = $statement;
}
Expand Down
12 changes: 11 additions & 1 deletion tests/Container/PdoSnapshotStoreFactoryTest.php
Expand Up @@ -71,7 +71,17 @@ public function it_gets_serializer_from_container_when_not_instanceof_serializer

$container->get('my_connection')->willReturn($connection)->shouldBeCalled();
$container->get('config')->willReturn($config)->shouldBeCalled();
$container->get('serializer_servicename')->willReturn(new CallbackSerializer(function() {}, function() {}))->shouldBeCalled();
$container
->get('serializer_servicename')
->willReturn(
new CallbackSerializer(
function () {
},
function () {
}
)
)
->shouldBeCalled();

$factory = new PdoSnapshotStoreFactory();
$snapshotStore = $factory($container->reveal());
Expand Down
17 changes: 17 additions & 0 deletions tests/Mock/AggregateRoot.php
@@ -0,0 +1,17 @@
<?php
/**
* This file is part of the prooph/pdo-snapshot-store.
* (c) 2016-2017 prooph software GmbH <contact@prooph.de>
* (c) 2016-2017 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ProophTest\SnapshotStore\Pdo\Mock;

class AggregateRoot
{
}
4 changes: 2 additions & 2 deletions tests/PdoSnapshotStoreTest.php
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\TestCase;
use Prooph\SnapshotStore\Pdo\PdoSnapshotStore;
use Prooph\SnapshotStore\Snapshot;
use ProophTest\SnapshotStore\Pdo\Mock\AggregateRoot;

class PdoSnapshotStoreTest extends TestCase
{
Expand All @@ -35,8 +36,7 @@ class PdoSnapshotStoreTest extends TestCase
public function it_saves_and_reads()
{
$aggregateType = 'baz';
$aggregateRoot = new \stdClass();
$aggregateRoot->foo = 'bar';
$aggregateRoot = new AggregateRoot();

$time = (string) microtime(true);
if (false === strpos($time, '.')) {
Expand Down

0 comments on commit 7e23241

Please sign in to comment.