Skip to content

generate:api gives error and stops before creating phpunit.xml. Similarly generate:test gives a warning and the test suite name is pretruncated.#406

Merged
totten merged 1 commit intototten:masterfrom
demeritcowboy:fullname
Jun 29, 2025

Conversation

@demeritcowboy
Copy link
Copy Markdown
Contributor

I made up the word pretruncated.

In #355 it added a use of $ctx['fullName'] to name the test suite, but it seems like maybe this never worked unless it was also building the info.xml at the same time as making phpunit.xml?

This PR updates it to load it from the info since fullName never gets set.

e.g. At the time this was the code and you can see here fullName is never set:

$ctx = [];
$ctx['type'] = 'module';
$ctx['basedir'] = \CRM\CivixBundle\Application::findExtDir();
$basedir = new Path($ctx['basedir']);
$info = new Info($basedir->string('info.xml'));
$info->load($ctx);
if ($info->getType() != 'module') {
$output->writeln('<error>Wrong extension type: ' . $info->getType() . '</error>');
return;
}
$phpUnitInitFiles = new PHPUnitGenerateInitFiles();
$phpUnitInitFiles->initPhpunitXml($basedir->string('phpunit.xml.dist'), $ctx, $output);

And in the current code the "generator" only has access to the "default ctx", and not this ctx, which also doesn't have fullName anyway:

@totten
Copy link
Copy Markdown
Owner

totten commented Jun 29, 2025

Thanks, @demeritcowboy!

gives error and stops before creating phpunit.xml

I can sort of reproduce this. Just noting that it seems to vary by the mix of CMS and subcommand.

  • In some cases (eg D7+generate:api), the CMS captures and hides the error (so it looks like a clean run - although phpunit.xml.dist shows a weird name ).
  • But in other cases (eg D7+generate:test), it produces a visible problem.

Patch works better. 👍

And in the current code the "generator" only has access to the "default ctx", and not this ctx, which also doesn't have fullName anyway:

Tangentially... civix was first written with a lot of emphasis on the $ctx stuff. But over time, it started to feel overwrought. (It's too easy to get lost trying to track what $ctx properties are needed for various commands+scenarios.) The Generator aims to reorganize around plain-old-methods/plain-old-objects so that we can encapsulate/phase-out the $ctx stuff.

@totten totten merged commit bd25634 into totten:master Jun 29, 2025
1 check passed
@demeritcowboy demeritcowboy deleted the fullname branch June 30, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants