Skip to content

Commit

Permalink
fix: add new exception for config
Browse files Browse the repository at this point in the history
  • Loading branch information
avlyalin committed Jul 7, 2020
1 parent d5e66a0 commit 0de1acb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/Exceptions/ConfigException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Avlyalin\SberbankAcquiring\Exceptions;

class ConfigException extends AcquiringException
{

}
6 changes: 3 additions & 3 deletions src/Traits/HasConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Avlyalin\SberbankAcquiring\Traits;

use Avlyalin\SberbankAcquiring\Exceptions\AcquiringException;
use Avlyalin\SberbankAcquiring\Exceptions\ConfigException;
use Exception;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Foundation\Application;
Expand Down Expand Up @@ -57,13 +57,13 @@ public function getConfigBaseURIParam(): string
* @param string $key
*
* @return Repository|Application|mixed
* @throws \Avlyalin\SberbankAcquiring\Exceptions\AcquiringException
* @throws \Avlyalin\SberbankAcquiring\Exceptions\ConfigException
*/
public function getConfigParam(string $key)
{
$value = config("sberbank-acquiring.$key");
if (is_null($value)) {
throw new AcquiringException(
throw new ConfigException(
"Error: cannot find key \"$key\" in config/sberbank-acquiring.php. Config could not be loaded."
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Traits/HasConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Avlyalin\SberbankAcquiring\Tests\Traits;

use Avlyalin\SberbankAcquiring\Exceptions\AcquiringException;
use Avlyalin\SberbankAcquiring\Exceptions\ConfigException;
use Avlyalin\SberbankAcquiring\Tests\TestCase;
use Avlyalin\SberbankAcquiring\Traits\HasConfig;
use Illuminate\Support\Facades\Config;
Expand Down Expand Up @@ -32,7 +32,7 @@ public function should_throw_exception_for_bad_table_name_key()

$mock = $this->getMockForHasConfigTrait();

$this->expectException(AcquiringException::class);
$this->expectException(ConfigException::class);
$mock->getTableName('payment');
}

Expand Down

0 comments on commit 0de1acb

Please sign in to comment.