Skip to content

Commit

Permalink
Merge pull request #18511 from totten/master-aff-test
Browse files Browse the repository at this point in the history
Afform Tests - Fix extension tests when run via `civi-test-run`
  • Loading branch information
seamuslee001 authored Sep 18, 2020
2 parents fa90126 + 76b9562 commit d6ae26b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 14 additions & 0 deletions Civi/Angular/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ public function __construct($res, \CRM_Utils_Cache_Interface $cache = NULL) {
$this->cache = $cache ? $cache : new \CRM_Utils_Cache_ArrayCache([]);
}

/**
* Clear out any runtime-cached metadata.
*
* This is useful if, eg, you have recently added or destroyed Angular modules.
*
* @return static
*/
public function clear() {
$this->cache->clear();
$this->modules = NULL;
$this->changeSets = NULL;
return $this;
}

/**
* Get a list of AngularJS modules which should be autoloaded.
*
Expand Down
2 changes: 1 addition & 1 deletion Civi/Core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function loadContainer() {
$cacheMode = defined('CIVICRM_CONTAINER_CACHE') ? CIVICRM_CONTAINER_CACHE : 'auto';

// In pre-installation environments, don't bother with caching.
if (!defined('CIVICRM_DSN') || $cacheMode === 'never' || \CRM_Utils_System::isInUpgradeMode()) {
if (!defined('CIVICRM_DSN') || defined('CIVICRM_TEST') || CIVICRM_UF === 'UnitTests' || $cacheMode === 'never' || \CRM_Utils_System::isInUpgradeMode()) {
$containerBuilder = $this->createContainer();
$containerBuilder->compile();
return $containerBuilder;
Expand Down
5 changes: 1 addition & 4 deletions ext/afform/core/afform.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,7 @@ function afform_civicrm_permission_check($permission, &$granted, $contactId) {
function _afform_clear() {
$container = \Civi::container();
$container->get('afform_scanner')->clear();

// Civi\Angular\Manager doesn't currently have a way to clear its in-memory
// data, so we just reset the whole object.
$container->set('angular', NULL);
$container->get('angular')->clear();
}

/**
Expand Down

0 comments on commit d6ae26b

Please sign in to comment.