(REF) RestTest - Split into a base-class and concrete-class
authorTim Otten <totten@civicrm.org>
Thu, 4 Mar 2021 09:37:44 +0000 (01:37 -0800)
committerTim Otten <totten@civicrm.org>
Mon, 24 Jan 2022 21:52:34 +0000 (13:52 -0800)
tests/phpunit/E2E/Extern/BaseRestTest.php [moved from tests/phpunit/E2E/Extern/RestTest.php with 98% similarity]
tests/phpunit/E2E/Extern/LegacyRestTest.php [new file with mode: 0644]

similarity index 98%
rename from tests/phpunit/E2E/Extern/RestTest.php
rename to tests/phpunit/E2E/Extern/BaseRestTest.php
index ed3aed7019bc43e969f97980483736212e38ad3e..626f89598e42f88440168be7f17ee8810514e347 100644 (file)
@@ -14,7 +14,7 @@
  *
  * @group e2e
  */
-class E2E_Extern_RestTest extends CiviEndToEndTestCase {
+abstract class E2E_Extern_BaseRestTest extends CiviEndToEndTestCase {
   protected $url;
   protected static $api_key;
   protected $session_id;
@@ -46,10 +46,7 @@ class E2E_Extern_RestTest extends CiviEndToEndTestCase {
     $this->old_api_keys = [];
   }
 
-  protected function getRestUrl() {
-    return CRM_Core_Resources::singleton()
-      ->getUrl('civicrm', 'extern/rest.php');
-  }
+  abstract protected function getRestUrl();
 
   protected function tearDown(): void {
     if (!empty($this->old_api_keys)) {
diff --git a/tests/phpunit/E2E/Extern/LegacyRestTest.php b/tests/phpunit/E2E/Extern/LegacyRestTest.php
new file mode 100644 (file)
index 0000000..e6c72a0
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Verify that the REST API bindings correctly parse and authenticate requests.
+ *
+ * @group e2e
+ */
+class E2E_Extern_LegacyRestTest extends E2E_Extern_BaseRestTest {
+
+  protected function setUp(): void {
+    if (CIVICRM_UF === 'Drupal8') {
+      $this->markTestSkipped('Legacy extern/rest.php does not apply to Drupal 8+');
+    }
+    parent::setUp();
+  }
+
+  protected function getRestUrl() {
+    return CRM_Core_Resources::singleton()
+      ->getUrl('civicrm', 'extern/rest.php');
+  }
+
+}