Fixes failing attribute defined test #24
Merged
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.
Running on Craft 5 results in the error,
Calling unknown method: craft\fields\Dropdown::valueType()
.The code in question is failing because the attribute
is defined
test on objects that extend theComponent
class (or any class that implements__call()
) always returnstrue
.craft-pest-core/stubs/compiled_classes/FactoryFields.twig
Lines 7 to 10 in cd7edd6
This is a known issue.
This PR is a simple workaround that performs the check based on the Craft versions.
There’s probably a more elegant way to check for Craft version, I’ll leave that up to you.
Running on Craft 5, the “attribute is defined” test is failing and resulting in the error,
Calling unknown method: craft\fields\Dropdown::valueType()
.I also found that
type
needs a default value since it may not be set when tested againstcraft-pest-core/stubs/compiled_classes/FactoryFields.twig
Line 18 in cd7edd6
Resulting in this working code.