Skip to content

Commit 6318c87

Browse files
committed
Merge pull request #42 from VSEphpbb/test-updates
Update unit tests
2 parents b4fcb82 + 8534107 commit 6318c87

3 files changed

Lines changed: 10 additions & 123 deletions

File tree

tests/event/listener_test.php

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ class event_listener_test extends \phpbb_test_case
1717
/** @var \phpbb\googleanalytics\event\listener */
1818
protected $listener;
1919

20+
protected $config;
21+
protected $template;
22+
protected $user;
23+
2024
/**
2125
* Setup test environment
22-
*
23-
* @access public
2426
*/
2527
public function setUp()
2628
{
@@ -34,14 +36,13 @@ public function setUp()
3436

3537
// Load/Mock classes required by the event listener class
3638
$this->config = new \phpbb\config\config(array('googleanalytics_id' => 'UA-000000-01'));
37-
$this->template = new \phpbb\googleanalytics\tests\mock\template();
39+
$this->template = $this->getMockBuilder('\phpbb\template\template')
40+
->getMock();
3841
$this->user = new \phpbb\user('\phpbb\datetime');
3942
}
4043

4144
/**
4245
* Create our event listener
43-
*
44-
* @access protected
4546
*/
4647
protected function set_listener()
4748
{
@@ -54,8 +55,6 @@ protected function set_listener()
5455

5556
/**
5657
* Test the event listener is constructed correctly
57-
*
58-
* @access public
5958
*/
6059
public function test_construct()
6160
{
@@ -65,8 +64,6 @@ public function test_construct()
6564

6665
/**
6766
* Test the event listener is subscribing events
68-
*
69-
* @access public
7067
*/
7168
public function test_getSubscribedEvents()
7269
{
@@ -79,27 +76,24 @@ public function test_getSubscribedEvents()
7976

8077
/**
8178
* Test the load_google_analytics event
82-
*
83-
* @access public
8479
*/
8580
public function test_load_google_analytics()
8681
{
8782
$this->set_listener();
8883

84+
$this->template->expects($this->once())
85+
->method('assign_var')
86+
->with('GOOGLEANALYTICS_ID', $this->config['googleanalytics_id']);
87+
8988
$dispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
9089
$dispatcher->addListener('core.page_header', array($this->listener, 'load_google_analytics'));
9190
$dispatcher->dispatch('core.page_header');
92-
93-
$this->assertEquals(array(
94-
'GOOGLEANALYTICS_ID' => $this->config['googleanalytics_id'],
95-
), $this->template->get_template_vars());
9691
}
9792

9893
/**
9994
* Data set for test_add_googleanalytics_configs
10095
*
10196
* @return array Array of test data
102-
* @access public
10397
*/
10498
public function add_googleanalytics_configs_data()
10599
{
@@ -131,7 +125,6 @@ public function add_googleanalytics_configs_data()
131125
* Test the add_googleanalytics_configs event
132126
*
133127
* @dataProvider add_googleanalytics_configs_data
134-
* @access public
135128
*/
136129
public function test_add_googleanalytics_configs($mode, $display_vars, $expected_keys)
137130
{
@@ -160,7 +153,6 @@ public function test_add_googleanalytics_configs($mode, $display_vars, $expected
160153
* Data set for test_validate_googleanalytics_id
161154
*
162155
* @return array Array of test data
163-
* @access public
164156
*/
165157
public function validate_googleanalytics_id_data()
166158
{
@@ -202,7 +194,6 @@ public function validate_googleanalytics_id_data()
202194
* Test the validate_googleanalytics_id event
203195
*
204196
* @dataProvider validate_googleanalytics_id_data
205-
* @access public
206197
*/
207198
public function test_validate_googleanalytics_id($cfg_array, $expected_error)
208199
{

tests/functional/google_analytics_test.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class google_analytics_test extends \phpbb_functional_test_case
2121
* Define the extensions to be tested
2222
*
2323
* @return array vendor/name of extension(s) to test
24-
* @access static
2524
*/
2625
static protected function setup_extensions()
2726
{
@@ -30,8 +29,6 @@ static protected function setup_extensions()
3029

3130
/**
3231
* Test Google Analytics ACP page and save settings
33-
*
34-
* @access public
3532
*/
3633
public function test_set_acp_settings()
3734
{
@@ -80,8 +77,6 @@ public function test_set_acp_settings()
8077

8178
/**
8279
* Test Google Analytics code appears as expected
83-
*
84-
* @access public
8580
*/
8681
public function test_google_analytics_code()
8782
{

tests/mock/template.php

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)