Closed bleepsandblops closed 1 year ago
Is the craft-pest
plugin installed in the Craft UI? There’s a behavior that provides that method in the plugin init
and the only reason I can think it would go missing would be if the plugin is not enabled.
Related: I’m looking at having everything run without needing to install the plugin. But that’s still a PR away and not in a release yet.
I have the same issue, the two plugins are enabled. The registration of the behaviour is executed (I can dump something there before errors are thrown).
Full output:
./vendor/bin/pest --verbose
FAIL Tests\ExampleTest
⨯ it Loads the homepage
---
• Tests\ExampleTest > it Loads the homepage
PHPUnit\Framework\ExceptionWrapper
Calling unknown method: lenz\linkfield\fields\LinkField::factoryTypeHint() in "__string_template__2feea56560234f273691feaa93ef7d61" at line 7
at vendor/craftcms/cms/src/helpers/Template.php:116
112▕ // Copy twig_get_attribute()'s BadMethodCallException handling
113▕ if ($ignoreStrictCheck || !$env->isStrictVariables()) {
114▕ return null;
115▕ }
➜ 116▕ throw new RuntimeError($e->getMessage(), -1, $source);
117▕ }
118▕ }
119▕
120▕ /**
1 vendor/phpunit/phpunit/src/Framework/TestCase.php:904
PHPUnit\Framework\TestResult::run()
2 vendor/phpunit/phpunit/src/Framework/TestSuite.php:675
PHPUnit\Framework\TestCase::run()
3 vendor/phpunit/phpunit/src/Framework/TestSuite.php:675
PHPUnit\Framework\TestSuite::run()
4 vendor/phpunit/phpunit/src/TextUI/TestRunner.php:653
PHPUnit\Framework\TestSuite::run()
5 vendor/phpunit/phpunit/src/TextUI/Command.php:144
PHPUnit\TextUI\TestRunner::run()
6 vendor/pestphp/pest/src/Console/Command.php:119
PHPUnit\TextUI\Command::run()
7 vendor/pestphp/pest/bin/pest:62
Pest\Console\Command::run()
8 vendor/pestphp/pest/bin/pest:63
{closure}()
9 vendor/bin/pest:120
include("*******/vendor/pestphp/pest/bin/pest")
Ah, this is because the field doesn't call parent::behaviors()
so EVENT_DEFINE_BEHAVIORS
is never run.
Link field inherits from ForeignField
which defines it's behaviors()
as,
Which overrides the default functionality of,
This fix will be that ForeignField
needs to call the parent
in order to retain this behavior. I've opened a PR with a potential fix, https://github.com/sebastian-lenz/craft-utils/pull/4.
thx! 🙌
I'm going to close this issue since the root cause is not in craft-pest
. Hopefully https://github.com/sebastian-lenz/craft-utils/pull/4 merges soon and resolves this! Feel free to jump over to that PR and submit bump the thread if you have more questions.
With Pest activated, when creating a new link field, I get:
Calling unknown method: lenz\linkfield\fields\LinkField::factoryTypeHint() in "__string_template__2feea56560234f273691feaa93ef7d61" at line 7