Skip to content

Commit

Permalink
WorkflowMessageTest - Fix weird inconsistency in resolving `@dataProv…
Browse files Browse the repository at this point in the history
…ider`

We see a failure scenario where:

* The first execution of WorkflowMessageTest runs fine.
* The second execution of WorkflowMessageTest fails to boot (while evaluating `@dataProvider`)
* If you reset the DB, then it works again - but only once.
  • Loading branch information
totten committed Jun 30, 2022
1 parent a207283 commit ebf5dbf
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/phpunit/api/v4/Entity/WorkflowMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,28 @@ public function testRenderExamplesBaseline() {
}

public function getRenderExamples(): array {
$metas = \Civi\Test::examples()->getMetas();
// Phpunit resolves data-providers at a moment where bootstrap is awkward.
// Dynamic data-providers should call-out to subprocess which can do full/normal boot.
$uf = getenv('CIVICRM_UF');
try {
putenv('CIVICRM_UF=');
$metas = cv('api4 ExampleData.get +s name,workflow \'{"where":[["tags","CONTAINS","phpunit"]]}\'');
}
finally {
putenv("CIVICRM_UF={$uf}");
}

$results = [];
foreach ($metas as $name => $meta) {
if (!empty($meta['data']['workflow'])) {
continue;
}
if (empty($meta['tags']) || !in_array('phpunit', $meta['tags'])) {
foreach ($metas as $meta) {
if (!empty($meta['workflow'])) {
continue;
}
if ($exampleFilter = getenv('WORKFLOW_EXAMPLES')) {
if (!preg_match($exampleFilter, $name)) {
if (!preg_match($exampleFilter, $meta['name'])) {
continue;
}
}
$results[$name] = [$meta['name']];
$results[$meta['name']] = [$meta['name']];
}
return $results;
}
Expand Down

0 comments on commit ebf5dbf

Please sign in to comment.