Skip to content

Commit

Permalink
Merge pull request #94 from codeliner/feature/in_transaction
Browse files Browse the repository at this point in the history
Add method to check whether event store is in transaction
  • Loading branch information
prolic committed Sep 18, 2015
2 parents c998832 + 0d31d01 commit ba9f005
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/EventStore.php
Expand Up @@ -342,6 +342,14 @@ public function rollback()
$this->recordedEvents = [];
}

/**
* @return bool
*/
public function isInTransaction()
{
return $this->transactionLevel > 0;
}

/**
* @return ActionEventEmitter
*/
Expand Down
4 changes: 4 additions & 0 deletions tests/EventStoreTest.php
Expand Up @@ -729,10 +729,14 @@ public function it_commits_transaction_if_adapter_implements_can_handle_transact

$this->eventStore->beginTransaction();

$this->assertTrue($this->eventStore->isInTransaction());

$this->eventStore->create($stream);

$this->eventStore->commit();

$this->assertFalse($this->eventStore->isInTransaction());

$stream = $this->eventStore->load($stream->streamName());

$this->assertEquals('user', $stream->streamName()->toString());
Expand Down

0 comments on commit ba9f005

Please sign in to comment.