Bootstrap classloading list incomplete (or something) when classscanner runs during extension install
Some preliminary notes since I don't have a full handle on what's happening, but after https://github.com/civicrm/civicrm-core/pull/24276, class scanning now runs more. This might be fine normally, but I think a test folder isn't getting included somewhere in the classloader config.
I can reproduce it like so:
- Create the following simple test file:
<?php class CRM_Foo_FooTest extends CiviUnitTestCase { public function testFoo() { $this->callAPISuccess('Extension', 'install', ['keys' => 'org.civicrm.search_kit']); // yes the same thing again $this->callAPISuccess('Extension', 'install', ['keys' => 'org.civicrm.search_kit']); } }
- export CIVICRM_UF=UnitTests
- phpunit tests\phpunit\CRM\Foo\FooTest.php
- Failure in api call for Extension install:
Scanned file Civi/Search/AdminTest.php for class Civi\Search\AdminTest, but it was not found.
- It's happening on this line where baseDir is search_kit's folder https://github.com/civicrm/civicrm-core/blob/06d92d394b6c6f127c82d43fe25b18948fd29d80/mixin/scan-classes%401/mixin.php#L58
In a non-core environment, I can reproduce it in a drupal test, where searchkit gets installed during the civi module enable during initial install. But note it fails on the test folder scanning, whereas the line 55 that runs before it for non-test files runs fine. This is why I think it's test folder bootstrap related.
But also confusing (or maybe a clue) is that if you start from a fresh database (e.g. DROP then CREATE so it's completely empty), then the test only fails if you try to install searchkit twice. If it's not a fresh database then it can fail earlier.
Technically a regression so marking regression it's just not the usual kind.