aboutsummaryrefslogtreecommitdiffstats
path: root/tests/event
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-04-18 02:08:23 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-04-18 12:56:59 +0200
commitb831e96aafc4b8c2bc883dd47c4f2452f329e5b2 (patch)
tree92f86c5f8a4ddb0587ff37e9ded9fcb070b87e4e /tests/event
parent91deb4419b3f7c93288e969cf97fb9e1541c2ecf (diff)
downloadforums-b831e96aafc4b8c2bc883dd47c4f2452f329e5b2.tar
forums-b831e96aafc4b8c2bc883dd47c4f2452f329e5b2.tar.gz
forums-b831e96aafc4b8c2bc883dd47c4f2452f329e5b2.tar.bz2
forums-b831e96aafc4b8c2bc883dd47c4f2452f329e5b2.tar.xz
forums-b831e96aafc4b8c2bc883dd47c4f2452f329e5b2.zip
[ticket/12273] Use class properties instead of parameters
PHPBB3-12273
Diffstat (limited to 'tests/event')
-rw-r--r--tests/event/exporter_test.php76
-rw-r--r--tests/event/fixtures/duplicate_event.test26
-rw-r--r--tests/event/fixtures/missing_var.test1
3 files changed, 83 insertions, 20 deletions
diff --git a/tests/event/exporter_test.php b/tests/event/exporter_test.php
index 06a66abb04..df5a258bbb 100644
--- a/tests/event/exporter_test.php
+++ b/tests/event/exporter_test.php
@@ -71,7 +71,25 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_check_for_events($file, $expected)
{
- $this->assertEquals($expected, $this->exporter->check_for_events($file));
+ $this->exporter->check_for_events($file);
+ $this->assertEquals($expected, $this->exporter->get_events());
+ }
+
+ static public function check_for_events_throws_data()
+ {
+ return array(
+ array('missing_var.test', null),
+ array('duplicate_event.test', 10),
+ );
+ }
+
+ /**
+ * @dataProvider check_for_events_throws_data
+ */
+ public function test_check_for_events_throws($file, $exception_code)
+ {
+ $this->setExpectedException('LogicException', '', $exception_code);
+ $this->assertNull($this->exporter->check_for_events($file));
}
static public function validate_since_data()
@@ -89,7 +107,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_since($since, $expected)
{
- $this->assertEquals($expected, $this->exporter->validate_since('', '', $since));
+ $this->assertEquals($expected, $this->exporter->validate_since($since));
}
static public function validate_since_throws_data()
@@ -111,7 +129,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_validate_since_throws($since, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->validate_since('', '', $since);
+ $this->exporter->validate_since($since);
}
static public function validate_event_data()
@@ -127,7 +145,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_event($event_name, $event, $expected)
{
- $this->assertEquals($expected, $this->exporter->validate_event('', $event_name, $event));
+ $this->assertEquals($expected, $this->exporter->validate_event($event_name, $event));
}
static public function validate_event_throws_data()
@@ -146,7 +164,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_validate_event_throws($event_name, $event, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->validate_event('', $event_name, $event);
+ $this->exporter->validate_event($event_name, $event);
}
static public function validate_vars_docblock_array_data()
@@ -161,7 +179,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_vars_docblock_array($vars_array, $vars_docblock)
{
- $this->assertNull($this->exporter->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()
@@ -181,7 +199,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock)
{
- $this->exporter->validate_vars_docblock_array('', '', $vars_array, $vars_docblock);
+ $this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock);
}
static public function get_dispatch_name_data()
@@ -199,7 +217,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_dispatch_name($event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->get_dispatch_name('', $event_line));
+ $this->assertEquals($expected, $this->exporter->get_dispatch_name($event_line));
}
static public function get_dispatch_name_throws_data()
@@ -218,7 +236,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_dispatch_name_throws($event_line)
{
- $this->exporter->get_dispatch_name('', $event_line);
+ $this->exporter->get_dispatch_name($event_line);
}
static public function get_trigger_event_name_data()
@@ -236,7 +254,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_trigger_event_name($event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->get_trigger_event_name('', $event_line));
+ $this->assertEquals($expected, $this->exporter->get_trigger_event_name($event_line));
}
static public function get_trigger_event_name_throws_data()
@@ -259,7 +277,7 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_trigger_event_name_throws($event_line)
{
- $this->exporter->get_trigger_event_name('', $event_line);
+ $this->exporter->get_trigger_event_name($event_line);
}
static public function get_vars_from_array_data()
@@ -293,7 +311,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_array($lines, $event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->get_vars_from_array('', '', $lines, $event_line));
+ $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()
@@ -349,7 +369,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_get_vars_from_array_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->get_vars_from_array('', '', $lines, $event_line);
+
+ $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()
@@ -374,7 +397,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_docblock($lines, $event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->get_vars_from_docblock('', '', $lines, $event_line));
+ $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()
@@ -429,7 +454,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->get_vars_from_docblock('', '', $lines, $event_line);
+
+ $this->exporter->set_current_event('', $event_line);
+ $this->exporter->set_content($lines);
+ $this->exporter->get_vars_from_docblock();
}
static public function find_since_data()
@@ -465,7 +493,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_find_since($lines, $event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->find_since('', '', $lines, $event_line));
+ $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()
@@ -527,7 +557,10 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_find_since_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->find_since('', '', $lines, $event_line);
+
+ $this->exporter->set_current_event('', $event_line);
+ $this->exporter->set_content($lines);
+ $this->exporter->find_since();
}
static public function find_description_data()
@@ -565,7 +598,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
*/
public function test_find_description($lines, $event_line, $expected)
{
- $this->assertEquals($expected, $this->exporter->find_description('', '', $lines, $event_line));
+ $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()
@@ -623,6 +658,9 @@ class phpbb_event_exporter_test extends phpbb_test_case
public function test_find_description_throws($lines, $event_line, $exception_code)
{
$this->setExpectedException('LogicException', '', $exception_code);
- $this->exporter->find_description('', '', $lines, $event_line);
+
+ $this->exporter->set_current_event('', $event_line);
+ $this->exporter->set_content($lines);
+ $this->exporter->find_description();
}
}
diff --git a/tests/event/fixtures/duplicate_event.test b/tests/event/fixtures/duplicate_event.test
new file mode 100644
index 0000000000..f5fa580c2b
--- /dev/null
+++ b/tests/event/fixtures/duplicate_event.test
@@ -0,0 +1,26 @@
+<?php
+
+ /**
+ * Event after the post data has been assigned to the template
+ *
+ * @event duplicate.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
+ * @var array post_row Template block array of the post
+ * @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('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');
diff --git a/tests/event/fixtures/missing_var.test b/tests/event/fixtures/missing_var.test
index 9df6e5b386..7ced5e93dc 100644
--- a/tests/event/fixtures/missing_var.test
+++ b/tests/event/fixtures/missing_var.test
@@ -11,7 +11,6 @@
* @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
- * @var array post_row Template block array of the post
* @since 3.1.0-a3
*/
$vars = array('start', 'current_row_number', 'end', 'row', 'cp_row', 'attachments', 'user_poster_data', 'post_row');