Merge branch '5.11' of https://github.com/civicrm/civicrm-core
[civicrm-core.git] / tests / phpunit / api / v3 / AttachmentTest.php
index bc2cf65703d22c58a9d9f8b6ec3b36369f2f7744..9e313db638d00bff689711fa9cdcb642add5c972 100644 (file)
@@ -506,6 +506,14 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
 
     $getResult = $this->callAPISuccess('Attachment', 'get', $getParams);
     $actualNames = array_values(CRM_Utils_Array::collect('name', $getResult['values']));
+    // Verify the hash generated by the API is valid if we were to try and load the file.
+    foreach ($getResult['values'] as $result) {
+      $queryResult = [];
+      $parsedURl = parse_url($result['url']);
+      $parsedQuery = parse_str($parsedURl['query'], $queryResult);
+      $this->assertTrue(CRM_Core_BAO_File::validateFileHash($queryResult['fcs'], $queryResult['eid'], $queryResult['id']));
+    }
+
     sort($actualNames);
     sort($expectedNames);
     $this->assertEquals($expectedNames, $actualNames);