What am I doing wrong here?
class Example
{
public function __construct()
{
add_filter('template_include', [$this, 'template']);
}
public function template(string $template): string
{
return 'something';
}
}
class ExampleTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Brain\Monkey\setUp();
}
protected function tearDown(): void
{
Brain\Monkey\tearDown();
parent::tearDown();
}
public function testExample()
{
Brain\Monkey\Filters\expectAdded('template_include')
->with('Example->template()');
new Example;
}
}
Returns
There was 1 error:
1) ExampleTest::testExample
Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_0::add_filter_template_include([0 => object(Example), 1 => 'template'], 10, 1). Either the method was unexpected or its arguments matched no expected argument list for this method
/.../vendor/mockery/mockery/library/Mockery/ExpectationDirector.php:92
/.../vendor/brain/monkey/src/Hook/HookExpectationExecutor.php:127
/.../vendor/brain/monkey/src/Hook/HookExpectationExecutor.php:64
/.../vendor/brain/monkey/inc/wp-hook-functions.php:35
/.../src/Example.php:24 (add_filter('template_include', [$this, 'template']))
/.../tests/ExampleTest.php:50 (new Example)
What am I doing wrong here?
Returns