7
7
use GuzzleHttp \Psr7 ;
8
8
use Psr \Http \Client \ClientInterface ;
9
9
use Psr \Http \Message \ResponseInterface ;
10
+ use Yoti \Exception \ActivityDetailsException ;
10
11
use Yoti \Profile \ActivityDetails ;
11
12
use Yoti \Profile \Service ;
12
13
use Yoti \Test \TestCase ;
@@ -160,8 +161,10 @@ public function testWrongPemFile()
160
161
*/
161
162
public function testSharingOutcomeFailure ()
162
163
{
164
+ $ mes1 = "Sharing activity unsuccessful for 9HNJDX5bEIN5TqBm0OGzVIc1LaAmbzfx6eIrwNdwpHvKeQmgPujyogC+r7hJCVPl " ;
165
+ $ mes2 = "UNKNOWN FRAUD_DETECTED " ;
163
166
$ this ->expectException (\Yoti \Exception \ActivityDetailsException::class);
164
- $ this ->expectExceptionMessage (' Outcome was unsuccessful ' );
167
+ $ this ->expectExceptionMessage ($ mes1 . $ mes2 );
165
168
166
169
$ json = json_decode (file_get_contents (TestData::RECEIPT_JSON ), true );
167
170
$ json ['receipt ' ]['sharing_outcome ' ] = 'FAILURE ' ;
@@ -170,6 +173,27 @@ public function testSharingOutcomeFailure()
170
173
$ profileService ->getActivityDetails (file_get_contents (TestData::YOTI_CONNECT_TOKEN ));
171
174
}
172
175
176
+ /**
177
+ * @covers \Yoti\Exception\ActivityDetailsException::getReceiptErrorDetails
178
+ * @covers \Yoti\Exception\ActivityDetailsException::__construct
179
+ */
180
+ public function testReceiptErrorDetailsException ()
181
+ {
182
+ $ json = json_decode (file_get_contents (TestData::RECEIPT_JSON ), true );
183
+ $ json ['receipt ' ]['sharing_outcome ' ] = 'FAILURE ' ;
184
+
185
+ $ profileService = $ this ->createProfileServiceWithResponse (200 , json_encode ($ json ));
186
+ try {
187
+ $ profileService ->getActivityDetails (file_get_contents (TestData::YOTI_CONNECT_TOKEN ));
188
+ } catch (ActivityDetailsException $ e ) {
189
+ $ this ->assertEquals ([
190
+ 'receipt_id ' => '9HNJDX5bEIN5TqBm0OGzVIc1LaAmbzfx6eIrwNdwpHvKeQmgPujyogC+r7hJCVPl ' ,
191
+ 'description ' => 'UNKNOWN ' ,
192
+ 'error_code ' => 'FRAUD_DETECTED ' ,
193
+ ], json_decode ($ e ->getReceiptErrorDetails (), true ));
194
+ }
195
+ }
196
+
173
197
/**
174
198
* @covers ::getActivityDetails
175
199
* @covers ::checkForReceipt
0 commit comments