Skip to content

Commit d7c249d

Browse files
committed
A little test coverage improvement
1 parent 2e90f10 commit d7c249d

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

tests/controller/idea_controller_test.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ public function controller_test_data()
2828
array(2, 'delete', 'delete', true, true, 'trigger_error', 200), // ajax delete success (confirm true)
2929
array(3, 'duplicate', 'set_duplicate', true, true, 'true', 200), // ajax set duplicate success
3030
array(3, 'duplicate', '', true, false, 'false', 200), // ajax set duplicate fail
31-
array(4, 'removevote', 'remove_vote', true, true, 'true', 200), // ajax set title success
32-
array(4, 'removevote', '', true, false, '"You do not have the necessary permissions to complete this operation."', 200), // ajax set title fail
31+
array(4, 'removevote', 'remove_vote', true, true, 'true', 200), // ajax remove vote success
32+
array(4, 'removevote', 'remove_vote', true, true, 'false', 200, ['idea_status' => \phpbb\ideas\factory\ideas::$statuses['DUPLICATE']]), // ajax remove vote not allowed
33+
array(4, 'removevote', 'remove_vote', true, true, 'false', 200, ['idea_status' => \phpbb\ideas\factory\ideas::$statuses['IMPLEMENTED']]), // ajax remove vote not allowed
34+
array(4, 'removevote', '', true, false, '"You do not have the necessary permissions to complete this operation."', 200), // ajax remove vote fail
3335
array(5, 'rfc', 'set_rfc', true, true, 'true', 200), // ajax set rfc success
3436
array(5, 'rfc', '', true, false, 'false', 200), // ajax set rfc fail
3537
array(6, 'status', 'change_status', true, true, 'true', 200), // ajax set status success
@@ -38,8 +40,10 @@ public function controller_test_data()
3840
array(7, 'ticket', '', true, false, 'false', 200), // ajax set ticket fail
3941
array(8, 'title', 'set_title', true, true, 'true', 200), // ajax set title success
4042
array(8, 'title', '', true, false, 'false', 200), // ajax set title fail
41-
array(9, 'vote', 'vote', true, true, 'true', 200), // ajax set title success
42-
array(9, 'vote', '', true, false, '"You do not have the necessary permissions to complete this operation."', 200), // ajax set title fail
43+
array(9, 'vote', 'vote', true, true, 'true', 200), // ajax vote success
44+
array(9, 'vote', 'vote', true, true, 'false', 200, ['idea_status' => \phpbb\ideas\factory\ideas::$statuses['DUPLICATE']]), // ajax vote not allowed
45+
array(9, 'vote', 'vote', true, true, 'false', 200, ['idea_status' => \phpbb\ideas\factory\ideas::$statuses['IMPLEMENTED']]), // ajax vote not allowed
46+
array(9, 'vote', '', true, false, '"You do not have the necessary permissions to complete this operation."', 200), // ajax vote fail
4347
array(10, 'implemented', 'set_implemented', true, true, 'true', 200), // ajax set implemented success
4448
array(10, 'implemented', '', true, false, 'false', 200), // ajax set implemented fail
4549
);
@@ -50,15 +54,21 @@ public function controller_test_data()
5054
*
5155
* @dataProvider controller_test_data
5256
*/
53-
public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorised, $expected, $status_code)
57+
public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorised, $expected, $status_code, $additional_data = [])
5458
{
5559
// mock some basic idea data
5660
$this->ideas->expects($this->any())
5761
->method('get_idea')
58-
->will($this->returnValue(array('idea_id' => $idea_id, 'idea_author' => 2)));
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))
68+
);
5969

6070
// mock a result from each method called by the idea controller
61-
if ($callback !== '')
71+
if ($expected === 'true')
6272
{
6373
$this->ideas->expects($this->once())
6474
->method(($callback))

0 commit comments

Comments
 (0)