2
2
3
3
namespace Yoti \Test \DocScan \Session \Create ;
4
4
5
+ use Yoti \DocScan \Constants ;
5
6
use Yoti \DocScan \Session \Create \SdkConfigBuilder ;
6
7
use Yoti \Test \TestCase ;
7
8
@@ -19,6 +20,8 @@ class SdkConfigBuilderTest extends TestCase
19
20
private const SOME_SUCCESS_URL = 'someSuccessUrl ' ;
20
21
private const SOME_ERROR_URL = 'someErrorUrl ' ;
21
22
private const SOME_PRIVACY_POLICY_URL = 'somePrivacyPolicyUrl ' ;
23
+ private const SOME_CATEGORY = 'someCategory ' ;
24
+ private const SOME_NUMBER_RETRIES = 5 ;
22
25
23
26
/**
24
27
* @test
@@ -162,4 +165,122 @@ public function allowHandoffShouldBeNullWhenItIsNotSet()
162
165
163
166
$ this ->assertNull ($ result ->getAllowHandoff ());
164
167
}
168
+
169
+ /**
170
+ * @test
171
+ * @covers ::build
172
+ * @covers ::withIdDocumentTextExtractionCategoryRetries
173
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::getAttemptsConfiguration
174
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
175
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::__construct
176
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::getIdDocumentTextDataExtraction
177
+ */
178
+ public function shouldBuildWithIdDocumentTextExtractionCategoryRetries (): void
179
+ {
180
+ $ data = [
181
+ self ::SOME_CATEGORY => self ::SOME_NUMBER_RETRIES
182
+ ];
183
+
184
+ $ sdkConfig = (new SdkConfigBuilder ())
185
+ ->withIdDocumentTextExtractionCategoryRetries (self ::SOME_CATEGORY , self ::SOME_NUMBER_RETRIES )
186
+ ->build ();
187
+
188
+ $ this ->assertEquals ($ data , $ sdkConfig ->getAttemptsConfiguration ()->getIdDocumentTextDataExtraction ());
189
+ }
190
+
191
+ /**
192
+ * @test
193
+ * @covers ::build
194
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::getAttemptsConfiguration
195
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
196
+ */
197
+ public function attemptsConfigurationShouldBeNullIfNotSet (): void
198
+ {
199
+ $ sdkConfig = (new SdkConfigBuilder ())
200
+ ->build ();
201
+
202
+ $ this ->assertNull ($ sdkConfig ->getAttemptsConfiguration ());
203
+ }
204
+
205
+ /**
206
+ * @test
207
+ * @covers ::build
208
+ * @covers ::withIdDocumentTextExtractionCategoryRetries
209
+ * @covers ::withIdDocumentTextExtractionReclassificationRetries
210
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::getAttemptsConfiguration
211
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
212
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::__construct
213
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::getIdDocumentTextDataExtraction
214
+ */
215
+ public function attemptsConfigurationShouldResetSameValueWithRepeatedCalls (): void
216
+ {
217
+ $ data = [
218
+ Constants::RECLASSIFICATION => 4
219
+ ];
220
+
221
+ $ sdkConfig = (new SdkConfigBuilder ())
222
+ ->withIdDocumentTextExtractionReclassificationRetries (2 )
223
+ ->withIdDocumentTextExtractionReclassificationRetries (3 )
224
+ ->withIdDocumentTextExtractionReclassificationRetries (4 )
225
+ ->build ();
226
+
227
+ $ this ->assertCount (1 , $ sdkConfig ->getAttemptsConfiguration ()->getIdDocumentTextDataExtraction ());
228
+ $ this ->assertEquals ($ data , $ sdkConfig ->getAttemptsConfiguration ()->getIdDocumentTextDataExtraction ());
229
+ }
230
+
231
+ /**
232
+ * @test
233
+ * @covers ::build
234
+ * @covers ::withIdDocumentTextExtractionCategoryRetries
235
+ * @covers ::withIdDocumentTextExtractionReclassificationRetries
236
+ * @covers ::withIdDocumentTextExtractionGenericRetries
237
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::getAttemptsConfiguration
238
+ * @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
239
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::__construct
240
+ * @covers \Yoti\DocScan\Session\Create\AttemptsConfiguration::getIdDocumentTextDataExtraction
241
+ */
242
+ public function attemptsConfigurationShouldAllowMultipleCategories (): void
243
+ {
244
+ $ numberOfGenericRetries = 3 ;
245
+ $ numberOfReclassificationRetries = 1 ;
246
+
247
+ $ sdkConfig = (new SdkConfigBuilder ())
248
+ ->withIdDocumentTextExtractionReclassificationRetries ($ numberOfReclassificationRetries )
249
+ ->withIdDocumentTextExtractionGenericRetries ($ numberOfGenericRetries )
250
+ ->withIdDocumentTextExtractionCategoryRetries (self ::SOME_CATEGORY , self ::SOME_NUMBER_RETRIES )
251
+ ->build ();
252
+
253
+ $ this ->assertCount (3 , $ sdkConfig ->getAttemptsConfiguration ()->getIdDocumentTextDataExtraction ());
254
+ $ this ->assertArrayHasKey (
255
+ Constants::RECLASSIFICATION ,
256
+ $ sdkConfig ->getAttemptsConfiguration ()
257
+ ->getIdDocumentTextDataExtraction ()
258
+ );
259
+ $ this ->assertArrayHasKey (
260
+ Constants::GENERIC ,
261
+ $ sdkConfig ->getAttemptsConfiguration ()
262
+ ->getIdDocumentTextDataExtraction ()
263
+ );
264
+ $ this ->assertArrayHasKey (
265
+ self ::SOME_CATEGORY ,
266
+ $ sdkConfig ->getAttemptsConfiguration ()
267
+ ->getIdDocumentTextDataExtraction ()
268
+ );
269
+
270
+ $ this ->assertContains (
271
+ $ numberOfGenericRetries ,
272
+ $ sdkConfig ->getAttemptsConfiguration ()
273
+ ->getIdDocumentTextDataExtraction ()
274
+ );
275
+ $ this ->assertContains (
276
+ $ numberOfReclassificationRetries ,
277
+ $ sdkConfig ->getAttemptsConfiguration ()
278
+ ->getIdDocumentTextDataExtraction ()
279
+ );
280
+ $ this ->assertContains (
281
+ self ::SOME_NUMBER_RETRIES ,
282
+ $ sdkConfig ->getAttemptsConfiguration ()
283
+ ->getIdDocumentTextDataExtraction ()
284
+ );
285
+ }
165
286
}
0 commit comments