diff options
author | JoshyPHP <s9e.dev@gmail.com> | 2015-03-26 05:10:25 +0100 |
---|---|---|
committer | JoshyPHP <s9e.dev@gmail.com> | 2015-04-02 19:16:04 +0200 |
commit | a04fca86ee4fec3cb615f358f3dc914564d9a9b1 (patch) | |
tree | e444456da7658b136a87b8cdfaf079fd1056b760 /tests/text_formatter | |
parent | af4f9b860f50a562a03f55efad1da7e0854bdfda (diff) | |
download | forums-a04fca86ee4fec3cb615f358f3dc914564d9a9b1.tar forums-a04fca86ee4fec3cb615f358f3dc914564d9a9b1.tar.gz forums-a04fca86ee4fec3cb615f358f3dc914564d9a9b1.tar.bz2 forums-a04fca86ee4fec3cb615f358f3dc914564d9a9b1.tar.xz forums-a04fca86ee4fec3cb615f358f3dc914564d9a9b1.zip |
[ticket/11768] Added renderer events
Added core.text_formatter_s9e_render_before and
core.text_formatter_s9e_render_after
PHPBB3-11768
Diffstat (limited to 'tests/text_formatter')
-rw-r--r-- | tests/text_formatter/s9e/renderer_test.php | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index ab89d42620..c69a93dbc1 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -389,4 +389,58 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case && isset($vars['self']) && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; } + + /** + * @testdox render() triggers a core.text_formatter_s9e_render_before and core.text_formatter_s9e_render_after events + */ + public function test_render_event() + { + $container = $this->get_test_case_helpers()->set_s9e_services(); + $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface'); + $dispatcher + ->expects($this->any()) + ->method('trigger_event') + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(1)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_render_before', + $this->callback(array($this, 'render_before_event_callback')) + ) + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(2)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_render_after', + $this->callback(array($this, 'render_after_event_callback')) + ) + ->will($this->returnArgument(1)); + + $renderer = new \phpbb\textformatter\s9e\renderer( + $container->get('cache.driver'), + $container->getParameter('cache.dir'), + '_foo_renderer', + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + $renderer->render('<t>...</t>'); + } + + public function render_before_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer + && isset($vars['xml']) + && $vars['xml'] === '<t>...</t>'; + } + + public function render_after_event_callback($vars) + { + return isset($vars['html']) + && $vars['html'] === '...' + && isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\renderer; + } } |