Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Afform Tests - Fix extension tests when run via civi-test-run #18511

Merged
merged 2 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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