You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation of the CanBeDeletedMatcher can lead to code that will pass the tests but will fail in production.
WOUnit offers a matcher to verify if an object can or cannot be deleted. The implementation of this matcher is simple. It calls only the validateForDelete method on the object being verified. Considering how EOF works, this implementation is not enough. It doesn't guarantee, for instance, that the state of the object will be correct when firing the validation code while running tests.
In production, two actions execute before the validation and may change the state of an object. The ERXEC calls the ERXEnterpriseObject.mightDelete method when the object is deleted, and the original EOEditingContext propagates the deletion over related objects (applying the delete rules defined in the EOModel) when the editing context is saved. If a relationship has a delete rule of type Nullify or Cascade, it will no longer be in place when the validation is executed.
The following uses of the CanBeDeletedMatcher are affected by this issue:
To fix this problem, the CanBeDeletedMatcher should call the ERXEnterpriseObject.mightDelete and the EOEnterpriseObject.propagateDeleteWithEditingContext methods before calling the validateForDelete method.
The text was updated successfully, but these errors were encountered:
The implementation of the
CanBeDeletedMatcher
can lead to code that will pass the tests but will fail in production.WOUnit offers a matcher to verify if an object can or cannot be deleted. The implementation of this matcher is simple. It calls only the
validateForDelete
method on the object being verified. Considering how EOF works, this implementation is not enough. It doesn't guarantee, for instance, that the state of the object will be correct when firing the validation code while running tests.In production, two actions execute before the validation and may change the state of an object. The
ERXEC
calls theERXEnterpriseObject.mightDelete
method when the object is deleted, and the originalEOEditingContext
propagates the deletion over related objects (applying the delete rules defined in theEOModel
) when the editing context is saved. If a relationship has a delete rule of typeNullify
orCascade
, it will no longer be in place when the validation is executed.The following uses of the
CanBeDeletedMatcher
are affected by this issue:To fix this problem, the
CanBeDeletedMatcher
should call theERXEnterpriseObject.mightDelete
and theEOEnterpriseObject.propagateDeleteWithEditingContext
methods before calling thevalidateForDelete
method.The text was updated successfully, but these errors were encountered: