Skip to content

Commit

Permalink
Fix repository mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
codeliner committed Jan 12, 2014
1 parent c00015a commit c9d3f43
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Malocher/EventStore/EventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ class EventStore
*/
public function __construct(Configuration $config)
{
$this->adapter = $config->getAdapter();
$this->lookupSnapshots = $config->isSnapshotLookup();
$this->adapter = $config->getAdapter();
$this->lookupSnapshots = $config->isSnapshotLookup();
$this->autoGenerateSnapshots = $config->isAutoGenerateSnapshots();
$this->snapshotInterval = $config->getSnapshotInterval();
$this->objectFactory = $config->getObjectFactory();
$this->eventDispatcher = $config->getEventDispatcher();
$this->snapshotInterval = $config->getSnapshotInterval();
$this->repositoryMap = $config->getRepositoryMap();
$this->objectFactory = $config->getObjectFactory();
$this->eventDispatcher = $config->getEventDispatcher();


if ($this->autoGenerateSnapshots) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@ public function testGetRepository()
$this->assertSame($repo, $sameRepo);
}

public function testGetCustomRepository()
{
$config = new Configuration();
$config->setAdapter($this->getEventStoreAdapter());
$config->addRepositoryMapping(
'Malocher\EventStoreTest\Coverage\Mock\User',
'Malocher\EventStoreTest\Coverage\Mock\MockedRepository'
);
$this->eventStore = new EventStore($config);

$repo = $this->eventStore->getRepository(
'Malocher\EventStoreTest\Coverage\Mock\User'
);

$this->assertInstanceOf(
'Malocher\EventStoreTest\Coverage\Mock\MockedRepository',
$repo
);
}

public function testDispatchPostPersistEvent()
{
$factory = new EventSourcedObjectFactory();
Expand Down
21 changes: 21 additions & 0 deletions tests/Malocher/EventStoreTest/Coverage/Mock/MockedRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the codeliner/event-store package.
* (c) Alexander Miertsch <kontakt@codeliner.ws>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Malocher\EventStoreTest\Coverage\Mock;

use Malocher\EventStore\Repository\EventSourcingRepository;
/**
* Class MockedRepository
*
* @author Alexander Miertsch <kontakt@codeliner.ws>
*/
class MockedRepository extends EventSourcingRepository
{

}

0 comments on commit c9d3f43

Please sign in to comment.