From 329c0b40c44abcabc3f367267d59c91eea9918d2 Mon Sep 17 00:00:00 2001 From: Andrey Eremin Date: Mon, 31 Aug 2026 16:20:43 +0200 Subject: [PATCH 1/2] SIG-4322: Add tests to watchlists mesh risks endpoint --- test/Resource/WatchlistAlertRisksTest.php | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 test/Resource/WatchlistAlertRisksTest.php diff --git a/test/Resource/WatchlistAlertRisksTest.php b/test/Resource/WatchlistAlertRisksTest.php new file mode 100644 index 0000000..77ef794 --- /dev/null +++ b/test/Resource/WatchlistAlertRisksTest.php @@ -0,0 +1,79 @@ +createApplicant( + new ApplicantBuilder([ + 'first_name' => 'Donald', + 'last_name' => 'Consider', + 'dob' => new DateTime('1990-01-01'), + 'address' => new Address([ + 'country' => 'PRT', + 'town' => 'Town', + 'street' => 'Street', + 'building_number' => '12', + 'postcode' => '12345' + ]) + ]) + ); + $workflowRun = $this->createWorkflowRun( + new WorkflowRunBuilder([ + 'applicant_id' => $applicant->getId(), + 'workflow_id' => '18effbfe-73c3-4680-ae43-e1c474767ff4', + 'custom_data' => [ + 'national_id' => [ + 'type' => 'passport', + 'value' => 'P1234567' + ], + 'nationality' => 'PRT' + ] + ]) + ); + $tasks = self::$onfido->listTasks($workflowRun->getId()); + $task = null; + + foreach ($tasks as $workflowTask) { + if ($workflowTask->getTaskDefId() === 'query_watchlists_complyadvantage_mesh') { + $task = $workflowTask; + break; + } + } + + $this->assertNotNull($task); + + $findTaskFn = function($workflowRunId, $taskId) { + return self::$onfido->findTask($workflowRunId, $taskId); + }; + $watchlistTask = $this->repeatRequestUntilTaskOutputChanges( + $findTaskFn, + [$workflowRun->getId(), $task->getId()], + 30, + 2 + ); + $alertIdentifier = $watchlistTask->getOutput()->properties->alert_identifier; + + $this->assertNotNull($alertIdentifier); + + $risks = self::$onfido->listWatchlistMeshAlertRisks($alertIdentifier, 1, 1); + + $this->assertGreaterThan(0, count($risks)); + $this->assertLessThanOrEqual(1, count($risks)); + $this->assertInstanceOf(WatchlistMeshAlertRisk::class, $risks[0]); + $this->assertNotNull($risks[0]->getIdentifier()); + $this->assertNotNull($risks[0]->getDecision()); + $this->assertNotNull($risks[0]->getDetail()); + } +} + +?> From 8afc1ea238135153bba06d7122db84a1365e6f97 Mon Sep 17 00:00:00 2001 From: Andrey Eremin Date: Mon, 31 Aug 2026 17:44:26 +0200 Subject: [PATCH 2/2] Fix tests --- test/Resource/WatchlistAlertRisksTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Resource/WatchlistAlertRisksTest.php b/test/Resource/WatchlistAlertRisksTest.php index 77ef794..fdb6b7a 100644 --- a/test/Resource/WatchlistAlertRisksTest.php +++ b/test/Resource/WatchlistAlertRisksTest.php @@ -61,7 +61,7 @@ public function testListWatchlistMeshAlertRisks(): void 30, 2 ); - $alertIdentifier = $watchlistTask->getOutput()->properties->alert_identifier; + $alertIdentifier = $watchlistTask->getOutput()['properties']->alert_identifier; $this->assertNotNull($alertIdentifier);