Merge pull request #17474 from eileenmcnaughton/processor_name
[civicrm-core.git] / tests / phpunit / CiviTest / CiviTestSMSProvider.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Test SMS provider to allow for testing
14 */
15 class CiviTestSMSProvider extends CRM_SMS_Provider {
16 protected $_providerInfo = array();
17 protected $_id = 0;
18 static private $_singleton = array();
19
20 public function __construct($provider, $skipAuth = TRUE) {
21 $this->provider = $provider;
22 }
23
24 public static function &singleton($providerParams = array(), $force = FALSE) {
25 if (isset($providerParams['provider'])) {
26 $providers = CRM_SMS_BAO_Provider::getProviders(NULL, array('name' => $providerParams['provider']));
27 $provider = current($providers);
28 $providerID = $provider['id'];
29 }
30 else {
31 $providerID = $providerParams['provider_id'] ?? NULL;
32 }
33 $skipAuth = $providerID ? FALSE : TRUE;
34 $cacheKey = (int) $providerID;
35
36 if (!isset(self::$_singleton[$cacheKey]) || $force) {
37 $provider = array();
38 if ($providerID) {
39 $provider = CRM_SMS_BAO_Provider::getProviderInfo($providerID);
40 }
41 self::$_singleton[$cacheKey] = new CiviTestSMSProvider($provider, $skipAuth);
42 }
43 return self::$_singleton[$cacheKey];
44 }
45
46 public function send($recipients, $header, $message, $dncID = NULL) {
47 }
48
49 }