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

(REF) WorkflowMessageTest - Use dataProvider #23811

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jun 16, 2022

Overview

This refactors a unit-test to improve DX.

Before

  • testRenderExamples() does a lookup to find examples -- and then loops through and renders each.
  • If any of the examples have an exception/error/failure, then the entire test fails - and it's unclear which example raised the problem.

After

  • testRenderExamples(string $name) will render an example (based on the name of the example)
  • The data-provider getRenderExamples() gives a list.
  • PHPUnit reports each test-run as a separate output, so it is easier to match the exception/error/failure to the relevant data.

Technical Details

  • The patch looks bigger than it should because of an indentation change (the top loop in testRenderExamples() was removed, so code moved back slightly.)
  • In PHPUnit, data-providers are liable to run before Civi has booted. To improve reliability, I switched from the higher-level Civi\Api4\ExampleData to the lower-level Civi\Test::examples()

@civibot
Copy link

civibot bot commented Jun 16, 2022

(Standard links)

@eileenmcnaughton
Copy link
Contributor

ok cool - so to add in any WorkFlowTemplate we just need to add the tag - which we can do once we've worked through the various bits & pieces for them

@eileenmcnaughton eileenmcnaughton merged commit 3de1fcd into civicrm:master Jun 16, 2022
@totten totten deleted the master-wfmsg-dataprovider branch June 16, 2022 04:30
totten added a commit to totten/civicrm-core that referenced this pull request Jun 28, 2022
This is a follow-up to civicrm#23811 (409b1e0). The prior commit
changed the way it found examples - and caused it to skip some examples.

This re-enables the example and adds an assertion to ensure that it actually
finds some examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants