Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
prolic committed Jan 20, 2017
1 parent 78fddbf commit ab7135c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 140 deletions.
28 changes: 0 additions & 28 deletions src/Failure.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function buildCommandDispatcher(callable $eventStoreFactory, callable $producerF
return persistEvents($aggregateResult, $eventStoreFactory, $definition, $definition->extractAggregateId($message));
};

$publishEvents = function (AggregateResult $aggregateResult) use ($producerFactory): array {
$publishEvents = function (AggregateResult $aggregateResult) use ($producerFactory): AggregateResult {
return publishEvents($aggregateResult, $producerFactory);
};

Expand Down Expand Up @@ -153,7 +153,6 @@ function loadEvents(
return new ArrayIterator();
}


const persistEvents = 'Prooph\Micro\Kernel\persistEvents';

function persistEvents(AggregateResult $aggregateResult, callable $eventStoreFactory, AggregateDefiniton $definition, string $aggregateId): AggregateResult
Expand Down
32 changes: 27 additions & 5 deletions tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Prooph\EventStore\StreamName;
use Prooph\Micro\AggregateDefiniton;
use Prooph\Micro\AggregateResult;
use Prooph\Micro\Failure;
use Prooph\Micro\Kernel as f;
use ProophTest\Micro\TestAsset\TestAggregateDefinition;
use Prophecy\Argument;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function it_builds_command_dispatcher_and_dispatches(): void

$result = $dispatch($command->reveal());

$this->assertEquals(['some' => 'state'], $result());
$this->assertEquals(['some' => 'state'], $result);
}

/**
Expand Down Expand Up @@ -109,8 +108,8 @@ public function it_builds_command_dispatcher_and_dispatches_but_breaks_when_hand

$result = $dispatch($command->reveal());

$this->assertInstanceOf(Failure::class, $result);
$this->assertEquals('Invalid aggregate result returned', $result());
$this->assertInstanceOf(\Exception::class, $result);
$this->assertEquals('Invalid aggregate result returned', $result->getMessage());
}

/**
Expand Down Expand Up @@ -261,7 +260,7 @@ public function it_publishes_events(): void

$result = f\publishEvents($aggregateResult, $factory);

$this->assertEquals(['foo' => 'bar'], $result);
$this->assertSame($aggregateResult, $result);
}

/**
Expand Down Expand Up @@ -329,4 +328,27 @@ public function it_throws_exception_when_no_definition_found(): void

f\getAggregateDefinition($message->reveal(), $commandMap);
}

/**
* @test
*/
public function it_pipes(): void
{
$result = f\pipleline('strtolower', 'ucfirst')('aBC');

$this->assertEquals('Abc', $result);
}

/**
* @test
*/
public function it_handles_exceptions(): void
{
$result = f\pipleline(function () {
throw new \Exception('Exception there!');
}, 'ucfirst')('aBC');

$this->assertInstanceOf(\Exception::class, $result);
$this->assertEquals('Exception there!', $result->getMessage());
}
}
105 changes: 0 additions & 105 deletions tests/PipeTest.php

This file was deleted.

0 comments on commit ab7135c

Please sign in to comment.