Skip to content

Commit

Permalink
feature: Implement unit test for custom exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielanhaia committed Jun 23, 2020
1 parent 8d7baac commit 8bd2838
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Exception/CircuitException.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public function __construct(
parent::__construct($message, $code, $previous);
$this->serviceName = $serviceName;
}

/**
* @return string
*/
public function getServiceName(): string
{
return $this->serviceName;
}
}
27 changes: 27 additions & 0 deletions tests/Unit/Exception/CircuitExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php


namespace Tests\Unit\Exception;

use GabrielAnhaia\PhpCircuitBreaker\Exception\CircuitException;
use Tests\TestCase;

/**
* Class CircuitExceptionTest
*
* @package Tests\Unit\Exception
*
* @author Gabriel Anhaia <[email protected]>
*/
class CircuitExceptionTest extends TestCase
{
/**
* Test if the exception holds the service-name.
*/
public function testExceptionWithServiceName()
{
$serviceName = 'TEST_SERVICE_NAME';
$exception = new CircuitException($serviceName);
$this->assertEquals($serviceName, $exception->getServiceName());
}
}

0 comments on commit 8bd2838

Please sign in to comment.