Example #1
0
 static function registerScripts()
 {
     static $loaded = FALSE;
     if ($loaded) {
         return;
     }
     $loaded = TRUE;
     CRM_Core_Resources::singleton()->addSettingsFactory(function () {
         global $user;
         $settings = array();
         $config = CRM_Core_Config::singleton();
         $extensions = CRM_Core_PseudoConstant::getExtensions();
         return array('Appraisals' => array('extensionPath' => CRM_Core_Resources::singleton()->getUrl('uk.co.compucorp.civicrm.appraisals'), 'settings' => $settings, 'permissions' => array()), 'adminId' => CRM_Core_Session::getLoggedInContactID(), 'contactId' => CRM_Utils_Request::retrieve('cid', 'Integer'), 'debug' => $config->debug);
     });
 }
Example #2
0
 /**
  * Find (or auto-create) a PHP file with information for bootstrapping the test environment
  *
  * @param string $key the extension for which tests will be run
  * @return string temp file path
  */
 protected function getBootstrapFile($key, $clear = FALSE)
 {
     $file = $this->getContainer()->get('kernel')->getCacheDir() . "/civix-phpunit.{$key}.php";
     if ($clear || !file_exists($file) || filemtime($file) < time() - self::BOOTSTRAP_TTL) {
         $template_vars = array();
         $template_vars['civicrm_setting'] = array();
         // disable extension searching
         $template_vars['civicrm_setting']['Extension Preferences']['ext_repo_url'] = FALSE;
         // use the same source tree for linked Civi runtime and test Civi runtime
         $template_vars['civicrm_setting']['Directory Preferences']['extensionsDir'] = \CRM_Core_BAO_Setting::getItem('Directory Preferences', 'extensionsDir');
         // extensionsURL of linked Civi runtime may differ from ideal value for test Civi runtime, but that's OK because extensionsURL defines *static* resources
         $template_vars['civicrm_setting']['URL Preferences']['extensionsURL'] = \CRM_Core_BAO_Setting::getItem('URL Preferences', 'extensionsURL');
         $template_vars['civicrm_setting']['Test']['test_extensions'] = array_keys(\CRM_Core_PseudoConstant::getExtensions());
         file_put_contents($file, $this->getContainer()->get('templating')->render('CRMCivixBundle:Code:phpunit-boot.php.php', $template_vars));
     }
     return $file;
 }
Example #3
0
 /**
  * Given the string, returns true or false if it's an extension class name.
  * 
  * @access public
  * @param string $clazz a string which might be an extension class name
  * @return boolean true if given string is an extension class name
  */
 public function isExtensionClass($clazz)
 {
     if (substr($clazz, 0, 4) != 'CRM_') {
         require_once 'CRM/Core/PseudoConstant.php';
         $extensions = CRM_Core_PseudoConstant::getExtensions($clazz);
         if (array_key_exists($this->classToKey($clazz), $extensions)) {
             return TRUE;
         }
     }
     return FALSE;
 }