diff --git a/.circleci/config.yml b/.circleci/config.yml
new file mode 100644
index 0000000..a3eb79f
--- /dev/null
+++ b/.circleci/config.yml
@@ -0,0 +1,33 @@
+version: 2.1
+
+jobs:
+ test: # Also lints first
+ docker:
+ - image: circleci/php:8.0
+ auth:
+ username: $DOCKER_HUB_USERNAME
+ password: $DOCKER_HUB_ACCESS_TOKEN
+
+ steps:
+ - checkout
+
+ - restore_cache:
+ keys:
+ - composer-v1-{{ checksum "composer.lock" }}
+
+ - run: composer install --no-interaction
+
+ - save_cache:
+ paths:
+ - vendor
+ key: composer-v1-{{ checksum "composer.lock" }}
+
+ - run: composer run lint:check
+ - run: composer run test
+
+workflows:
+ build:
+ jobs:
+ - test:
+ context:
+ - docker-hub-creds
diff --git a/composer.json b/composer.json
index 4486f84..938f631 100644
--- a/composer.json
+++ b/composer.json
@@ -42,12 +42,12 @@
"ext-simplexml": "*",
"ext-xmlwriter": "*",
"ext-zlib": "*",
- "thebiggive/php-govtalk": "^1.0.0"
+ "thebiggive/php-govtalk": "^1.0.1"
},
"require-dev": {
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5.7",
- "roave/security-advisories": "dev-master",
+ "roave/security-advisories": "dev-latest",
"squizlabs/php_codesniffer": "^3.6.0"
},
"scripts": {
diff --git a/src/GiftAid.php b/src/GiftAid.php
index 08c69e6..fc80b03 100644
--- a/src/GiftAid.php
+++ b/src/GiftAid.php
@@ -858,8 +858,8 @@ public function requestClaimData()
}
/**
- * Polls the Gateway for a submission response / error following a VAT
- * declaration request. By default the correlation ID from the last response
+ * Polls the Gateway for a submission response / error following a request.
+ * By default the correlation ID from the last response
* is used for the polling, but this can be over-ridden by supplying a
* correlation ID. The correlation ID can be skipped by passing a null value.
*
@@ -925,10 +925,14 @@ public function declarationResponsePoll($correlationId = null, $pollUrl = null)
}
} else {
if ($this->responseHasErrors()) {
- return [
+ $returnable = [
'errors' => $this->getResponseErrors(),
'fullResponseString' => $this->fullResponseString
];
+ $returnable['donation_ids_with_errors'] = $this->getDistinctErroringDonations(
+ $returnable['errors']['business']
+ );
+ return $returnable;
}
return false;
@@ -1157,8 +1161,10 @@ public function getResponseErrors()
$pattern = '!^/hd:GovTalkMessage\[1]/hd:Body\[1]/r68:IRenvelope\[1]/r68:R68\[1]/' .
'r68:Claim\[(\d+)]/r68:Repayment\[1]/r68:GAD\[(\d+)].+$!';
if (isset($gaError->Location) && preg_match($pattern, $gaError->Location, $matches) === 1) {
- if (isset($this->donationIdMap[$matches[1]][$matches[2]])) {
- $donationId = $this->donationIdMap[$matches[1]][$matches[2]];
+ $claimIndex = (int) $matches[1];
+ $gadIndex = (int) $matches[2];
+ if (isset($this->donationIdMap[$claimIndex][$gadIndex])) {
+ $donationId = $this->donationIdMap[$claimIndex][$gadIndex];
}
}
diff --git a/tests/GovTalk/GiftAid/GiftAidTest.php b/tests/GovTalk/GiftAid/GiftAidTest.php
index 0e9edb3..335c30d 100644
--- a/tests/GovTalk/GiftAid/GiftAidTest.php
+++ b/tests/GovTalk/GiftAid/GiftAidTest.php
@@ -556,8 +556,10 @@ public function testMultiClaimSubmissionWithMultipleDonationErrors(): void
// `...r68:Claim[2]...`. So the UUID for error index 1 matches our 2nd (index 1)
// donation while that for error index 5 matches our index 0 donation.
+ // We expect both donations to be in the same claim because they share an HMRC org ref.
+
$this->assertEquals('some-uuid-1234', $response['errors']['business'][1]['donation_id']);
- $this->assertEquals('/hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[2]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1]', $response['errors']['business'][1]['location']);
+ $this->assertEquals('/hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[2]/r68:Donor[1]/r68:Sur[1]', $response['errors']['business'][1]['location']);
$this->assertEquals('/hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1]', $response['errors']['business'][5]['location']);
$this->assertEquals('some-uuid-5678', $response['errors']['business'][5]['donation_id']);
@@ -565,7 +567,7 @@ public function testMultiClaimSubmissionWithMultipleDonationErrors(): void
$this->assertEquals(['some-uuid-1234', 'some-uuid-5678'], $response['donation_ids_with_errors']);
}
- public function testDeclarationResponsePoll()
+ public function testDeclarationResponsePoll(): void
{
$this->setMockHttpResponse('DeclarationResponsePoll.xml');
$this->gaService = $this->setUpService(); // Use client w/ mock queue.
diff --git a/tests/GovTalk/GiftAid/Mock/SubmitMultiMultipleErrorsResponse.xml b/tests/GovTalk/GiftAid/Mock/SubmitMultiMultipleErrorsResponse.xml
index 69cc223..136a549 100644
--- a/tests/GovTalk/GiftAid/Mock/SubmitMultiMultipleErrorsResponse.xml
+++ b/tests/GovTalk/GiftAid/Mock/SubmitMultiMultipleErrorsResponse.xml
@@ -1 +1 @@
- 2.0 HMRC-CHAR-CLM-MULTI error submit 6359058085579170979 http://localhost:5665/LTS/LTSServlet XML 2021-10-12T18:09:03.009 ChRIS 3001 business Your submission failed due to business validation errors. Please see below for details. 8 ChRIS 4065 schema Invalid content found at element 'Sur' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[2]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-type.3.1.3: The value '' of element 'Sur' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[2]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_SurDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Fore' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[2]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-type.3.1.3: The value '' of element 'Fore' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[2]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_ForeDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Sur' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-type.3.1.3: The value '' of element 'Sur' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_SurDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Fore' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-type.3.1.3: The value '' of element 'Fore' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_ForeDonorGADRepaymentClaimR68'.
+ 2.0 HMRC-CHAR-CLM-MULTI error submit 6359058085579170979 http://localhost:5665/LTS/LTSServlet XML 2021-10-12T18:09:03.009 ChRIS 3001 business Your submission failed due to business validation errors. Please see below for details. 8 ChRIS 4065 schema Invalid content found at element 'Sur' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[2]/r68:Donor[1]/r68:Sur[1] cvc-type.3.1.3: The value '' of element 'Sur' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[2]/r68:Donor[1]/r68:Sur[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_SurDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Fore' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[2]/r68:Donor[1]/r68:Fore[1] cvc-type.3.1.3: The value '' of element 'Fore' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[2]/r68:Donor[1]/r68:Fore[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_ForeDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Sur' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-type.3.1.3: The value '' of element 'Sur' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Sur[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_SurDonorGADRepaymentClaimR68'. ChRIS 4065 schema Invalid content found at element 'Fore' /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-type.3.1.3: The value '' of element 'Fore' is not valid. ChRIS 4082 schema Value '' has an incorrect length /hd:GovTalkMessage[1]/hd:Body[1]/r68:IRenvelope[1]/r68:R68[1]/r68:Claim[1]/r68:Repayment[1]/r68:GAD[1]/r68:Donor[1]/r68:Fore[1] cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_ForeDonorGADRepaymentClaimR68'.