Added required public methods to the DataBuilderInterface
#586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
The first major update is adding public methods to
DataBuilderInterface
that are called during the normal course of operation. This is evidenced by the fact that the test fixtureFakeDataBuilder
included more methods than the interface required. If those methods were removed, the tests would start throwing errors because methods were called that did not exist.This is important because it is possible for a user to do something like the following...
The
dataBuilder
config option is not readily apparent in the code and is not in our developer documentation. (I didn't realize it existed until a few months ago.)If a user supplies their own data builder class, it must implement the
DataBuilderInterface
. However, if the user only implemented the methods that are required by the interface, we would start throwing exceptions when methods are called that don't exist. This honestly seems like a bit of an edge case, since rewriting the entireDataBuilder
class seems unlikely. Most people would extend theDataBuilder
class.The reason this is being included is because fixing it is a breaking change. Otherwise, it seems like a minor issue.
The second major change is removing the tests around custom data that is not an array. Our entire logic around custom data assumes the 'custom' config key is an array. In March of this year, I added these tests to ensure primitives and different objects would work correctly. At the time I was not as aware of the rest of our codebase that deals with the custom data array. Interestingly these tests passed. However, trying to use something other than an array would cause issues elsewhere.
I also updated the logic in
DataBuilder::addCustom()
to remove the need to throw an exception.Type of change
Related issues
None
Checklists
Development
Code review