diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f972d..63b9356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org). +## [1.4.0] - 2021-12-05 +### Added +* Created new factory to tell if either swoole or openswoole are enabled + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* *Nothing* + + ## [1.3.1] - 2021-11-01 ### Added * *Nothing* diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index c8bd32a..9d34f06 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -11,6 +11,9 @@ public function __invoke(): array return [ 'dependencies' => [ + 'factories' => [ + Factory\SwooleInstalledFactory::SWOOLE_INSTALLED => Factory\SwooleInstalledFactory::class, + ], 'abstract_factories' => [ Factory\DottedAccessConfigAbstractFactory::class, ], diff --git a/src/Factory/SwooleInstalledFactory.php b/src/Factory/SwooleInstalledFactory.php new file mode 100644 index 0000000..01a68d4 --- /dev/null +++ b/src/Factory/SwooleInstalledFactory.php @@ -0,0 +1,17 @@ + extension_loaded('openswoole') || extension_loaded('swoole'); + } +} diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index f14a9f8..d7c91a7 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -7,6 +7,7 @@ use PHPUnit\Framework\TestCase; use Shlinkio\Shlink\Config\ConfigProvider; use Shlinkio\Shlink\Config\Factory\DottedAccessConfigAbstractFactory; +use Shlinkio\Shlink\Config\Factory\SwooleInstalledFactory; class ConfigProviderTest extends TestCase { @@ -23,6 +24,9 @@ public function configIsReturned(): void $config = ($this->configProvider)(); self::assertArrayHasKey('dependencies', $config); self::assertEquals([ + 'factories' => [ + SwooleInstalledFactory::SWOOLE_INSTALLED => SwooleInstalledFactory::class, + ], 'abstract_factories' => [ DottedAccessConfigAbstractFactory::class, ], diff --git a/test/Factory/SwooleInstalledFactoryTest.php b/test/Factory/SwooleInstalledFactoryTest.php new file mode 100644 index 0000000..4ca137f --- /dev/null +++ b/test/Factory/SwooleInstalledFactoryTest.php @@ -0,0 +1,26 @@ +factory = new SwooleInstalledFactory(); + } + + /** @test */ + public function properlyCreatesHelperFunction(): void + { + $func = ($this->factory)(); + + self::assertFalse($func()); + } +}