From 8cc66f7c75b46a9f3fdfc2849acf3cd4f42b6723 Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 15 May 2024 15:25:56 +0200 Subject: [PATCH 01/13] =?UTF-8?q?N=C2=B05139=20-=20Let=20data=20that=20is?= =?UTF-8?q?=20null=20also=20be=20null=20at=20the=20other=20side-fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/collector.class.inc.php | 2 +- test/CollectorTest.php | 18 +++-- .../iTopPersonCollector.class.inc.php | 65 ++++++++++++++----- .../nullified_json_1/expected_generated.csv | 4 +- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/core/collector.class.inc.php b/core/collector.class.inc.php index 3b4d624..8d4acab 100644 --- a/core/collector.class.inc.php +++ b/core/collector.class.inc.php @@ -594,7 +594,7 @@ protected function AddRow($aRow) { $aData = array(); foreach ($this->aCSVHeaders as $sHeader) { - if (is_null($aRow[$sHeader]) && $this->AttributeIsNullified($sHeader)) { + if (strlen($aRow[$sHeader])==0 && $this->AttributeIsNullified($sHeader)) { $aData[] = NULL_VALUE; } else { $aData[] = $aRow[$sHeader]; diff --git a/test/CollectorTest.php b/test/CollectorTest.php index 67004b5..49a72c2 100644 --- a/test/CollectorTest.php +++ b/test/CollectorTest.php @@ -109,15 +109,19 @@ public function testAttributeIsNullified($sCollectorXmlSubSection, $bExpectedIsN $this->assertEquals($bExpectedIsNullified, $oCollector->AttributeIsNullified('phone')); - $oCollector->Collect(1); + $oCollector->Collect(); $sExpectedCsv = <<;123456;9998877665544;issac.asimov@function.io;writer +1;isaac;asimov_null;Demo;;123456;9998877665544;issac.asimov@function.io;writer +2;isaac;asimov_empty;Demo;;123456;9998877665544;issac.asimov@function.io;writer +3;isaac;asimov_notempty;Demo;"not empty";123456;9998877665544;issac.asimov@function.io;writer CSV; @@ -158,12 +162,12 @@ public function testUpdateSDSAttributes($aExpectedAttrDef, $aSynchroAttrDef, boo $oCollector = new iTopPersonCollector(); $oMockClient = $this->CreateMock('RestClient'); $oMockClient->expects($this->exactly($bWillUpdate ? 1 : 0))->method("Update")->willReturn(['code' => 0]); - + $bRet = $this->InvokeNonPublicMethod(get_class($oCollector), 'UpdateSDSAttributes', $oCollector, [$aExpectedAttrDef, $aSynchroAttrDef, '', $oMockClient]); - + $this->assertTrue($bRet); } - + public function providerUpdateSDSAttributes() { return [ @@ -271,7 +275,7 @@ public function InvokeNonPublicMethod($sObjectClass, $sMethodName, $oObject, $aA $class = new \ReflectionClass($sObjectClass); $method = $class->getMethod($sMethodName); $method->setAccessible(true); - + return $method->invokeArgs($oObject, $aArgs); } } diff --git a/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php b/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php index eb87c65..481ed39 100644 --- a/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php +++ b/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php @@ -2,29 +2,62 @@ class iTopPersonCollector extends Collector { - private $bFetched; + private $i; + private $aCurrentData; protected function Fetch() { - if (! $this->bFetched) { - $this->bFetched = true; - return [ - 'primary_key' => 1, - 'first_name' => "isaac", - 'name' => "asimov", - 'org_id' => "Demo", - 'phone' => null, - 'mobile_phone' => "123456", - 'employee_number' => "9998877665544", - 'email' => "issac.asimov@function.io", - 'function' => "writer", - 'Status' => "Active", + if (is_null($this->aCurrentData)){ + $this->i = 0; + $this->aCurrentData = [ + [ + 'primary_key' => 1, + 'first_name' => "isaac", + 'name' => "asimov_null", + 'org_id' => "Demo", + 'phone' => null, + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], + [ + 'primary_key' => 2, + 'first_name' => "isaac", + 'name' => "asimov_empty", + 'org_id' => "Demo", + 'phone' => "", + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], + [ + 'primary_key' => 3, + 'first_name' => "isaac", + 'name' => "asimov_notempty", + 'org_id' => "Demo", + 'phone' => "not empty", + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], ]; } - return null; + $res = null; + if ($this->i < count($this->aCurrentData)){ + $res=$this->aCurrentData[$this->i]; + $this->i++; + } + + return $res; } - + /** * {@inheritDoc} * @see Collector::AttributeIsOptional() diff --git a/test/single_json/nullified_json_1/expected_generated.csv b/test/single_json/nullified_json_1/expected_generated.csv index 3bab6b3..468643d 100644 --- a/test/single_json/nullified_json_1/expected_generated.csv +++ b/test/single_json/nullified_json_1/expected_generated.csv @@ -1,4 +1,4 @@ primary_key;name;status;first_name;email;phone;org_id;function 1;"My last name";active;"My first name";my.email@foo.org;"+00 000 000 000";1; -2;Picasso;active;Pablo;pablo@demo.com;;3; -3;Dali;active;Salvador;dali@demo.com;;3; +2;Picasso;active;Pablo;pablo@demo.com;;3; +3;Dali;active;Salvador;dali@demo.com;;3; From 8125470e8a92983df720cf9ebf9a8031dc9b84b3 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 12 Feb 2024 11:59:02 +0100 Subject: [PATCH 02/13] Correct composer php version according to documentation --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index feb3990..99c652e 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { "require": { - "php": "7.*", + "php": "7.* || 8.0.* || 8.1.", "ext-libxml": "*" }, "require-dev": { - "phpunit/phpunit": "^9" + "phpunit/phpunit": "*" } } From 19c8c2b0fb22d1177c7ec620b08743f099d2ae71 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 12 Feb 2024 11:59:35 +0100 Subject: [PATCH 03/13] Apply min versions according to composer.json restrictions --- core/orchestrator.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/orchestrator.class.inc.php b/core/orchestrator.class.inc.php index 7ea3e2c..b1b1ff4 100644 --- a/core/orchestrator.class.inc.php +++ b/core/orchestrator.class.inc.php @@ -17,7 +17,7 @@ class Orchestrator { static $aCollectors = array(); - static $aMinVersions = array('PHP' => '5.3.0', 'simplexml' => '0.1', 'dom' => '1.0'); + static $aMinVersions = array('PHP' => '7.0', 'simplexml' => '7.0', 'dom' => '1'); /** * Add a collector class to be run in the specified order From 8e2d46b90b4d82aeb3e2cc77043d34869e0b8c45 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 29 Apr 2024 09:24:43 +0200 Subject: [PATCH 04/13] Revert phpunit version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 99c652e..844c62e 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,6 @@ "ext-libxml": "*" }, "require-dev": { - "phpunit/phpunit": "*" + "phpunit/phpunit": "^6" } } From bfa7e5e9974cc31692f1a25dd76eb0714a60378c Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Fri, 18 Oct 2024 11:06:51 +0200 Subject: [PATCH 05/13] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 844c62e..3b4afbe 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": "7.* || 8.0.* || 8.1.", + "php": "7.* || 8.* <= 8.3", "ext-libxml": "*" }, "require-dev": { From 72819ef3783e334ec6c38eebfc9b81192b217453 Mon Sep 17 00:00:00 2001 From: jf-cbd <121934370+jf-cbd@users.noreply.github.com> Date: Mon, 23 Dec 2024 15:32:35 +0100 Subject: [PATCH 06/13] Create action.yml To classify PRs --- .github/workflows/action.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/action.yml diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml new file mode 100644 index 0000000..3bbfc3f --- /dev/null +++ b/.github/workflows/action.yml @@ -0,0 +1,43 @@ +name: Add PRs to Combodo PRs Dashboard + +on: + pull_request_target: + types: + - opened + +jobs: + add-to-project: + name: Add PR to Combodo Project + runs-on: ubuntu-latest + steps: + - name: Check if author is a member of the organization + id: check-membership + run: | + ORG="Combodo" + AUTHOR=$(jq -r .pull_request.user.login "$GITHUB_EVENT_PATH") + RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token ${{ secrets.PR_AUTOMATICALLY_ADD_TO_PROJECT }}" \ + "https://api.github.com/orgs/$ORG/members/$AUTHOR") + if [ "$RESPONSE" == "404" ]; then + echo "project_url=https://github.com/orgs/Combodo/projects/5" >> $GITHUB_ENV + echo "is_member=false" >> $GITHUB_ENV + else + echo "project_url=https://github.com/orgs/Combodo/projects/4" >> $GITHUB_ENV + echo "is_member=true" >> $GITHUB_ENV + + fi + + - name: Add internal tag if member + if: env.is_member == 'true' + run: | + curl -X POST -H "Authorization: token ${{ secrets.PR_AUTOMATICALLY_ADD_TO_PROJECT }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/Combodo/itop-data-collector-base/issues/${{ github.event.pull_request.number }}/labels \ + -d '{"labels":["internal"]}' + env: + is_member: ${{ env.is_member }} + + - name: Add PR to the appropriate project + uses: actions/add-to-project@v1.0.2 + with: + project-url: ${{ env.project_url }} + github-token: ${{ secrets.PR_AUTOMATICALLY_ADD_TO_PROJECT }} From fb21d01e7a94bea9ed5ce2f499fc701aeab87dad Mon Sep 17 00:00:00 2001 From: xtophe38 <13520055+xtophe38@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:56:27 +0100 Subject: [PATCH 07/13] =?UTF-8?q?N=C2=B07783=20-=20Relative=20paths=20cann?= =?UTF-8?q?ot=20beused=20when=20the=20collector=20is=20not=20launched=20fr?= =?UTF-8?q?om=20its=20home=20directory=20(#55)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Make sure relative paths can be used when json collector is launched from outside its root directory * Add test for jsonfile parameter defined with relative path * Provider function must be static for PHP 8.2+ --- core/jsoncollector.class.inc.php | 6 ++- test/JsonCollectorTest.php | 5 ++- .../dataTest.json | 38 +++++++++++++++++++ .../expected_generated.csv | 4 ++ .../params.distrib.xml | 34 +++++++++++++++++ 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 test/single_json/json_file_with_relative_path/dataTest.json create mode 100644 test/single_json/json_file_with_relative_path/expected_generated.csv create mode 100644 test/single_json/json_file_with_relative_path/params.distrib.xml diff --git a/core/jsoncollector.class.inc.php b/core/jsoncollector.class.inc.php index c9c472a..2bae2af 100644 --- a/core/jsoncollector.class.inc.php +++ b/core/jsoncollector.class.inc.php @@ -150,7 +150,11 @@ public function Prepare() Utils::Log(LOG_DEBUG, 'Source sFileJson: '.$this->sFileJson); Utils::Log(LOG_INFO, 'Synchro URL (target): '.Utils::GetConfigurationValue('itop_url', array())); } else { - $this->sFileJson = file_get_contents($this->sFilePath); + $this->sFileJson = file_get_contents($this->sFilePath); + if ($this->sFileJson === false) { + $this->sFilePath = APPROOT.$this->sFilePath; + $this->sFileJson = file_get_contents($this->sFilePath); + } Utils::Log(LOG_DEBUG, 'Source sFileJson: '.$this->sFileJson); Utils::Log(LOG_INFO, 'Synchro URL (target): '.Utils::GetConfigurationValue('itop_url', array())); } diff --git a/test/JsonCollectorTest.php b/test/JsonCollectorTest.php index 266bf90..a2ba7d1 100644 --- a/test/JsonCollectorTest.php +++ b/test/JsonCollectorTest.php @@ -108,7 +108,7 @@ public function testOrgCollector($sAdditionalDir = '') $this->assertEquals($sExpected_content, file_get_contents(APPROOT."/data/ITopPersonJsonCollector-1.csv")); } - public function OrgCollectorProvider() + public static function OrgCollectorProvider() { return [ "default_value" => [ "default_value" ], @@ -119,6 +119,7 @@ public function OrgCollectorProvider() "sort of object xpath parsing via an index" => [ "format_json_5" ], "first row nullified function" => [ "nullified_json_1" ], "another row nullified function" => [ "nullified_json_2" ], + "json file with relative path" => [ "json_file_with_relative_path" ], ]; } @@ -167,7 +168,7 @@ public function testJsonErrors($sAdditionalDir, $sErrorMsg, $sExceptionMsg = fal } } - public function ErrorFileProvider() + public static function ErrorFileProvider() { return [ "error_json_1" => [ diff --git a/test/single_json/json_file_with_relative_path/dataTest.json b/test/single_json/json_file_with_relative_path/dataTest.json new file mode 100644 index 0000000..07f1a38 --- /dev/null +++ b/test/single_json/json_file_with_relative_path/dataTest.json @@ -0,0 +1,38 @@ +{ + "objects": { + "Person::1": { + "key": "1", + "name": {"bob": "My last name"}, + "status": "active", + "org_id": "Blala", + "email": "my.email@foo.org", + "phone": "+00 000 000 000", + "notify": "yes", + "function": "", + "first_nameyo": "My first name" + }, + "Person::2": { + "key": "2", + "name": {"bob": "Picasso"}, + "status": "active", + "org_id": "Demo", + "email": "pablo@demo.com", + "phone": "", + "notify": "yes", + "function": "", + "first_nameyo": "Pablo" + }, + "Person::3": { + "key": "3", + "name": {"bob": "Dali"}, + "status": "active", + "email": "dali@demo.com", + "phone": "", + "notify": "yes", + "function": "", + "first_nameyo": "Salvador" + } + }, + "code": 0, + "message": "Found: 1" +} \ No newline at end of file diff --git a/test/single_json/json_file_with_relative_path/expected_generated.csv b/test/single_json/json_file_with_relative_path/expected_generated.csv new file mode 100644 index 0000000..fdf85aa --- /dev/null +++ b/test/single_json/json_file_with_relative_path/expected_generated.csv @@ -0,0 +1,4 @@ +primary_key;name;status;first_name;email;phone;function;org_id +1;"My last name";active;"My first name";my.email@foo.org;"+00 000 000 000";;Blala +2;Picasso;active;Pablo;pablo@demo.com;123456789;;Demo +3;Dali;active;Salvador;dali@demo.com;123456789;;Demo diff --git a/test/single_json/json_file_with_relative_path/params.distrib.xml b/test/single_json/json_file_with_relative_path/params.distrib.xml new file mode 100644 index 0000000..ccdc98c --- /dev/null +++ b/test/single_json/json_file_with_relative_path/params.distrib.xml @@ -0,0 +1,34 @@ + + + + + collectors/dataTest.json + objects/* + + key + name/bob + status + first_nameyo + email + phone + mobile + function + employeenumber + org_id + + + Demo + active + 123456789 + + + + + $prefix$ + synchro_data_person_1 + + From c7b6b5970ed985a8d0979c14ed7f1bcda6c8fbdf Mon Sep 17 00:00:00 2001 From: xtophe38 <13520055+xtophe38@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:05:48 +0100 Subject: [PATCH 08/13] Update jsoncollector.class.inc.php Suppress the PHP warning generated by file_get_contents when requested file is not found. The error is handled by the code. --- core/jsoncollector.class.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/jsoncollector.class.inc.php b/core/jsoncollector.class.inc.php index 2bae2af..c7fabf2 100644 --- a/core/jsoncollector.class.inc.php +++ b/core/jsoncollector.class.inc.php @@ -150,10 +150,10 @@ public function Prepare() Utils::Log(LOG_DEBUG, 'Source sFileJson: '.$this->sFileJson); Utils::Log(LOG_INFO, 'Synchro URL (target): '.Utils::GetConfigurationValue('itop_url', array())); } else { - $this->sFileJson = file_get_contents($this->sFilePath); + $this->sFileJson = @file_get_contents($this->sFilePath); if ($this->sFileJson === false) { $this->sFilePath = APPROOT.$this->sFilePath; - $this->sFileJson = file_get_contents($this->sFilePath); + $this->sFileJson = @file_get_contents($this->sFilePath); } Utils::Log(LOG_DEBUG, 'Source sFileJson: '.$this->sFileJson); Utils::Log(LOG_INFO, 'Synchro URL (target): '.Utils::GetConfigurationValue('itop_url', array())); From bdc1a4c967f2ab49420cab3f71542040cda44352 Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Thu, 13 Jun 2024 16:15:06 +0200 Subject: [PATCH 09/13] =?UTF-8?q?Fix=20N=C2=B07338=20to=20actually=20use?= =?UTF-8?q?=20"itop=5Flogin"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/orchestrator.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/orchestrator.class.inc.php b/core/orchestrator.class.inc.php index b1b1ff4..7a82860 100644 --- a/core/orchestrator.class.inc.php +++ b/core/orchestrator.class.inc.php @@ -175,7 +175,7 @@ public function InitSynchroDataSources($aCollectors) Utils::Log(LOG_ERR, "Unable to find the contact with email = '$sEmailToNotify'. No contact to notify will be defined."); } } - $sSynchroUser = Utils::GetConfigurationValue('synchro_user', Utils::GetConfigurationValue('itop_login', '')); + $sSynchroUser = Utils::GetConfigurationValue('synchro_user') ?: Utils::GetConfigurationValue('itop_login'); $aPlaceholders['$synchro_user$'] = 0; if ($sSynchroUser != '') { $oRestClient = new RestClient(); From d3427bcf9eb3e439076ee648d938513b82d563ed Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Thu, 6 Mar 2025 16:53:18 +0100 Subject: [PATCH 10/13] Fix default date_format (#54) * Log the trimmed output in debug mode when there are no errors * Revert previous default behaviour * Also fix the hardcoded default value --- conf/params.distrib.xml | 2 +- core/collector.class.inc.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/conf/params.distrib.xml b/conf/params.distrib.xml index c11fad3..0992f35 100644 --- a/conf/params.distrib.xml +++ b/conf/params.distrib.xml @@ -107,5 +107,5 @@ - Y-m-d + Y-m-d H:i:s diff --git a/core/collector.class.inc.php b/core/collector.class.inc.php index 8d4acab..9d692fb 100644 --- a/core/collector.class.inc.php +++ b/core/collector.class.inc.php @@ -692,7 +692,7 @@ public function Synchronize($iMaxChunkSize = 0) 'output' => $sOutput, 'csvdata' => file_get_contents($sDataFile), 'charset' => $this->GetCharset(), - 'date_format' => Utils::GetConfigurationValue('date_format', 'Y-m-d') + 'date_format' => Utils::GetConfigurationValue('date_format', 'Y-m-d H:i:s') ); $sLoginform = Utils::GetLoginMode(); @@ -708,6 +708,8 @@ public function Synchronize($iMaxChunkSize = 0) Utils::Log(LOG_ERR, $sTrimmedOutput); return false; + } else { + Utils::Log(LOG_DEBUG, $sTrimmedOutput); } } From 1fb29bc7bd350529eeef17e9472b1ef07dc37c59 Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 23 Apr 2025 09:58:00 +0200 Subject: [PATCH 11/13] =?UTF-8?q?N=C2=B05139=20-=20molkobain=20suggestion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/collector.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/collector.class.inc.php b/core/collector.class.inc.php index 9d692fb..189ae58 100644 --- a/core/collector.class.inc.php +++ b/core/collector.class.inc.php @@ -594,7 +594,7 @@ protected function AddRow($aRow) { $aData = array(); foreach ($this->aCSVHeaders as $sHeader) { - if (strlen($aRow[$sHeader])==0 && $this->AttributeIsNullified($sHeader)) { + if (strlen($aRow[$sHeader] ?? '')===0 && $this->AttributeIsNullified($sHeader)) { $aData[] = NULL_VALUE; } else { $aData[] = $aRow[$sHeader]; From 0f856a69202c6445b192931a9b1d241c25cfeb4d Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 23 Apr 2025 09:58:14 +0200 Subject: [PATCH 12/13] =?UTF-8?q?N=C2=B05139=20-=20test=20small=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iTopPersonCollector.class.inc.php | 92 +++++++++---------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php b/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php index 481ed39..b12eb91 100644 --- a/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php +++ b/test/collector/attribute_isnullified/iTopPersonCollector.class.inc.php @@ -5,55 +5,53 @@ class iTopPersonCollector extends Collector private $i; private $aCurrentData; + public function __construct() { + parent::__construct(); + + $this->i = 0; + $this->aCurrentData = [ + [ + 'primary_key' => 1, + 'first_name' => "isaac", + 'name' => "asimov_null", + 'org_id' => "Demo", + 'phone' => null, + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], + [ + 'primary_key' => 2, + 'first_name' => "isaac", + 'name' => "asimov_empty", + 'org_id' => "Demo", + 'phone' => "", + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], + [ + 'primary_key' => 3, + 'first_name' => "isaac", + 'name' => "asimov_notempty", + 'org_id' => "Demo", + 'phone' => "not empty", + 'mobile_phone' => "123456", + 'employee_number' => "9998877665544", + 'email' => "issac.asimov@function.io", + 'function' => "writer", + 'Status' => "Active", + ], + ]; + } protected function Fetch() { - if (is_null($this->aCurrentData)){ - $this->i = 0; - $this->aCurrentData = [ - [ - 'primary_key' => 1, - 'first_name' => "isaac", - 'name' => "asimov_null", - 'org_id' => "Demo", - 'phone' => null, - 'mobile_phone' => "123456", - 'employee_number' => "9998877665544", - 'email' => "issac.asimov@function.io", - 'function' => "writer", - 'Status' => "Active", - ], - [ - 'primary_key' => 2, - 'first_name' => "isaac", - 'name' => "asimov_empty", - 'org_id' => "Demo", - 'phone' => "", - 'mobile_phone' => "123456", - 'employee_number' => "9998877665544", - 'email' => "issac.asimov@function.io", - 'function' => "writer", - 'Status' => "Active", - ], - [ - 'primary_key' => 3, - 'first_name' => "isaac", - 'name' => "asimov_notempty", - 'org_id' => "Demo", - 'phone' => "not empty", - 'mobile_phone' => "123456", - 'employee_number' => "9998877665544", - 'email' => "issac.asimov@function.io", - 'function' => "writer", - 'Status' => "Active", - ], - ]; - } - - $res = null; - if ($this->i < count($this->aCurrentData)){ - $res=$this->aCurrentData[$this->i]; - $this->i++; - } + $res = $this->aCurrentData[$this->i] ?? null; + $this->i++; return $res; } From b03b0c35a6d14bc30556f415e721b9a97612af31 Mon Sep 17 00:00:00 2001 From: odain Date: Wed, 23 Apr 2025 12:07:32 +0200 Subject: [PATCH 13/13] fix phpunit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3b4afbe..e347ec1 100644 --- a/composer.json +++ b/composer.json @@ -4,6 +4,6 @@ "ext-libxml": "*" }, "require-dev": { - "phpunit/phpunit": "^6" + "phpunit/phpunit": "^9" } }