Skip to content

Commit

Permalink
fixed wrong exception namespace, added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Miliooo committed Oct 29, 2015
1 parent ff58dbc commit 4a801b9
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 42 deletions.
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
"doctrine/orm": "^2.4"
},
"require-dev": {
"phpunit/phpunit": "^4.6"
"phpunit/phpunit": "~5.0"
},
"autoload": {
"psr-4": {
"Milio\\CQRS\\": "src"
}
}
},
"autoload-dev": {
"psr-4": { "Milio\\CQRS\\Tests\\": "tests" }
}
}
140 changes: 113 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/EventSourcing/EventSourcingRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public function __construct(EventStoreInterface $eventStore, EventBusInterface $
$aggregateFactory = new PublicConstructorAggregateFactory();
parent::__construct($eventStore, $eventBus, $aggregateClass, $aggregateFactory, []);
}
}
}
5 changes: 2 additions & 3 deletions src/ReadModel/Exception/NotFoundReadModelException.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

namespace Milio\CQRS\Readmodel\Exception;
namespace Milio\CQRS\ReadModel\Exception;

/**
* Exception that gets thrown when read model could not be found by it's identifier
*/
class NotFoundReadModelException extends \Exception
{

}
}
13 changes: 7 additions & 6 deletions src/ReadModel/InMemory/MilioInMemoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Milio\CQRS\ReadModel\InMemory;

use Broadway\ReadModel\InMemory\InMemoryRepository;
use Broadway\ReadModel\ReadModelInterface;
use Milio\CQRS\Readmodel\Exception\NotFoundReadModelException;
use Broadway\ReadModel\RepositoryInterface;
use Milio\CQRS\ReadModel\Exception\NotFoundReadModelException;
use Milio\CQRS\ReadModel\ReadModelRepositoryInterface;

class MilioInMemoryRepository implements ReadModelRepositoryInterface
{
private $repository;

public function __construct(InMemoryRepository $repository)
public function __construct(RepositoryInterface $repository)
{
$this->repository = $repository;
}
Expand All @@ -25,8 +25,9 @@ public function __construct(InMemoryRepository $repository)
public function findOrFail($id)
{
$result = $this->repository->find($id);
if (empty($result)) {
throw new NotFoundReadModelException();

if (null == $result) {
throw new NotFoundReadModelException();
}

return $result;
Expand Down Expand Up @@ -90,4 +91,4 @@ public function remove($id)
{
return $this->repository->remove($id);
}
}
}
7 changes: 4 additions & 3 deletions tests/Identifier/AggregateIdentifierTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace Milio\CQRS\Identifier;
namespace Milio\CQRS\Tests\Identifier;

use Milio\CQRS\Identifier\Testing\AggregateIdentifierTestCase;
use Milio\CQRS\Identifier\AggregateIdentifier;

class AggregateIdentifierTest extends AggregateIdentifierTestCase
{
Expand All @@ -12,7 +13,7 @@ class AggregateIdentifierTest extends AggregateIdentifierTestCase
public function generate_returns_an_object()
{
$test = TestIdentifier::generate();
$this->assertInstanceof('Milio\CQRS\Identifier\TestIdentifier', $test);
$this->assertInstanceof('Milio\CQRS\Tests\Identifier\TestIdentifier', $test);
}

/**
Expand Down Expand Up @@ -43,7 +44,7 @@ public function it_supports_returning_as_string()
public function it_takes_a_string_as_constructor_argument()
{
$test = new TestIdentifier('foo');
$this->assertInstanceof('Milio\CQRS\Identifier\TestIdentifier', $test);
$this->assertInstanceof('Milio\CQRS\Tests\Identifier\TestIdentifier', $test);
$this->assertEquals('foo', (string) $test);
$this->assertEquals('foo', $test->getIdentifierString());
}
Expand Down

0 comments on commit 4a801b9

Please sign in to comment.