|
4 | 4 |
|
5 | 5 | namespace Yoti\Test\DocScan\Session\Retrieve;
|
6 | 6 |
|
| 7 | +use Yoti\DocScan\Constants; |
| 8 | +use Yoti\DocScan\Session\Retrieve\Contracts\CaMatchingStrategyResponse; |
| 9 | +use Yoti\DocScan\Session\Retrieve\Contracts\CaSourcesResponse; |
| 10 | +use Yoti\DocScan\Session\Retrieve\Contracts\WatchlistSearchConfigResponse; |
| 11 | +use Yoti\DocScan\Session\Retrieve\MediaResponse; |
| 12 | +use Yoti\DocScan\Session\Retrieve\RawResultsResponse; |
7 | 13 | use Yoti\DocScan\Session\Retrieve\ReportResponse;
|
8 | 14 | use Yoti\Test\TestCase;
|
9 | 15 |
|
|
12 | 18 | */
|
13 | 19 | class ReportResponseTest extends TestCase
|
14 | 20 | {
|
| 21 | + private const TOTAL_HITS = 7; |
| 22 | + private const SOME_COUNTRY_CODE = ['GBR', 'USA']; |
| 23 | + private const SOME_TYPES = [ "someString", "someOtherString" ]; |
| 24 | + private const SOME_API_KEY = 'SOME_API_KEY'; |
| 25 | + private const SOME_CLIENT_REF = 'SOME_CLIENT_REF'; |
| 26 | + private const SOME_SEARCH_PROFILE = 'SOME_SEARCH_PROFILE'; |
| 27 | + private const SOME_FUZZINESS = 0.7; |
| 28 | + private const SOME_CATEGORIES = [ "someString", "someOtherString" ]; |
| 29 | + |
15 | 30 | /**
|
16 | 31 | * @test
|
17 | 32 | * @covers ::__construct
|
@@ -45,4 +60,210 @@ public function shouldNotThrowExceptionWhenMissingValues()
|
45 | 60 | $this->assertNull($result->getRecommendation());
|
46 | 61 | $this->assertCount(0, $result->getBreakdown());
|
47 | 62 | }
|
| 63 | + |
| 64 | + /** |
| 65 | + * @test |
| 66 | + * @covers ::__construct |
| 67 | + * @covers ::getWatchlistSummary |
| 68 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistSummaryResponse::__construct |
| 69 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistSummaryResponse::setSearchConfig |
| 70 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistSummaryResponse::getTotalHits |
| 71 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistSummaryResponse::getRawResults |
| 72 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistSummaryResponse::getSearchConfig |
| 73 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::__construct |
| 74 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::getSources |
| 75 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::getMatchingStrategy |
| 76 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::getType |
| 77 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::isShareUrl |
| 78 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::isRemoveDeceased |
| 79 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::setMatchingStrategy |
| 80 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistAdvancedCaSearchConfigResponse::setSources |
| 81 | + * @covers \Yoti\DocScan\Session\Retrieve\RawResultsResponse::__construct |
| 82 | + * @covers \Yoti\DocScan\Session\Retrieve\RawResultsResponse::getMedia |
| 83 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\TypeListSourcesResponse::__construct |
| 84 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\TypeListSourcesResponse::getTypes |
| 85 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\TypeListSourcesResponse::getType |
| 86 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\SearchProfileSourcesResponse::__construct |
| 87 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\SearchProfileSourcesResponse::getSearchProfile |
| 88 | + * @covers \Yoti\DocScan\Session\Retrieve\Sources\SearchProfileSourcesResponse::getType |
| 89 | + * @covers \Yoti\DocScan\Session\Retrieve\Contracts\CaSourcesResponse::getType |
| 90 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\FuzzyMatchingStrategyResponse::__construct |
| 91 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\FuzzyMatchingStrategyResponse::getFuzziness |
| 92 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\FuzzyMatchingStrategyResponse::getType |
| 93 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\ExactMatchingStrategyResponse::__construct |
| 94 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\ExactMatchingStrategyResponse::isExactMatch |
| 95 | + * @covers \Yoti\DocScan\Session\Retrieve\Matching\ExactMatchingStrategyResponse::getType |
| 96 | + * @covers \Yoti\DocScan\Session\Retrieve\Contracts\CaSourcesResponse::getType |
| 97 | + * @covers \Yoti\DocScan\Session\Retrieve\Contracts\CaMatchingStrategyResponse::getType |
| 98 | + * @covers \Yoti\DocScan\Session\Retrieve\CustomAccountWatchlistCaSearchConfigResponse::__construct |
| 99 | + * @covers \Yoti\DocScan\Session\Retrieve\CustomAccountWatchlistCaSearchConfigResponse::getApiKey |
| 100 | + * @covers \Yoti\DocScan\Session\Retrieve\CustomAccountWatchlistCaSearchConfigResponse::getMonitoring |
| 101 | + * @covers \Yoti\DocScan\Session\Retrieve\CustomAccountWatchlistCaSearchConfigResponse::getTags |
| 102 | + * @covers \Yoti\DocScan\Session\Retrieve\CustomAccountWatchlistCaSearchConfigResponse::getClientRef |
| 103 | + */ |
| 104 | + public function shouldBuildWithWatchlistSummaryResponse() |
| 105 | + { |
| 106 | + $tags = [ |
| 107 | + 'some' => 'exact' |
| 108 | + ]; |
| 109 | + $someTags = json_encode($tags); |
| 110 | + |
| 111 | + $input = [ |
| 112 | + 'watchlist_summary' => [ |
| 113 | + 'total_hits' => self::TOTAL_HITS, |
| 114 | + 'raw_results' => [ |
| 115 | + 'media' => [ |
| 116 | + 'id' => 'SOME_ID', |
| 117 | + 'type' => 'SOME_TYPE', |
| 118 | + 'created' => "2021-02-16T17:02:53.519Z", |
| 119 | + 'last_updated' => "2021-02-16T17:02:53.519Z" |
| 120 | + ] |
| 121 | + ], |
| 122 | + 'associated_country_codes' => self::SOME_COUNTRY_CODE, |
| 123 | + 'search_config' => [ |
| 124 | + 'type' => Constants::WITH_YOTI_ACCOUNT, |
| 125 | + 'remove_deceased' => true, |
| 126 | + 'share_url' => true, |
| 127 | + 'sources' => [ |
| 128 | + 'type' => Constants::TYPE_LIST, |
| 129 | + 'types' => self::SOME_TYPES |
| 130 | + ], |
| 131 | + 'matching_strategy' => [ |
| 132 | + 'type' => Constants::EXACT, |
| 133 | + 'exact_match' => true |
| 134 | + ] |
| 135 | + ] |
| 136 | + ] |
| 137 | + ]; |
| 138 | + |
| 139 | + $result = new ReportResponse($input); |
| 140 | + |
| 141 | + $this->assertNotNull($result->getWatchlistSummary()); |
| 142 | + $this->assertEquals(self::TOTAL_HITS, $result->getWatchlistSummary()->getTotalHits()); |
| 143 | + $this->assertEquals( |
| 144 | + self::SOME_COUNTRY_CODE, |
| 145 | + $result->getWatchlistSummary()->getAssociatedCountryCodes() |
| 146 | + ); |
| 147 | + |
| 148 | + $this->assertInstanceOf(RawResultsResponse::class, $result->getWatchlistSummary()->getRawResults()); |
| 149 | + $this->assertInstanceOf( |
| 150 | + WatchlistSearchConfigResponse::class, |
| 151 | + $result->getWatchlistSummary()->getSearchConfig() |
| 152 | + ); |
| 153 | + |
| 154 | + $this->assertTrue($result->getWatchlistSummary()->getSearchConfig()->isRemoveDeceased()); |
| 155 | + $this->assertTrue($result->getWatchlistSummary()->getSearchConfig()->isShareUrl()); |
| 156 | + $this->assertInstanceOf( |
| 157 | + CaMatchingStrategyResponse::class, |
| 158 | + $result->getWatchlistSummary()->getSearchConfig()->getMatchingStrategy() |
| 159 | + ); |
| 160 | + $this->assertInstanceOf( |
| 161 | + CaSourcesResponse::class, |
| 162 | + $result->getWatchlistSummary()->getSearchConfig()->getSources() |
| 163 | + ); |
| 164 | + $this->assertEquals( |
| 165 | + Constants::WITH_YOTI_ACCOUNT, |
| 166 | + $result->getWatchlistSummary()->getSearchConfig()->getType() |
| 167 | + ); |
| 168 | + |
| 169 | + $this->assertEquals( |
| 170 | + self::SOME_TYPES, |
| 171 | + $result->getWatchlistSummary()->getSearchConfig()->getSources()->getTypes() |
| 172 | + ); |
| 173 | + |
| 174 | + $this->assertTrue( |
| 175 | + $result->getWatchlistSummary()->getSearchConfig()->getMatchingStrategy()->isExactMatch() |
| 176 | + ); |
| 177 | + |
| 178 | + $input2 = [ |
| 179 | + 'watchlist_summary' => [ |
| 180 | + 'total_hits' => self::TOTAL_HITS, |
| 181 | + 'raw_results' => [ |
| 182 | + 'media' => [ |
| 183 | + 'id' => 'SOME_ID', |
| 184 | + 'type' => 'SOME_TYPE', |
| 185 | + 'created' => "2021-02-16T17:02:53.519Z", |
| 186 | + 'last_updated' => "2021-02-16T17:02:53.519Z" |
| 187 | + ] |
| 188 | + ], |
| 189 | + 'associated_country_codes' => self::SOME_COUNTRY_CODE, |
| 190 | + 'search_config' => [ |
| 191 | + 'type' => Constants::WITH_CUSTOM_ACCOUNT, |
| 192 | + 'remove_deceased' => true, |
| 193 | + 'share_url' => true, |
| 194 | + 'api_key' => self::SOME_API_KEY, |
| 195 | + 'monitoring' => false, |
| 196 | + 'client_ref' => self::SOME_CLIENT_REF, |
| 197 | + 'tags' => $someTags, |
| 198 | + 'sources' => [ |
| 199 | + 'type' => Constants::PROFILE, |
| 200 | + 'search_profile' => self::SOME_SEARCH_PROFILE |
| 201 | + ], |
| 202 | + 'matching_strategy' => [ |
| 203 | + 'type' => Constants::FUZZY, |
| 204 | + 'fuzziness' => self::SOME_FUZZINESS |
| 205 | + ] |
| 206 | + ] |
| 207 | + ] |
| 208 | + ]; |
| 209 | + |
| 210 | + $result2 = new ReportResponse($input2); |
| 211 | + |
| 212 | + $this->assertEquals( |
| 213 | + self::SOME_SEARCH_PROFILE, |
| 214 | + $result2->getWatchlistSummary()->getSearchConfig()->getSources()->getSearchProfile() |
| 215 | + ); |
| 216 | + |
| 217 | + $this->assertInstanceOf( |
| 218 | + MediaResponse::class, |
| 219 | + $result2->getWatchlistSummary()->getRawResults()->getMedia() |
| 220 | + ); |
| 221 | + |
| 222 | + $this->assertEquals( |
| 223 | + self::SOME_FUZZINESS, |
| 224 | + $result2->getWatchlistSummary()->getSearchConfig()->getMatchingStrategy()->getFuzziness() |
| 225 | + ); |
| 226 | + |
| 227 | + $this->assertEquals( |
| 228 | + self::SOME_API_KEY, |
| 229 | + $result2->getWatchlistSummary()->getSearchConfig()->getApiKey() |
| 230 | + ); |
| 231 | + |
| 232 | + $this->assertFalse( |
| 233 | + $result2->getWatchlistSummary()->getSearchConfig()->getMonitoring() |
| 234 | + ); |
| 235 | + |
| 236 | + $this->assertEquals( |
| 237 | + $tags, |
| 238 | + $result2->getWatchlistSummary()->getSearchConfig()->getTags() |
| 239 | + ); |
| 240 | + |
| 241 | + $this->assertEquals( |
| 242 | + self::SOME_CLIENT_REF, |
| 243 | + $result2->getWatchlistSummary()->getSearchConfig()->getCLientRef() |
| 244 | + ); |
| 245 | + } |
| 246 | + |
| 247 | + /** |
| 248 | + * @test |
| 249 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistScreeningSearchConfigResponse::__construct |
| 250 | + * @covers \Yoti\DocScan\Session\Retrieve\WatchlistScreeningSearchConfigResponse::getCategories |
| 251 | + */ |
| 252 | + public function shouldBuildWithWatchlistScreening() |
| 253 | + { |
| 254 | + $input = [ |
| 255 | + 'watchlist_summary' => [ |
| 256 | + 'total_hits' => self::TOTAL_HITS, |
| 257 | + 'search_config' => [ |
| 258 | + 'categories' => self::SOME_CATEGORIES |
| 259 | + ] |
| 260 | + ] |
| 261 | + ]; |
| 262 | + $result = new ReportResponse($input); |
| 263 | + |
| 264 | + $this->assertEquals( |
| 265 | + self::SOME_CATEGORIES, |
| 266 | + $result->getWatchlistSummary()->getSearchConfig()->getCategories() |
| 267 | + ); |
| 268 | + } |
48 | 269 | }
|
0 commit comments