diff --git a/src/Checks/Php/Extensions.php b/src/Checks/Php/Extensions.php new file mode 100644 index 0000000..531d000 --- /dev/null +++ b/src/Checks/Php/Extensions.php @@ -0,0 +1,34 @@ +getBuilder(); + + $extensions = $this->getParam('extensions', []); + $errors = []; + + foreach ($extensions as $extension) { + if (! extension_loaded($extension)) { + $errors[] = $extension; + } + } + + if ($errors) { + $builder->down()->withData('errors', $errors); + } + + return $builder->build(); + } +} \ No newline at end of file diff --git a/tests/Checks/PhpExtensionsTest.php b/tests/Checks/PhpExtensionsTest.php new file mode 100644 index 0000000..eea3362 --- /dev/null +++ b/tests/Checks/PhpExtensionsTest.php @@ -0,0 +1,25 @@ +assertCheck($this->runCheck(Extensions::class, []), 'UP'); + + $this->assertCheck($this->runCheck(Extensions::class, [ + 'extensions' => [ + 'nosuch' + ] + ]), 'DOWN'); + + $this->assertCheck($this->runCheck(Extensions::class, [ + 'extensions' => [ + 'mbstring' + ] + ]), extension_loaded('mbstring') ? 'UP' : 'DOWN'); + } +} \ No newline at end of file