Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelandrieu committed May 20, 2019
1 parent 0c233b6 commit d0096e3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/Events/TransitionEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,19 @@ public function testGetParameters(): void

$this->assertSame($parameters, $event->getParameters());
}

/**
* @depends testCreation
*/
public function testGetCircuitBreaker(): void
{
$event = new TransitionEvent(
$this->createMock(CircuitBreaker::class),
'eventName',
'bar',
[]
);

$this->assertInstanceOf(CircuitBreaker::class, $event->getCircuitBreaker());
}
}
25 changes: 24 additions & 1 deletion tests/Transactions/SimpleTransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPUnit\Framework\TestCase;
use Resiliency\Contracts\Place;
use Resiliency\Transactions\SimpleTransaction;
use Resiliency\Exceptions\InvalidTransaction;

class SimpleTransactionTest extends TestCase
{
Expand Down Expand Up @@ -80,7 +81,7 @@ public function testIncrementFailures()
/**
* @depends testCreation
*/
public function testCreationFromPlaceHelper()
public function testCreationFromPlaceHelper(): void
{
$simpleTransactionFromHelper = SimpleTransaction::createFromPlace(
$this->createPlaceStub(),
Expand All @@ -97,6 +98,28 @@ public function testCreationFromPlaceHelper()
$this->assertSame($fromPlaceDate, $expectedDate);
}

/**
* @depends testCreation
*/
public function testCreationWithInvalidSettingsWillThrowAnException(): void
{
$this->expectException(InvalidTransaction::class);

$placeStub = $this->createMock(Place::class);

$placeStub->expects($this->any())
->method('getState')
->willReturn('FAKE_STATE')
;

$placeStub->expects($this->any())
->method('getThreshold')
->willReturn(-1)
;

SimpleTransaction::createFromPlace($placeStub, 'http://some-uri.domain');
}

/**
* Returns an instance of SimpleTransaction for tests.
*
Expand Down

0 comments on commit d0096e3

Please sign in to comment.