public function testNormalizeCallsWrappedNormalizerAndFiltersOutput() { $called = false; add_filter(magnify_hook('normalized_post'), function ($result) use(&$called) { $called = true; return $result; }); $postId = $this->factory->post->create($in = ['post_title' => 'FilteringNormalizerTest']); $post = get_post($postId); $this->wrapped->expects($this->once())->method('normalize')->with(1, $this->identicalTo($post))->willReturn($in); $result = $this->normalizer->normalize(1, $post); $this->assertEquals($in, $result); $this->assertTrue($called, 'should have called the filter'); }
public function setUp() { parent::setUp(); remove_filter(magnify_hook('driver_enabled'), '_magnify_disable_inactive_drivers'); $this->logger = new Logger\SpyLogger(); $this->driver = $this->getMock(Driver::class); $this->normalizer = $this->getMock(Normalizer::class); $this->handler = new SyncHandler($this->driver, $this->normalizer, $this->logger); $this->handler->connect(); }
function magnify_filter($hook, ...$args) { return apply_filters(magnify_hook($hook), ...$args); }