Commit 290418fe authored by Daniel Hürtgen's avatar Daniel Hürtgen
Browse files

[FEATURE] InvalidConfigurationException for Builder added

parent 1ee2d466
<?php
namespace Higidi\Lock\Builder\Exception;
/**
* Thrown on any invalid configuration within the builder.
*/
class InvalidConfigurationException extends \Exception
{
/**
* @var array
*/
protected $configuration;
/**
* Construct the exception. Note: The message is NOT binary safe.
*
* @link http://php.net/manual/en/exception.construct.php
*
* @param array $configuration The invalid configuration array
* @param string $message [optional] The Exception message to throw.
* @param int $code [optional] The Exception code.
* @param \Exception $previous [optional] The previous throwable used for the exception chaining.
*
* @since 5.1.0
*/
public function __construct(array $configuration, $message = "", $code = 0, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);
$this->configuration = $configuration;
}
/**
* Returns the configuration.
*
* @return array The configuration array
*/
public function getConfiguration()
{
return $this->configuration;
}
}
<?php
namespace Higidi\Lock\Tests\Unit\Builder\Exception;
use Higidi\Lock\Builder\Exception\InvalidConfigurationException;
use Nimut\TestingFramework\TestCase\UnitTestCase;
/**
* Test case for "\Higidi\Lock\Builder\Exception\InvalidConfigurationException".
*
* @covers \Higidi\Lock\Builder\Exception\InvalidConfigurationException
*/
class InvalidConfigurationExceptionTest extends UnitTestCase
{
/**
* @test
*/
public function itExtendsTheGenericException()
{
$sut = new InvalidConfigurationException([]);
$this->assertInstanceOf(\Exception::class, $sut);
}
/**
* @test
*/
public function itHoldsTheConfiguration()
{
$configuration = [
'bla' => 'foo',
];
$sut = new InvalidConfigurationException($configuration);
$this->assertSame($configuration, $sut->getConfiguration());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment