aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text_formatter/s9e/parser_test.php
diff options
context:
space:
mode:
authorJoshyPHP <s9e.dev@gmail.com>2015-03-26 05:20:23 +0100
committerJoshyPHP <s9e.dev@gmail.com>2015-04-02 19:16:04 +0200
commitf75f63b264b2005faedb699dd867bd1d9c429a09 (patch)
tree31504b8cc529aa313c2ce31a177ac672292762c5 /tests/text_formatter/s9e/parser_test.php
parenta04fca86ee4fec3cb615f358f3dc914564d9a9b1 (diff)
downloadforums-f75f63b264b2005faedb699dd867bd1d9c429a09.tar
forums-f75f63b264b2005faedb699dd867bd1d9c429a09.tar.gz
forums-f75f63b264b2005faedb699dd867bd1d9c429a09.tar.bz2
forums-f75f63b264b2005faedb699dd867bd1d9c429a09.tar.xz
forums-f75f63b264b2005faedb699dd867bd1d9c429a09.zip
[ticket/11768] Added parser events
Added core.text_formatter_s9e_parse_before and core.text_formatter_s9e_parse_after PHPBB3-11768
Diffstat (limited to 'tests/text_formatter/s9e/parser_test.php')
-rw-r--r--tests/text_formatter/s9e/parser_test.php54
1 files changed, 54 insertions, 0 deletions
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'] === '<t>...</t>';
+ }
}