fix typo in second test and update to match first url workaround
authorDemeritCowboy <demeritcowboy@hotmail.com>
Wed, 4 Sep 2019 22:25:45 +0000 (18:25 -0400)
committerDemeritCowboy <demeritcowboy@hotmail.com>
Thu, 5 Sep 2019 00:01:33 +0000 (20:01 -0400)
tests/phpunit/api/v3/AttachmentTest.php

index 33bc8ec269194c4f61d10f9beb986f533986fc34..4d9833829ccc280882f67fe0578a790564612d8b 100644 (file)
@@ -349,8 +349,16 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
       'return' => ['content'],
     ]);
     $this->assertEquals($expectedContent, $getResult2['values'][$fileId]['content']);
+    // Do this again even though we just tested above to demonstrate that these fields should be returned even if you only ask to return 'content'.
     foreach (['id', 'entity_table', 'entity_id', 'url'] as $field) {
-      $this->assertEquals($createResult['values'][$fileId][$field], $getResult['values'][$fileId][$field], "Expect field $field to match");
+      if ($field == 'url') {
+        $this->assertEquals(substr($createResult['values'][$fileId][$field], 0, -15), substr($getResult2['values'][$fileId][$field], 0, -15));
+        $this->assertEquals(substr($createResult['values'][$fileId][$field], -3), substr($getResult2['values'][$fileId][$field], -3));
+        $this->assertApproxEquals(substr($createResult['values'][$fileId][$field], -14, 10), substr($getResult2['values'][$fileId][$field], -14, 10), 2);
+      }
+      else {
+        $this->assertEquals($createResult['values'][$fileId][$field], $getResult2['values'][$fileId][$field], "Expect field $field to match");
+      }
     }
   }