Verified Commit c06cbe43 authored by Elias Häußler's avatar Elias Häußler 🐛
Browse files

[BUGFIX] Ensure enable state of services is correctly read

parent b94fe409
......@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Ensure enable state of services is correctly read
- Set correct `Content-Type` header for requests sent to remote services
## [0.8.0] - 2021-02-12
......
......@@ -29,6 +29,7 @@ use EliasHaeussler\ComposerUpdateCheck\IO\Style;
use EliasHaeussler\ComposerUpdateCheck\IO\Verbosity;
use EliasHaeussler\ComposerUpdateCheck\Options;
use EliasHaeussler\ComposerUpdateCheck\Package\UpdateCheckResult;
use EliasHaeussler\ComposerUpdateReporter\Exception\MissingConfigurationException;
use EliasHaeussler\ComposerUpdateReporter\Traits\ServiceConfigurationTrait;
use Spatie\Emoji\Emoji;
use Spatie\Emoji\Exceptions\UnknownCharacter;
......@@ -63,15 +64,11 @@ abstract class AbstractService implements ServiceInterface
*/
public static function isEnabled(array $configuration): bool
{
$identifier = static::getIdentifier();
$envVariable = strtoupper($identifier.'_enable');
$extra = $configuration[strtolower($identifier)] ?? null;
if (false !== getenv($envVariable)) {
return (bool) getenv($envVariable);
try {
return (bool) static::resolveConfigurationKey($configuration, 'enable');
} catch (MissingConfigurationException $e) {
return false;
}
return is_array($extra) && (bool) ($extra['enable'] ?? false);
}
abstract protected static function getName(): string;
......
......@@ -151,7 +151,7 @@ class AbstractServiceTest extends AbstractTestCase
],
],
'0',
false,
true,
];
yield 'falsy configuration and truthy environment variable' => [
[
......@@ -160,7 +160,7 @@ class AbstractServiceTest extends AbstractTestCase
],
],
'1',
true,
false,
];
yield 'empty configuration and truthy environment variable' => [
[
......
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