From 5286bb03d687d987f4376132cef5c567754f938c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20Ivan=C4=8Di=C4=87?= <marko.ivancic@srce.hr>
Date: Mon, 6 Feb 2023 13:47:34 +0100
Subject: [PATCH] Adapt to non-nullable config options

---
 config-templates/module_accounting.php       | 6 +++---
 src/ModuleConfiguration.php                  | 6 +++---
 tests/config-templates/module_accounting.php | 2 +-
 tests/src/ModuleConfigurationTest.php        | 6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/config-templates/module_accounting.php b/config-templates/module_accounting.php
index 828725b..e1755cd 100644
--- a/config-templates/module_accounting.php
+++ b/config-templates/module_accounting.php
@@ -157,13 +157,13 @@ $config = [
      *
      * Maximum execution time for the job runner. You can use this option to limit job runner activity by combining
      * when the job runner will run (using cron configuration) and how long the job runner will be active
-     * (execution time). This can be null, meaning it will run indefinitely, or can be set as a duration
+     * (execution time). This can be false, meaning it will run indefinitely, or can be set as a duration
      * for DateInterval, examples being below. Note that when the job runner is run using Cron user
      * interface in SimpleSAMLphp, the duration will be taken from the 'max_execution_time' ini
      * setting, and will override this setting if ini setting is shorter.
      * @see https://www.php.net/manual/en/dateinterval.construct.php
      */
-    ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => null,
+    ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false,
     //ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'PT9M', // 9 minutes
     //ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'PT59M', // 59 minutes
     //ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => 'P1D', // 1 day
@@ -172,7 +172,7 @@ $config = [
      * Number of processed jobs after which the job runner should take a 1-second pause.
      *
      * This option was introduced so that the job runner can act in a more resource friendly fashion when facing
-     * backend store. If the value is null, there will be no pause.
+     * backend store. If the value is false, there will be no pause.
      */
     ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => 10,
 
diff --git a/src/ModuleConfiguration.php b/src/ModuleConfiguration.php
index 453d1b9..21e5d69 100644
--- a/src/ModuleConfiguration.php
+++ b/src/ModuleConfiguration.php
@@ -87,7 +87,7 @@ class ModuleConfiguration
     {
         $value = $this->get(self::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME);
 
-        if (is_null($value)) {
+        if ($value === false) {
             return null;
         }
 
@@ -109,13 +109,13 @@ class ModuleConfiguration
     {
         $value = $this->get(self::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED);
 
-        if (is_null($value)) {
+        if ($value === false) {
             return null;
         }
 
         if (! is_int($value)) {
             $message = sprintf(
-                'Option \'%s\' must be defined either as null, or positive integer.',
+                'Option \'%s\' must be defined either as false, or positive integer.',
                 self::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED
             );
             throw new InvalidConfigurationException($message);
diff --git a/tests/config-templates/module_accounting.php b/tests/config-templates/module_accounting.php
index 882170b..0ecea7b 100644
--- a/tests/config-templates/module_accounting.php
+++ b/tests/config-templates/module_accounting.php
@@ -48,7 +48,7 @@ $config = [
         ],
     ],
 
-    ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => null,
+    ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false,
 
     ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => 10,
 
diff --git a/tests/src/ModuleConfigurationTest.php b/tests/src/ModuleConfigurationTest.php
index 6c2fc0e..2c4612c 100644
--- a/tests/src/ModuleConfigurationTest.php
+++ b/tests/src/ModuleConfigurationTest.php
@@ -219,7 +219,7 @@ class ModuleConfigurationTest extends TestCase
     {
         $moduleConfiguration = new ModuleConfiguration(
             null,
-            [ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => false]
+            [ModuleConfiguration::OPTION_JOB_RUNNER_MAXIMUM_EXECUTION_TIME => []]
         );
 
         $this->expectException(InvalidConfigurationException::class);
@@ -255,7 +255,7 @@ class ModuleConfigurationTest extends TestCase
     {
         $moduleConfiguration = new ModuleConfiguration(
             null,
-            [ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => null]
+            [ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => false]
         );
 
         $this->assertNull($moduleConfiguration->getJobRunnerShouldPauseAfterNumberOfJobsProcessed());
@@ -268,7 +268,7 @@ class ModuleConfigurationTest extends TestCase
     {
         $moduleConfiguration = new ModuleConfiguration(
             null,
-            [ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => false]
+            [ModuleConfiguration::OPTION_JOB_RUNNER_SHOULD_PAUSE_AFTER_NUMBER_OF_JOBS_PROCESSED => []]
         );
 
         $this->expectException(InvalidConfigurationException::class);
-- 
GitLab