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

Enhancement: Implement WithOptionalStrategy #365

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

localheinz
Copy link
Member

@localheinz localheinz commented Aug 4, 2020

This PR

  • implements a WithOptionalStrategy

πŸ’β€β™‚οΈ The fixture factory currently uses a DefaultStrategy for resolving field definitions.

This strategy involves random behavior, and

  • FieldDefinition::optionalClosure() might be resolved to null a concrete value
  • FieldDefinition::optionalReference() might be resolved to null or a concrete reference
  • FieldDefinition::optionalSequence() might be resolved to null or a concrete value
  • FieldDefinition::optionalValue() might be resolved to null or a concrete value
  • FieldDefinition::references() might be resolved to an empty array or an array of references

You might have a scenario where you have entity definitions that use optional field definitions, but would like to create an entity where these optional field definitions are resolved to concrete values or references. In this case you can use a fixture factory with the WithOptionalStrategy.

This strategy still involves random behavior, but

  • FieldDefinition::optionalClosure() will be resolved to a concrete value
  • FieldDefinition::optionalReference() will be resolved to a concrete value
  • FieldDefinition::optionalSequence() will be resolved to a concrete value
  • FieldDefinition::optionalValue() will be resolved to a concrete value
  • FieldDefinition::references() will be resolved to a non-empty array

@codecov
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

Merging #365 into main will increase coverage by 0.60%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #365      +/-   ##
============================================
+ Coverage     98.41%   99.01%   +0.60%     
- Complexity       98      107       +9     
============================================
  Files            21       24       +3     
  Lines           252      304      +52     
============================================
+ Hits            248      301      +53     
+ Misses            4        3       -1     
Impacted Files Coverage Ξ” Complexity Ξ”
src/FieldDefinition/Reference.php 100.00% <ΓΈ> (ΓΈ) 2.00 <0.00> (ΓΈ)
src/Count.php 100.00% <100.00%> (ΓΈ) 8.00 <8.00> (?)
src/Exception/InvalidCount.php 100.00% <100.00%> (ΓΈ) 1.00 <1.00> (?)
src/Exception/InvalidDefinition.php 100.00% <100.00%> (ΓΈ) 3.00 <3.00> (+2.00)
src/Exception/InvalidMaximum.php 100.00% <100.00%> (ΓΈ) 1.00 <1.00> (?)
src/Exception/InvalidMinimum.php 100.00% <100.00%> (ΓΈ) 1.00 <1.00> (?)
src/FieldDefinition.php 100.00% <100.00%> (ΓΈ) 9.00 <1.00> (-2.00)
src/FieldDefinition/References.php 100.00% <100.00%> (ΓΈ) 2.00 <1.00> (ΓΈ)
src/FixtureFactory.php 97.88% <100.00%> (-0.35%) 46.00 <20.00> (+4.00) ⬇️
src/Strategy/DefaultStrategy.php 100.00% <100.00%> (ΓΈ) 4.00 <4.00> (?)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 0751c29...8c6b6b0. Read the comment docs.

@localheinz localheinz force-pushed the feature/with-optional branch 3 times, most recently from fbf7c8b to 14b50a5 Compare August 4, 2020 17:11
@localheinz localheinz mentioned this pull request Aug 4, 2020
1 task
@localheinz localheinz marked this pull request as ready for review August 4, 2020 17:53
@localheinz localheinz mentioned this pull request Aug 4, 2020
1 task
@ergebnis-bot ergebnis-bot merged commit a21bbd9 into main Aug 4, 2020
@ergebnis-bot ergebnis-bot deleted the feature/with-optional branch August 4, 2020 18:10
@ergebnis-bot ergebnis-bot self-requested a review August 4, 2020 18:10
@localheinz localheinz mentioned this pull request Aug 5, 2020
1 task
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.

None yet

2 participants