Skip to content

Commit 2e6e85f

Browse files
committed
test Ideas against phpBB 3.3
1 parent ddb9b42 commit 2e6e85f

16 files changed

Lines changed: 79 additions & 117 deletions

.travis.yml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
language: php
2+
dist: xenial
23

34
matrix:
45
include:
5-
- php: 5.5
6+
- php: 7.1
67
env: DB=none;NOTESTS=1
7-
- php: 5.4
8-
env: DB=mysqli #myisam
9-
- php: 5.4
10-
env: DB=mysql
11-
- php: 5.4
8+
- php: 7.1
129
env: DB=mariadb
13-
- php: 5.4
10+
- php: 7.1
1411
env: DB=postgres
15-
- php: 5.5
16-
env: DB=mysqli
17-
- php: 5.6
18-
env: DB=mysqli
19-
- php: 7.0
20-
env: DB=mysqli
2112
- php: 7.1
22-
env: DB=mysqli
13+
env: DB=sqlite3
14+
- php: 7.1
15+
env: DB=mysqli # MyISAM
2316
- php: 7.2
2417
env: DB=mysqli
18+
- php: 7.3
19+
env: DB=mysqli
20+
- php: 7.4snapshot
21+
env: DB=mysqli
2522
- php: nightly
2623
env: DB=mysqli
2724
allow_failures:
@@ -34,15 +31,21 @@ env:
3431
- SNIFF="1" # Should we run code sniffer on your code?
3532
- IMAGE_ICC="1" # Should we run icc profile sniffer on your images?
3633
- EPV="1" # Should we run EPV (Extension Pre Validator) on your code?
37-
- PHPBB_BRANCH="3.2.x"
34+
- PHPBB_BRANCH="3.3.x"
3835

3936
branches:
4037
only:
4138
- master
39+
- develop
40+
- /^develop-.*$/
4241
- /^\d+(\.\d+)?\.x$/
4342

43+
services:
44+
- postgresql
45+
- mysql
46+
4447
install:
45-
- travis/prepare-phpbb.sh $EXTNAME $PHPBB_BRANCH
48+
- travis/prepare-phpbb.sh $PHPBB_BRANCH
4649
- cd ../../phpBB3
4750
- travis/prepare-extension.sh $EXTNAME $PHPBB_BRANCH
4851
- travis/setup-phpbb.sh $DB $TRAVIS_PHP_VERSION $NOTESTS

phpunit.xml.dist

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,20 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
verbose="true"
1312
bootstrap="../../../../tests/bootstrap.php"
1413
>
1514
<testsuites>
1615
<testsuite name="Extension Test Suite">
1716
<directory suffix="_test.php">./tests</directory>
1817
<exclude>./tests/functional</exclude>
19-
<exclude>./tests/ui</exclude>
2018
</testsuite>
2119
<testsuite name="Extension Functional Tests">
22-
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">./tests/functional/</directory>
23-
</testsuite>
24-
<testsuite name="Extension UI Tests">
25-
<directory suffix="_test.php" phpVersion="5.3.19" phpVersionOperator=">=">./tests/ui/</directory>
20+
<directory suffix="_test.php">./tests/functional/</directory>
2621
</testsuite>
2722
</testsuites>
2823

2924
<filter>
30-
<blacklist>
31-
<directory>./tests/</directory>
32-
</blacklist>
3325
<whitelist processUncoveredFilesFromWhitelist="true">
3426
<directory suffix=".php">./</directory>
3527
<exclude>

tests/controller/controller_base.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,25 @@ public function setUp()
6464
$this->controller_helper = $this->getMockBuilder('\phpbb\controller\helper')
6565
->disableOriginalConstructor()
6666
->getMock();
67-
$this->controller_helper->expects($this->any())
67+
$this->controller_helper->expects($this->atMost(1))
6868
->method('render')
6969
->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) {
7070
return new \Symfony\Component\HttpFoundation\Response($template_file, $status_code);
7171
});
7272
$this->ideas = $this->getMockBuilder('\phpbb\ideas\factory\ideas')
7373
->disableOriginalConstructor()
7474
->getMock();
75-
$this->ideas->expects($this->any())
75+
$this->ideas->expects($this->atMost(3))
7676
->method('get_ideas')
77-
->will($this->returnValue(array(array())));
77+
->willReturn(array(array()));
7878
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
7979
$this->lang = new \phpbb\language\language($lang_loader);
8080
$this->link_helper = $this->getMockBuilder('\phpbb\ideas\factory\linkhelper')
8181
->disableOriginalConstructor()
8282
->getMock();
83-
$this->link_helper->expects($this->any())
83+
$this->link_helper->expects($this->atMost(3))
8484
->method('get_list_link')
85-
->will($this->returnValue(''));
85+
->willReturn('');
8686
$this->pagination = $this->getMockBuilder('\phpbb\pagination')
8787
->disableOriginalConstructor()
8888
->getMock();

tests/controller/idea_controller_test.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,48 +57,47 @@ public function controller_test_data()
5757
public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorised, $expected, $status_code, $additional_data = [])
5858
{
5959
// mock some basic idea data
60-
$this->ideas->expects($this->any())
60+
$this->ideas->expects($this->once())
6161
->method('get_idea')
62-
->will($this->returnValue(
63-
array_merge(array(
64-
'idea_id' => $idea_id,
65-
'idea_author' => 2,
66-
'idea_status' => \phpbb\ideas\factory\ideas::$statuses['NEW']
67-
), $additional_data))
62+
->willReturn(array_merge(array(
63+
'idea_id' => $idea_id,
64+
'idea_author' => 2,
65+
'idea_status' => \phpbb\ideas\factory\ideas::$statuses['NEW']
66+
), $additional_data)
6867
);
6968

7069
// mock a result from each method called by the idea controller
7170
if ($expected === 'true')
7271
{
7372
$this->ideas->expects($this->once())
7473
->method(($callback))
75-
->will($this->returnValue($authorised));
74+
->willReturn($authorised);
7675
}
7776

7877
// set if using ajax or not
79-
$this->request->expects($this->any())
78+
$this->request->expects($is_ajax ? $this->once() : $this->never())
8079
->method('is_ajax')
81-
->will($this->returnValue($is_ajax));
80+
->willReturn($is_ajax);
8281

8382
// mock some useful variables requested by the idea controller
84-
$this->request->expects($this->any())
83+
$this->request->expects($this->atLeastOnce())
8584
->method('variable')
8685
->with($this->anything())
87-
->will($this->returnValueMap(array(
86+
->willReturnMap(array(
8887
array('mode', '', false, \phpbb\request\request_interface::REQUEST, $mode),
8988
array('hash', '', false, \phpbb\request\request_interface::REQUEST, generate_link_hash("{$mode}_{$idea_id}")),
9089
array('status', 0, false, \phpbb\request\request_interface::REQUEST, 1),
9190
array('v', 1, false, \phpbb\request\request_interface::REQUEST, 1),
92-
)));
91+
));
9392

9493
// mock some user permissions during testing
95-
$this->auth->expects($this->any())
94+
$this->auth
9695
->method('acl_get')
9796
->with($this->stringContains('_'), $this->anything())
98-
->will($this->returnValueMap(array(
97+
->willReturnMap(array(
9998
array('m_', 2, $authorised),
10099
array('f_vote', 2, $authorised),
101-
)));
100+
));
102101

103102
// special case, expect trigger_error when a confirm_box return true
104103
if ($expected === 'trigger_error')
@@ -109,7 +108,8 @@ public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorise
109108

110109
if ($status_code === 403)
111110
{
112-
$this->setExpectedException('\phpbb\exception\http_exception', 'NO_AUTH_OPERATION');
111+
$this->expectException('\phpbb\exception\http_exception');
112+
$this->expectExceptionMessage('NO_AUTH_OPERATION');
113113
}
114114

115115
/** @var \phpbb\ideas\controller\idea_controller $controller */

tests/controller/list_controller_test.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ public function controller_test_data()
150150
*/
151151
public function test_controller($status_code, $page_content, $params, $expected)
152152
{
153-
$this->request->expects($this->any())
153+
$this->request->expects($this->atMost(3))
154154
->method('variable')
155-
->will($this->returnValueMap(array(
155+
->willReturnMap(array(
156156
array('sd', 'd', false, \phpbb\request\request_interface::REQUEST, ''),
157157
array('status', 0, false, \phpbb\request\request_interface::REQUEST, $params['status']),
158158
array('start', 0, false, \phpbb\request\request_interface::REQUEST, 0),
159-
)));
159+
));
160160

161-
$this->ideas->expects($this->any())
161+
$this->ideas->expects($this->once())
162162
->method('get_ideas')
163163
->with('', $expected['sort'], 'ASC', $expected['status'], 0);
164164

tests/controller/post_controller_test.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,29 @@ public function test_post_success($is_newly_registered_user)
120120

121121
$this->controller_helper->expects($this->once())
122122
->method('route')
123-
->will($this->returnValue('phpbb_ideas_idea_controller'));
123+
->willReturn('phpbb_ideas_idea_controller');
124124

125125
$this->request->expects($this->once())
126126
->method('is_set_post')
127-
->will($this->returnValueMap(array(
127+
->willReturnMap(array(
128128
array('post', true),
129-
)));
129+
));
130130

131131
$this->auth->expects($this->once())
132132
->method('acl_get')
133133
->with('f_noapprove', $this->config['ideas_forum_id'])
134-
->will($this->returnValue(!$is_newly_registered_user));
134+
->willReturn(!$is_newly_registered_user);
135135

136136
if ($is_newly_registered_user)
137137
{
138-
$this->setExpectedException('\phpbb\exception\http_exception', 'IDEA_STORED_MOD');
138+
$this->expectException('\phpbb\exception\http_exception');
139+
$this->expectExceptionMessage('IDEA_STORED_MOD');
139140
}
140141

141142
// ideas->submit() will return an idea id on successful submit
142143
$this->ideas->expects($this->once())
143144
->method('submit')
144-
->will($this->returnValue(1));
145+
->willReturn(1);
145146

146147
$response = $controller->post();
147148
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\RedirectResponse', $response);
@@ -156,19 +157,19 @@ public function test_preview()
156157
$controller = $this->get_controller('post_controller');
157158
$this->assertInstanceOf('phpbb\ideas\controller\post_controller', $controller);
158159

159-
$this->request->expects($this->any())
160+
$this->request->expects($this->atLeastOnce())
160161
->method('is_set_post')
161-
->will($this->returnValueMap(array(
162+
->willReturnMap(array(
162163
array('post', false),
163164
array('preview', true),
164-
)));
165+
));
165166

166167
$this->request->expects($this->atLeastOnce())
167168
->method('variable')
168-
->will($this->returnValueMap(array(
169+
->willReturnMap(array(
169170
array('title', '', true, \phpbb\request\request_interface::REQUEST, 'test title'),
170171
array('message', '', true, \phpbb\request\request_interface::REQUEST, 'test message'),
171-
)));
172+
));
172173

173174
$this->ideas->expects($this->never())
174175
->method('submit');
@@ -199,22 +200,22 @@ public function test_submit_errors()
199200

200201
$this->request->expects($this->atLeastOnce())
201202
->method('is_set_post')
202-
->will($this->returnValueMap(array(
203+
->willReturnMap(array(
203204
array('post', true),
204205
array('preview', false),
205-
)));
206+
));
206207

207208
$this->request->expects($this->atLeastOnce())
208209
->method('variable')
209-
->will($this->returnValueMap(array(
210+
->willReturnMap(array(
210211
array('title', '', true, \phpbb\request\request_interface::REQUEST, 'test title'),
211212
array('message', '', true, \phpbb\request\request_interface::REQUEST, 'test message'),
212-
)));
213+
));
213214

214215
// ideas->submit() will return an array of error messages on submit error
215216
$this->ideas->expects($this->once())
216217
->method('submit')
217-
->will($this->returnValue(array('error1', 'error2')));
218+
->willReturn(array('error1', 'error2'));
218219

219220
$this->template->expects($this->at(0))
220221
->method('assign_vars')

tests/event/listener_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function setUp()
5656
$this->helper = $this->getMockBuilder('\phpbb\controller\helper')
5757
->disableOriginalConstructor()
5858
->getMock();
59-
$this->helper->expects($this->any())
59+
$this->helper->expects($this->atMost(1))
6060
->method('route')
6161
->willReturnCallback(function ($route, array $params = array()) {
6262
return $route . '#' . serialize($params);

tests/factory/linkhelper_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function getDataSet()
3131
return $this->createXMLDataSet(__DIR__ . '/../fixtures/ideas.xml');
3232
}
3333

34-
public function setUp()
34+
public function setUp(): void
3535
{
3636
parent::setUp();
3737

@@ -41,7 +41,7 @@ public function setUp()
4141
$this->helper = $this->getMockBuilder('\phpbb\controller\helper')
4242
->disableOriginalConstructor()
4343
->getMock();
44-
$this->helper->expects($this->any())
44+
$this->helper->expects($this->atMost(3))
4545
->method('route')
4646
->willReturnCallback(function ($route, array $params = array()) {
4747
return $route . '#' . json_encode($params);
@@ -52,12 +52,12 @@ public function setUp()
5252
$auth = $this->getMockBuilder('\phpbb\auth\auth')
5353
->disableOriginalConstructor()
5454
->getMock();
55-
$auth->expects($this->any())
55+
$auth
5656
->method('acl_get')
5757
->with($this->stringContains('_'), $this->anything())
58-
->will($this->returnValueMap(array(
58+
->willReturnMap(array(
5959
array('u_viewprofile', true),
60-
)));
60+
));
6161
$user->data['user_id'] = ANONYMOUS;
6262
}
6363

tests/functional/ideas_functional_base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static protected function setup_extensions()
2525
return array('phpbb/ideas');
2626
}
2727

28-
public function setUp()
28+
public function setUp(): void
2929
{
3030
parent::setUp();
3131
$this->enable_ideas();

tests/ideas/get_ideas_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ public function get_ideas_data()
266266
*/
267267
public function test_get_ideas_permissions($is_mod, $expected)
268268
{
269-
$this->auth->expects($this->any())
269+
$this->auth
270270
->method('acl_get')
271271
->with('m_', $this->config['ideas_forum_id'])
272-
->will($this->returnValue($is_mod));
272+
->willReturn($is_mod);
273273

274274
$ideas = $this->get_ideas_object();
275275

0 commit comments

Comments
 (0)