mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-11 03:04:09 +02:00
Merge remote-tracking branch 'github-nickvergessen/ticket/12273' into develop-ascraeus
* github-nickvergessen/ticket/12273: (55 commits) [ticket/12273] Move $extension to constructor so the path is always set [ticket/12273] Find events.md relative from the path not the phpbb root [ticket/12273] Do not look in extensions docs/ and tests/ directory [ticket/12273] Also check file for adm "Location:" events [ticket/12273] Do not allow template events in non-html files [ticket/12273] Fix return description [ticket/12273] Update exporter to allow specifying an extension [ticket/12273] Allow to filter events for extensions [ticket/12273] Remove old parameter from function call [ticket/12273] Fix table header for adm events [ticket/12273] Add root path to recursive_event_filter_iterator [ticket/12273] Fix missing classes in export_events_for_wiki.php [ticket/12273] Use RecursiveDirectoryIterator with filter in php_exporter [ticket/12273] Use RecursiveDirectoryIterator in md_exporter [ticket/12273] Fix doc blocks [ticket/12273] Do not allow 3.1-A1 for template events [ticket/12273] Sort arguments alphabetically before exporting [ticket/12273] Do not allow 3.1-A1 version [ticket/12273] Update since version to 3.1.0-a* style [ticket/12273] Update existing events ...
This commit is contained in:
45
tests/event/export_php_test.php
Normal file
45
tests/event/export_php_test.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_event_export_php_test extends phpbb_test_case
|
||||
{
|
||||
/** @var \phpbb\event\php_exporter */
|
||||
protected $exporter;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
global $phpbb_root_path;
|
||||
$this->exporter = new \phpbb\event\php_exporter($phpbb_root_path);
|
||||
}
|
||||
|
||||
static public function crawl_php_file_data()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$exporter = new \phpbb\event\php_exporter($phpbb_root_path);
|
||||
$files = $exporter->get_recursive_file_list($phpbb_root_path);
|
||||
|
||||
$data_provider = array();
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$data_provider[] = array($file);
|
||||
}
|
||||
|
||||
return $data_provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider crawl_php_file_data
|
||||
*/
|
||||
public function test_crawl_php_file($file)
|
||||
{
|
||||
$this->assertGreaterThanOrEqual(0, $this->exporter->crawl_php_file($file));
|
||||
}
|
||||
}
|
9
tests/event/fixtures/default.test
Normal file
9
tests/event/fixtures/default.test
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* @event default.dispatch
|
||||
* @since 3.1.0-b2
|
||||
*/
|
||||
$phpbb_dispatcher->dispatch('default.dispatch');
|
19
tests/event/fixtures/duplicate_event.test
Normal file
19
tests/event/fixtures/duplicate_event.test
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Event after the post data has been assigned to the template
|
||||
*
|
||||
* @event duplicate.trigger
|
||||
* @var int start Start item of this page
|
||||
* @since 3.1.0-a3
|
||||
*/
|
||||
$vars = array('start');
|
||||
extract($phpbb_dispatcher->trigger_event('duplicate.trigger', compact($vars)));
|
||||
|
||||
/**
|
||||
* Event after the post data has been assigned to the template
|
||||
*
|
||||
* @event duplicate.trigger
|
||||
* @since 3.1.0-b1
|
||||
*/
|
||||
$phpbb_dispatcher->dispatch('duplicate.trigger');
|
11
tests/event/fixtures/extra_description.test
Normal file
11
tests/event/fixtures/extra_description.test
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Description
|
||||
*
|
||||
* NOTE: This will not be exported
|
||||
*
|
||||
* @event extra_description.dispatch
|
||||
* @since 3.1.0-b2
|
||||
*/
|
||||
$phpbb_dispatcher->dispatch('extra_description.dispatch');
|
17
tests/event/fixtures/missing_var.test
Normal file
17
tests/event/fixtures/missing_var.test
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Event after the post data has been assigned to the template
|
||||
*
|
||||
* @event core.trigger
|
||||
* @var int start Start item of this page
|
||||
* @var int current_row_number Number of the post on this page
|
||||
* @var int end Number of posts on this page
|
||||
* @var array row Array with original post and user data
|
||||
* @var array cp_row Custom profile field data of the poster
|
||||
* @var array attachments List of attachments
|
||||
* @var array user_poster_data Poster's data from user cache
|
||||
* @since 3.1.0-a3
|
||||
*/
|
||||
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.trigger', compact($vars)));
|
6
tests/event/fixtures/none.test
Normal file
6
tests/event/fixtures/none.test
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Hi there :)
|
||||
*/
|
||||
echo 1 + 2;
|
15
tests/event/fixtures/trigger.test
Normal file
15
tests/event/fixtures/trigger.test
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Event after the post data has been assigned to the template
|
||||
*
|
||||
* @event core.trigger
|
||||
* @var int start Start item of this page
|
||||
* @var int current_row_number Number of the post on this page
|
||||
* @var int end Number of posts on this page
|
||||
* @var array row Array with original post and user data
|
||||
* @var array cp_row Custom profile field data of the poster
|
||||
* @since 3.1.0-a3
|
||||
*/
|
||||
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row');
|
||||
extract($phpbb_dispatcher->trigger_event('core.trigger', compact($vars)));
|
65
tests/event/fixtures/trigger_many_vars.test
Normal file
65
tests/event/fixtures/trigger_many_vars.test
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This event allows you to modify template variables for the posting screen
|
||||
*
|
||||
* @event core.posting_modify_template_vars
|
||||
* @var array post_data Array with post data
|
||||
* @var array moderators Array with forum moderators
|
||||
* @var string mode What action to take if the form is submitted
|
||||
* post|reply|quote|edit|delete|bump|smilies|popup
|
||||
* @var string page_title Title of the mode page
|
||||
* @var bool s_topic_icons Whether or not to show the topic icons
|
||||
* @var string form_enctype If attachments are allowed for this form
|
||||
* "multipart/form-data" or empty string
|
||||
* @var string s_action The URL to submit the POST data to
|
||||
* @var string s_hidden_fields Concatenated hidden input tags of posting form
|
||||
* @var int post_id ID of the post
|
||||
* @var int topic_id ID of the topic
|
||||
* @var int forum_id ID of the forum
|
||||
* @var bool submit Whether or not the form has been submitted
|
||||
* @var bool preview Whether or not the post is being previewed
|
||||
* @var bool save Whether or not a draft is being saved
|
||||
* @var bool load Whether or not a draft is being loaded
|
||||
* @var bool delete Whether or not the post is being deleted
|
||||
* @var bool cancel Whether or not to cancel the form (returns to
|
||||
* viewtopic or viewforum depending on if the user
|
||||
* is posting a new topic or editing a post)
|
||||
* @var array error Any error strings; a non-empty array aborts
|
||||
* form submission.
|
||||
* NOTE: Should be actual language strings, NOT
|
||||
* language keys.
|
||||
* @var bool refresh Whether or not to retain previously submitted data
|
||||
* @var array page_data Posting page data that should be passed to the
|
||||
* posting page via $template->assign_vars()
|
||||
* @var object message_parser The message parser object
|
||||
* @since 3.1.0-a1
|
||||
* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
|
||||
* s_topic_icons, form_enctype, s_action, s_hidden_fields,
|
||||
* post_id, topic_id, forum_id, submit, preview, save, load,
|
||||
* delete, cancel, refresh, error, page_data, message_parser
|
||||
*/
|
||||
$vars = array(
|
||||
'post_data',
|
||||
'moderators',
|
||||
'mode',
|
||||
'page_title',
|
||||
's_topic_icons',
|
||||
'form_enctype',
|
||||
's_action',
|
||||
's_hidden_fields',
|
||||
'post_id',
|
||||
'topic_id',
|
||||
'forum_id',
|
||||
'submit',
|
||||
'preview',
|
||||
'save',
|
||||
'load',
|
||||
'delete',
|
||||
'cancel',
|
||||
'refresh',
|
||||
'error',
|
||||
'page_data',
|
||||
'message_parser',
|
||||
);
|
||||
extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars)));
|
67
tests/event/md_exporter_test.php
Normal file
67
tests/event/md_exporter_test.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_event_md_exporter_test extends phpbb_test_case
|
||||
{
|
||||
|
||||
static public function crawl_eventsmd_data()
|
||||
{
|
||||
return array(
|
||||
array('styles'),
|
||||
array('adm'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider crawl_eventsmd_data
|
||||
*/
|
||||
public function test_crawl_eventsmd($filter)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
|
||||
$this->assertGreaterThan(0, $exporter->crawl_eventsmd('docs/events.md', $filter));
|
||||
}
|
||||
|
||||
static public function crawl_template_file_data()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
|
||||
$data_provider = array();
|
||||
|
||||
$styles = array(
|
||||
'adm/style/' => 'adm',
|
||||
'styles/prosilver/template/' => 'styles',
|
||||
'styles/subsilver2/template/' => 'styles',
|
||||
);
|
||||
foreach ($styles as $path => $filter)
|
||||
{
|
||||
$files = $exporter->get_recursive_file_list($phpbb_root_path . $path, $path);
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$data_provider[] = array($filter, $path . $file);
|
||||
}
|
||||
}
|
||||
|
||||
return $data_provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider crawl_template_file_data
|
||||
*/
|
||||
public function test_crawl_template_file($filter, $file)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
|
||||
$exporter->crawl_eventsmd('docs/events.md', $filter);
|
||||
$events = $exporter->crawl_file_for_events($file);
|
||||
|
||||
$this->assertGreaterThanOrEqual(0, sizeof($events));
|
||||
$this->assertTrue($exporter->validate_events_from_file($file, $events));
|
||||
}
|
||||
}
|
722
tests/event/php_exporter_test.php
Normal file
722
tests/event/php_exporter_test.php
Normal file
@@ -0,0 +1,722 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_event_php_exporter_test extends phpbb_test_case
|
||||
{
|
||||
/** @var \phpbb\event\php_exporter */
|
||||
protected $exporter;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->exporter = new \phpbb\event\php_exporter(dirname(__FILE__) . '/fixtures/');
|
||||
}
|
||||
|
||||
static public function crawl_php_file_data()
|
||||
{
|
||||
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(
|
||||
'trigger.test',
|
||||
array(
|
||||
'core.trigger' => array(
|
||||
'event' => 'core.trigger',
|
||||
'file' => 'trigger.test',
|
||||
'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'),
|
||||
'since' => '3.1.0-a3',
|
||||
'description' => 'Event after the post data has been assigned to the template',
|
||||
),
|
||||
),
|
||||
),
|
||||
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',
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'none.test',
|
||||
array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider crawl_php_file_data
|
||||
*/
|
||||
public function test_crawl_php_file($file, $expected)
|
||||
{
|
||||
$this->exporter->crawl_php_file($file);
|
||||
$this->assertEquals($expected, $this->exporter->get_events());
|
||||
}
|
||||
|
||||
static public function crawl_php_file_throws_data()
|
||||
{
|
||||
return array(
|
||||
array('missing_var.test', null),
|
||||
array('duplicate_event.test', 10),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider crawl_php_file_throws_data
|
||||
*/
|
||||
public function test_crawl_php_file_throws($file, $exception_code)
|
||||
{
|
||||
$this->setExpectedException('LogicException', '', $exception_code);
|
||||
$this->exporter->crawl_php_file($file);
|
||||
}
|
||||
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_since_data
|
||||
*/
|
||||
public function test_validate_since($since, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->exporter->validate_since($since));
|
||||
}
|
||||
|
||||
static public function validate_since_throws_data()
|
||||
{
|
||||
return array(
|
||||
array(' * @since 3.1.0-a1'),
|
||||
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'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_since_throws_data
|
||||
* @expectedException LogicException
|
||||
*/
|
||||
public function test_validate_since_throws($since)
|
||||
{
|
||||
$this->exporter->validate_since($since);
|
||||
}
|
||||
|
||||
static public function validate_event_data()
|
||||
{
|
||||
return array(
|
||||
array('test.event', '* @event test.event', 'test.event'),
|
||||
array('test.event2', ' * @event test.event2', 'test.event2'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_event_data
|
||||
*/
|
||||
public function test_validate_event($event_name, $event, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->exporter->validate_event($event_name, $event));
|
||||
}
|
||||
|
||||
static public function validate_event_throws_data()
|
||||
{
|
||||
return array(
|
||||
array('test.event', ' * @event test.event', 1),
|
||||
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);
|
||||
$this->exporter->validate_event($event_name, $event);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->assertNull($this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_content(array($event_line));
|
||||
$this->assertEquals($expected, $this->exporter->get_event_name(0, true));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_content(array($event_line));
|
||||
$this->exporter->get_event_name(0, true);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_content(array($event_line));
|
||||
$this->assertEquals($expected, $this->exporter->get_event_name(0, false));
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_content(array($event_line));
|
||||
$this->exporter->get_event_name(0, false);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->assertEquals($expected, $this->exporter->get_vars_from_array());
|
||||
}
|
||||
|
||||
static public function get_vars_from_array_throws_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
2,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$vars = $bertie;',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
3,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$vars = array(\'$bertie\');',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
3,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$vars = array();',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
3,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$vars = array(\'t1\', \'t2\', \'t3\', \'t4\', \'t5\', \'t6\', \'t7\');',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
3,
|
||||
2,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$vars = array(\'test2\', \'\');',
|
||||
'$phpbb_dispatcher->trigger_event(\'test\', compact($vars));',
|
||||
),
|
||||
3,
|
||||
3,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'/**',
|
||||
'*/',
|
||||
'$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));',
|
||||
),
|
||||
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);
|
||||
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->exporter->get_vars_from_array();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->assertEquals($expected, $this->exporter->get_vars_from_docblock());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->exporter->get_vars_from_docblock();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->assertEquals($expected, $this->exporter->find_since());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->exporter->find_since();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->assertEquals($expected, $this->exporter->find_description());
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$this->exporter->set_current_event('', $event_line);
|
||||
$this->exporter->set_content($lines);
|
||||
$this->exporter->find_description();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user