-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
tests: automatically create cascade persist permutations #666
base: 2.x
Are you sure you want to change the base?
tests: automatically create cascade persist permutations #666
Conversation
$temp[$j] = new DoctrineCascadeRelationshipMetadata( | ||
class: $permutations[$j]['class'], | ||
field: $permutations[$j]['field'], | ||
cascade: (bool) (($i >> $j) & 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you chatGPT 😅
#[UsingRelationShips(StandardContact::class, ['category'])] | ||
#[UsingRelationShips(StandardCategory::class, ['contacts'])] | ||
public function many_to_one(): void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure for this specific test if the inverse relationship is even used 🤔
/** | ||
* @return iterable<list<DoctrineCascadeRelationshipMetadata>> | ||
*/ | ||
private static function provideCascadeRelationshipsCombination(string $methodName): iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to add some tests for this stuff as well
* @author Nicolas PHILIPPE <[email protected]> | ||
*/ | ||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] | ||
final class UsingRelationShips |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final class UsingRelationShips | |
final class UsingRelationships |
/** | ||
* @author Nicolas PHILIPPE <[email protected]> | ||
*/ | ||
trait WithEntityRelationShip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait WithEntityRelationShip | |
trait WithEntityRelationship |
fixes #597
This PR introduces a way to automatically create all permutations for "cascade persist" relationships.
By using a combination of the trait
WithEntityRelationShip
, and the attributeUsingRelationShips
, a data provider is automatically created with all possible combinations of the "cascade persist" and "standard" associations.ex:
If we're OK on this implementation, I think I can remove all
StandardXXX
andCascadeXXX
classes!Here are some thoughts about this work:
UsingRelationShips
. I don't think it is possible to automatically add it, but I've added a check which enforces to add the provider if the attribute is usedWithEntityRelationShip
MUST be beforeFactories
trait. I have to find a way to enforce that. It is a problem of order in the@before
hooks and this is why I decided to propose this change in PHPUnit