From 0256c39c51419776d827670ed51b3312b44e30dd Mon Sep 17 00:00:00 2001
From: Rich Lott / Artful Robot <forums@artfulrobot.uk>
Date: Fri, 22 Nov 2019 20:03:35 +0000
Subject: [PATCH] update tests a bit WIP

---
 CRM/Dataprocessor/Upgrader/Base.php                    | 10 +++++-----
 info.xml                                               |  2 +-
 .../CreateDataProcessorDataSourceTest.php              |  4 +++-
 tests/phpunit/CRM/Dataprocessor/TestBase.php           |  2 +-
 tests/phpunit/bootstrap.php                            |  1 +
 5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/CRM/Dataprocessor/Upgrader/Base.php b/CRM/Dataprocessor/Upgrader/Base.php
index 63c0118c..6200bf83 100644
--- a/CRM/Dataprocessor/Upgrader/Base.php
+++ b/CRM/Dataprocessor/Upgrader/Base.php
@@ -281,7 +281,7 @@ class CRM_Dataprocessor_Upgrader_Base {
   // ******** Hook delegates ********
 
   /**
-   * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
+   * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
    */
   public function onInstall() {
     $files = glob($this->extensionDir . '/sql/*_install.sql');
@@ -308,7 +308,7 @@ class CRM_Dataprocessor_Upgrader_Base {
   }
 
   /**
-   * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall
+   * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
    */
   public function onPostInstall() {
     $revisions = $this->getRevisions();
@@ -321,7 +321,7 @@ class CRM_Dataprocessor_Upgrader_Base {
   }
 
   /**
-   * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
+   * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
    */
   public function onUninstall() {
     $files = glob($this->extensionDir . '/sql/*_uninstall.mysql.tpl');
@@ -342,7 +342,7 @@ class CRM_Dataprocessor_Upgrader_Base {
   }
 
   /**
-   * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
+   * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
    */
   public function onEnable() {
     // stub for possible future use
@@ -352,7 +352,7 @@ class CRM_Dataprocessor_Upgrader_Base {
   }
 
   /**
-   * @see https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
+   * @see https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
    */
   public function onDisable() {
     // stub for possible future use
diff --git a/info.xml b/info.xml
index 42c04fcc..6366d407 100644
--- a/info.xml
+++ b/info.xml
@@ -25,7 +25,7 @@
     <ver>5.15</ver>
   </compatibility>
   <classloader>
-    <psr4 prefix="Civi\" path="Civi" />
+    <psr4 prefix="Civi\" path="Civi"/>
   </classloader>
   <civix>
     <namespace>CRM/Dataprocessor</namespace>
diff --git a/tests/phpunit/CRM/Dataprocessor/CreateDataProcessorDataSourceTest.php b/tests/phpunit/CRM/Dataprocessor/CreateDataProcessorDataSourceTest.php
index 9bbe8c69..c28b2f43 100644
--- a/tests/phpunit/CRM/Dataprocessor/CreateDataProcessorDataSourceTest.php
+++ b/tests/phpunit/CRM/Dataprocessor/CreateDataProcessorDataSourceTest.php
@@ -24,8 +24,10 @@ class CRM_Dataprocessor_CreateDataProcessorDataSourceTest extends CRM_Dataproces
 
     $data_processor_id = $this->createTestDataProcessorFixture();
 
-    // Retrieving the id of data processor
     $factory = dataprocessor_get_factory();
+    if ($factory === NULL) {
+      $this->fail("Test cannot complete, unable to obtain data processor factory.");
+    }
     $data_sources = $factory->getDataSources();
 
     foreach ($data_sources as $key => $value) {
diff --git a/tests/phpunit/CRM/Dataprocessor/TestBase.php b/tests/phpunit/CRM/Dataprocessor/TestBase.php
index 50f7badf..291f626f 100644
--- a/tests/phpunit/CRM/Dataprocessor/TestBase.php
+++ b/tests/phpunit/CRM/Dataprocessor/TestBase.php
@@ -19,7 +19,7 @@ use Civi\Test\TransactionalInterface;
  *
  * @group headless
  */
-class CRM_Dataprocessor_TestBase extends \PHPUnit_Framework_TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
+class CRM_Dataprocessor_TestBase extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
 
   /**
    * @var array keyed by ID
diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php
index afa827e9..352e0070 100644
--- a/tests/phpunit/bootstrap.php
+++ b/tests/phpunit/bootstrap.php
@@ -2,6 +2,7 @@
 
 ini_set('memory_limit', '2G');
 ini_set('safe_mode', 0);
+// phpcs:ignore
 eval(cv('php:boot --level=classloader', 'phpcode'));
 
 // Allow autoloading of PHPUnit helper classes in this extension.
-- 
GitLab