From 8bd28380a9b1581ad458c70e76e66c8b34cf64b7 Mon Sep 17 00:00:00 2001 From: Gabriel Anhaia Date: Tue, 23 Jun 2020 09:41:16 -0300 Subject: [PATCH] feature: Implement unit test for custom exception. --- src/Exception/CircuitException.php | 8 ++++++ tests/Unit/Exception/CircuitExceptionTest.php | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/Unit/Exception/CircuitExceptionTest.php diff --git a/src/Exception/CircuitException.php b/src/Exception/CircuitException.php index a2300a7..0e3f2b1 100644 --- a/src/Exception/CircuitException.php +++ b/src/Exception/CircuitException.php @@ -36,4 +36,12 @@ public function __construct( parent::__construct($message, $code, $previous); $this->serviceName = $serviceName; } + + /** + * @return string + */ + public function getServiceName(): string + { + return $this->serviceName; + } } \ No newline at end of file diff --git a/tests/Unit/Exception/CircuitExceptionTest.php b/tests/Unit/Exception/CircuitExceptionTest.php new file mode 100644 index 0000000..2925e1e --- /dev/null +++ b/tests/Unit/Exception/CircuitExceptionTest.php @@ -0,0 +1,27 @@ + + */ +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()); + } +} \ No newline at end of file