Merge pull request #15330 from mattwire/paymentprocessor_testmodelivemode
[civicrm-core.git] / tests / phpunit / CRM / Core / ResourcesTest.php
index a00a9ca67a9ab0d4ae86299fa91b16e14f138c86..bfebbb69a9d8c2113382586a5df6d6e2d899ede4 100644 (file)
@@ -1,27 +1,11 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | 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       |
  +--------------------------------------------------------------------+
  */
 
@@ -42,7 +26,8 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase {
   protected $mapper;
 
   /**
-   * @var string for testing cache buster generation
+   * @var string
+   * For testing cache buster generation
    */
   protected $cacheBusterString = 'xBkdk3';
 
@@ -321,6 +306,9 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase {
 
     $actual = $smarty->fetch('string:{crmResURL ext=com.example.ext}');
     $this->assertEquals('http://ext-dir/com.example.ext/', $actual);
+
+    $actual = $smarty->fetch('string:{crmResURL expr="[civicrm.root]/foo"}');
+    $this->assertEquals(Civi::paths()->getUrl('[civicrm.root]/foo'), $actual);
   }
 
   public function testGlob() {
@@ -432,4 +420,28 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase {
     $this->assertEquals($expected, CRM_Core_Resources::isFullyFormedUrl($url));
   }
 
+  /**
+   * Test for hook_civicrm_entityRefFilters().
+   *
+   */
+  public function testEntityRefFiltersHook() {
+    CRM_Utils_Hook_UnitTests::singleton()->setHook('civicrm_entityRefFilters', [$this, 'entityRefFilters']);
+    $data = CRM_Core_Resources::getEntityRefMetadata();
+    $this->assertEquals(count($data['links']['Contact']), 4);
+    $this->assertEquals(!empty($data['links']['Contact']['new_staff']), TRUE);
+  }
+
+  /**
+   * @param array $filters
+   * @param array $links
+   */
+  public function entityRefFilters(&$filters, &$links) {
+    $links['Contact']['new_staff'] = [
+      'label' => ts('New Staff'),
+      'url' => '/civicrm/profile/create&reset=1&context=dialog&gid=5',
+      'type' => 'Individual',
+      'icon' => 'fa-user',
+    ];
+  }
+
 }