From f75f63b264b2005faedb699dd867bd1d9c429a09 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Thu, 26 Mar 2015 05:20:23 +0100 Subject: [ticket/11768] Added parser events Added core.text_formatter_s9e_parse_before and core.text_formatter_s9e_parse_after PHPBB3-11768 --- tests/text_formatter/s9e/parser_test.php | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests/text_formatter/s9e/parser_test.php') diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index 03b29bef12..74182bda47 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -206,4 +206,58 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case && isset($vars['user']) && $vars['user'] instanceof \phpbb\user; } + + /** + * @testdox parse() triggers a core.text_formatter_s9e_parse_before and core.text_formatter_s9e_parse_after events + */ + public function test_parse_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_parse_before', + $this->callback(array($this, 'parse_before_event_callback')) + ) + ->will($this->returnArgument(1)); + $dispatcher + ->expects($this->at(2)) + ->method('trigger_event') + ->with( + 'core.text_formatter_s9e_parse_after', + $this->callback(array($this, 'parse_after_event_callback')) + ) + ->will($this->returnArgument(1)); + + $parser = new \phpbb\textformatter\s9e\parser( + $container->get('cache.driver'), + '_foo_parser', + $container->get('user'), + $container->get('text_formatter.s9e.factory'), + $dispatcher + ); + $parser->parse('...'); + } + + public function parse_before_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && isset($vars['text']) + && $vars['text'] === '...'; + } + + public function parse_after_event_callback($vars) + { + return isset($vars['self']) + && $vars['self'] instanceof \phpbb\textformatter\s9e\parser + && isset($vars['xml']) + && $vars['xml'] === '...'; + } } -- cgit v1.2.1