2014-04-17 15:00:14 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
2014-05-27 20:18:06 +02:00
|
|
|
* This file is part of the phpBB Forum Software package.
|
|
|
|
*
|
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
|
|
*
|
|
|
|
* For full copyright and license information, please see
|
|
|
|
* the docs/CREDITS.txt file.
|
2014-04-17 15:00:14 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-04-18 12:50:23 +02:00
|
|
|
class phpbb_event_php_exporter_test extends phpbb_test_case
|
2014-04-17 15:00:14 +02:00
|
|
|
{
|
2014-04-18 12:50:23 +02:00
|
|
|
/** @var \phpbb\event\php_exporter */
|
2014-04-17 15:00:14 +02:00
|
|
|
protected $exporter;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2014-04-18 12:50:23 +02:00
|
|
|
$this->exporter = new \phpbb\event\php_exporter(dirname(__FILE__) . '/fixtures/');
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 11:06:04 +02:00
|
|
|
static public function crawl_php_file_data()
|
2014-04-17 15:00:14 +02:00
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
'default.test',
|
|
|
|
array(
|
|
|
|
'default.dispatch' => array(
|
|
|
|
'event' => 'default.dispatch',
|
|
|
|
'file' => 'default.test',
|
|
|
|
'arguments' => array(),
|
|
|
|
'since' => '3.1.0-b2',
|
|
|
|
'description' => 'Description',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'extra_description.test',
|
|
|
|
array(
|
|
|
|
'extra_description.dispatch' => array(
|
|
|
|
'event' => 'extra_description.dispatch',
|
|
|
|
'file' => 'extra_description.test',
|
|
|
|
'arguments' => array(),
|
|
|
|
'since' => '3.1.0-b2',
|
|
|
|
'description' => 'Description',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
array(
|
2014-04-18 00:31:06 +02:00
|
|
|
'trigger.test',
|
2014-04-17 15:00:14 +02:00
|
|
|
array(
|
2014-04-18 00:31:06 +02:00
|
|
|
'core.trigger' => array(
|
|
|
|
'event' => 'core.trigger',
|
|
|
|
'file' => 'trigger.test',
|
2014-04-20 14:15:54 +02:00
|
|
|
'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'),
|
2014-04-18 00:31:06 +02:00
|
|
|
'since' => '3.1.0-a3',
|
2014-10-09 13:30:10 -04:00
|
|
|
'description' => 'Event after the post data has been assigned to the template',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'trigger_wspace.test',
|
|
|
|
array(
|
|
|
|
'core.trigger' => array(
|
|
|
|
'event' => 'core.trigger',
|
|
|
|
'file' => 'trigger_wspace.test',
|
|
|
|
'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'),
|
|
|
|
'since' => '3.1.0-a3',
|
2014-04-18 00:31:06 +02:00
|
|
|
'description' => 'Event after the post data has been assigned to the template',
|
2014-04-17 15:00:14 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2014-04-20 14:15:54 +02:00
|
|
|
array(
|
|
|
|
'trigger_many_vars.test',
|
|
|
|
array(
|
|
|
|
'core.posting_modify_template_vars' => array(
|
|
|
|
'event' => 'core.posting_modify_template_vars',
|
|
|
|
'file' => 'trigger_many_vars.test',
|
|
|
|
'arguments' => array(
|
|
|
|
'cancel', 'delete', 'error', 'form_enctype', 'forum_id',
|
|
|
|
'load', 'message_parser', 'mode', 'moderators', 'page_data',
|
|
|
|
'page_title', 'post_data', 'post_id', 'preview', 'refresh',
|
|
|
|
's_action', 's_hidden_fields', 's_topic_icons', 'save',
|
|
|
|
'submit', 'topic_id',
|
|
|
|
),
|
|
|
|
'since' => '3.1.0-a1',
|
|
|
|
'description' => 'This event allows you to modify template variables for the posting screen',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2014-04-18 00:31:06 +02:00
|
|
|
array(
|
|
|
|
'none.test',
|
|
|
|
array(),
|
|
|
|
),
|
2014-04-17 15:00:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-18 11:06:04 +02:00
|
|
|
* @dataProvider crawl_php_file_data
|
2014-04-17 15:00:14 +02:00
|
|
|
*/
|
2014-04-18 11:06:04 +02:00
|
|
|
public function test_crawl_php_file($file, $expected)
|
2014-04-17 15:00:14 +02:00
|
|
|
{
|
2014-04-18 11:06:04 +02:00
|
|
|
$this->exporter->crawl_php_file($file);
|
2014-04-18 12:50:23 +02:00
|
|
|
$this->assertEquals($expected, $this->exporter->get_events());
|
2014-04-18 02:08:23 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 11:06:04 +02:00
|
|
|
static public function crawl_php_file_throws_data()
|
2014-04-18 02:08:23 +02:00
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('missing_var.test', null),
|
|
|
|
array('duplicate_event.test', 10),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-04-18 11:06:04 +02:00
|
|
|
* @dataProvider crawl_php_file_throws_data
|
2014-04-18 02:08:23 +02:00
|
|
|
*/
|
2014-04-18 11:06:04 +02:00
|
|
|
public function test_crawl_php_file_throws($file, $exception_code)
|
2014-04-18 02:08:23 +02:00
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 11:06:04 +02:00
|
|
|
$this->exporter->crawl_php_file($file);
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function validate_since_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('* @since 3.1.0-a1', '3.1.0-a1'),
|
|
|
|
array('* @since 3.1.0-b3', '3.1.0-b3'),
|
|
|
|
array(' * @since 3.1.0-b3', '3.1.0-b3'),
|
2014-06-25 13:35:57 +02:00
|
|
|
array('* @since 3.1.0-RC2', '3.1.0-RC2'),
|
2014-10-06 16:53:20 +02:00
|
|
|
array(' * @since 3.1.0-a1', '3.1.0-a1'),
|
2014-04-17 15:00:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_since_data
|
|
|
|
*/
|
|
|
|
public function test_validate_since($since, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->assertEquals($expected, $this->exporter->validate_since($since));
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function validate_since_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
2014-04-25 12:31:57 +02:00
|
|
|
array('* @since 3.1.0-a1 '),
|
|
|
|
array('* @since 3.1.0-a1 bertie is cool'),
|
|
|
|
array('bertie* @since 3.1.0-a1'),
|
|
|
|
array('* @since 3.1-A2'),
|
2014-06-25 13:35:57 +02:00
|
|
|
array('* @since 3.1.0-rc1'),
|
2014-04-17 15:00:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_since_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
2014-04-25 12:31:57 +02:00
|
|
|
public function test_validate_since_throws($since)
|
2014-04-17 15:00:14 +02:00
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->validate_since($since);
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function validate_event_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('test.event', '* @event test.event', 'test.event'),
|
|
|
|
array('test.event2', ' * @event test.event2', 'test.event2'),
|
2014-10-06 16:53:20 +02:00
|
|
|
array('test.event', ' * @event test.event', 'test.event'),
|
2014-04-17 15:00:14 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_event_data
|
|
|
|
*/
|
|
|
|
public function test_validate_event($event_name, $event, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->assertEquals($expected, $this->exporter->validate_event($event_name, $event));
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function validate_event_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('test.event', '* @event test.event bertie is cool', 2),
|
|
|
|
array('test.event', 'bertie* @event test.event', 2),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_event_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_validate_event_throws($event_name, $event, $exception_code)
|
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->validate_event($event_name, $event);
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 00:31:06 +02:00
|
|
|
static public function validate_vars_docblock_array_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(array('abc', 'def'), array('abc', 'def')),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_vars_docblock_array_data
|
|
|
|
*/
|
|
|
|
public function test_validate_vars_docblock_array($vars_array, $vars_docblock)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->assertNull($this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock));
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function validate_vars_docblock_array_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(array('abc', 'def'), array()),
|
|
|
|
array(array('abc', 'def'), array('abc')),
|
|
|
|
array(array('abc', 'defg'), array('abc', 'def')),
|
|
|
|
array(array('abc'), array('abc', 'def')),
|
|
|
|
array(array(), array('abc', 'def')),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider validate_vars_docblock_array_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock);
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_dispatch_name_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array("\$phpbb_dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'),
|
|
|
|
array("\t\$phpbb_dispatcher->dispatch('dispatch.one2.thr_ee4');", 'dispatch.one2.thr_ee4'),
|
|
|
|
array("\$this->dispatcher->dispatch('dispatch.one2');", 'dispatch.one2'),
|
|
|
|
array("\$phpbb_dispatcher->dispatch('dis_patch.one');", 'dis_patch.one'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_dispatch_name_data
|
|
|
|
*/
|
|
|
|
public function test_get_dispatch_name($event_line, $expected)
|
|
|
|
{
|
2014-04-20 14:58:24 +02:00
|
|
|
$this->exporter->set_content(array($event_line));
|
|
|
|
$this->assertEquals($expected, $this->exporter->get_event_name(0, true));
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_dispatch_name_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array("\$phpbb_dispatcher->dispatch();"),
|
|
|
|
array("\$phpbb_dispatcher->dispatch('');"),
|
|
|
|
array("\$phpbb_dispatcher->dispatch('dispatch.2one');"),
|
|
|
|
array("\$phpbb_dispatcher->dispatch('dispatch');"),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_dispatch_name_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_get_dispatch_name_throws($event_line)
|
|
|
|
{
|
2014-04-20 14:58:24 +02:00
|
|
|
$this->exporter->set_content(array($event_line));
|
|
|
|
$this->exporter->get_event_name(0, true);
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_trigger_event_name_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'),
|
|
|
|
array("\textract(\$phpbb_dispatcher->trigger_event('dispatch.one2.thr_ee4', compact(\$vars)));", 'dispatch.one2.thr_ee4'),
|
|
|
|
array("extract(\$this->dispatcher->trigger_event('dispatch.one2', compact(\$vars)));", 'dispatch.one2'),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars)));", 'dis_patch.one'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_trigger_event_name_data
|
|
|
|
*/
|
|
|
|
public function test_get_trigger_event_name($event_line, $expected)
|
|
|
|
{
|
2014-04-20 14:58:24 +02:00
|
|
|
$this->exporter->set_content(array($event_line));
|
|
|
|
$this->assertEquals($expected, $this->exporter->get_event_name(0, false));
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_trigger_event_name_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event());"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event(''));"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.2one'));"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch'));"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', \$vars));"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$var)));"),
|
|
|
|
array("extract(\$phpbb_dispatcher->trigger_event('dispatch.one', compact(\$array)));"),
|
|
|
|
array("\$phpbb_dispatcher->trigger_event('dis_patch.one', compact(\$vars));", 'dis_patch.one'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_trigger_event_name_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_get_trigger_event_name_throws($event_line)
|
|
|
|
{
|
2014-04-20 14:58:24 +02:00
|
|
|
$this->exporter->set_content(array($event_line));
|
|
|
|
$this->exporter->get_event_name(0, false);
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_vars_from_array_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = array(\'bertie\');',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
3,
|
|
|
|
array('bertie'),
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
"\t/**",
|
|
|
|
"\t*/",
|
|
|
|
"\t\$vars = array('_Strange123', 'phpBB3_Test');",
|
|
|
|
"\t\$this->dispatcher->dispatch('test');",
|
|
|
|
),
|
|
|
|
3,
|
|
|
|
array('_Strange123', 'phpBB3_Test'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_vars_from_array_data
|
|
|
|
*/
|
|
|
|
public function test_get_vars_from_array($lines, $event_line, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->assertEquals($expected, $this->exporter->get_vars_from_array());
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_vars_from_array_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
2014-04-20 14:15:54 +02:00
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
2014-04-25 11:46:24 +02:00
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
2014-04-20 14:15:54 +02:00
|
|
|
),
|
|
|
|
2,
|
2014-04-25 11:46:24 +02:00
|
|
|
1,
|
2014-04-20 14:15:54 +02:00
|
|
|
),
|
2014-04-18 00:31:06 +02:00
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = $bertie;',
|
2014-04-25 11:46:24 +02:00
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
3,
|
2014-04-25 11:46:24 +02:00
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = array(\'$bertie\');',
|
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
|
|
|
),
|
2014-04-20 14:15:54 +02:00
|
|
|
3,
|
2014-04-25 11:46:24 +02:00
|
|
|
1,
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = array();',
|
2014-04-25 11:46:24 +02:00
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
3,
|
2014-04-25 11:46:24 +02:00
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = array(\'t1\', \'t2\', \'t3\', \'t4\', \'t5\', \'t6\', \'t7\');',
|
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
|
|
|
),
|
2014-04-20 14:15:54 +02:00
|
|
|
3,
|
2014-04-25 11:46:24 +02:00
|
|
|
2,
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
2014-04-20 14:15:54 +02:00
|
|
|
'$vars = array(\'test2\', \'\');',
|
2014-04-25 11:46:24 +02:00
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
3,
|
2014-04-25 11:46:24 +02:00
|
|
|
3,
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
2014-04-25 11:46:24 +02:00
|
|
|
'$vars = array(\'bertie\'\');',
|
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
|
|
|
),
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$vars = array(\'bertie\',\'basically_valid\');',
|
|
|
|
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
2014-04-18 00:31:06 +02:00
|
|
|
),
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_vars_from_array_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_get_vars_from_array_throws($lines, $event_line, $exception_code)
|
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 02:08:23 +02:00
|
|
|
|
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->exporter->get_vars_from_array();
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_vars_from_docblock_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @var int name1 Description',
|
|
|
|
'* @var array name2 Description test',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
array('name1', 'name2'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_vars_from_docblock_data
|
|
|
|
*/
|
|
|
|
public function test_get_vars_from_docblock($lines, $event_line, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->assertEquals($expected, $this->exporter->get_vars_from_docblock());
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function get_vars_from_docblock_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'$vars = array();',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @var int name1',
|
|
|
|
'* @var array name2 Description test',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @var int name1 Description',
|
|
|
|
'* @var array $name2 Description',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
4,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider get_vars_from_docblock_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code)
|
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 02:08:23 +02:00
|
|
|
|
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->exporter->get_vars_from_docblock();
|
2014-04-18 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
2014-04-17 15:00:14 +02:00
|
|
|
static public function find_since_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @since 3.1.0-a1',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
3,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'* @since 3.1.0-a1',
|
|
|
|
'/**',
|
|
|
|
'* @since 3.1.0-a1',
|
|
|
|
'* @changed 3.1.0-a2',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
5,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider find_since_data
|
|
|
|
*/
|
|
|
|
public function test_find_since($lines, $event_line, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->assertEquals($expected, $this->exporter->find_since());
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function find_since_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @since 3.1.0-a1',
|
|
|
|
'*/',
|
|
|
|
'/**',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
5,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @changed 3.1.0-a1',
|
|
|
|
'* @changed 3.1.0-a2',
|
|
|
|
'* @changed 3.1.0-a3',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
5,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @since 3.1.0-a2',
|
|
|
|
'* @var',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
3,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @since 3.1.0-a2',
|
|
|
|
'* @event',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
3,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider find_since_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_find_since_throws($lines, $event_line, $exception_code)
|
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 02:08:23 +02:00
|
|
|
|
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->exporter->find_since();
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function find_description_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* Hello Bertie!',
|
|
|
|
'* @since 3.1.0-a1',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
' /**',
|
|
|
|
' * Hello Bertie!',
|
|
|
|
' *',
|
|
|
|
' * @since 3.1.0-a1',
|
|
|
|
' * @changed 3.1.0-a2',
|
|
|
|
' */',
|
|
|
|
' $phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
6,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider find_description_data
|
|
|
|
*/
|
|
|
|
public function test_find_description($lines, $event_line, $expected)
|
|
|
|
{
|
2014-04-18 02:08:23 +02:00
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->assertEquals($expected, $this->exporter->find_description());
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static public function find_description_throws_data()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'$vars = array();',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* @changed 3.1.0-a1',
|
|
|
|
'* @changed 3.1.0-a2',
|
|
|
|
'* @changed 3.1.0-a3',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
5,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'*',
|
|
|
|
'* @since 3.1.0-a2',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'/**',
|
|
|
|
'* ',
|
|
|
|
'* @event',
|
|
|
|
'*/',
|
|
|
|
'$phpbb_dispatcher->dispatch(\'test\');',
|
|
|
|
),
|
|
|
|
4,
|
|
|
|
2,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider find_description_throws_data
|
|
|
|
* @expectedException LogicException
|
|
|
|
*/
|
|
|
|
public function test_find_description_throws($lines, $event_line, $exception_code)
|
|
|
|
{
|
|
|
|
$this->setExpectedException('LogicException', '', $exception_code);
|
2014-04-18 02:08:23 +02:00
|
|
|
|
|
|
|
$this->exporter->set_current_event('', $event_line);
|
|
|
|
$this->exporter->set_content($lines);
|
|
|
|
$this->exporter->find_description();
|
2014-04-17 15:00:14 +02:00
|
|
|
}
|
|
|
|
}
|