Skip to content

Commit 2e90f10

Browse files
authored
Merge pull request #103 from VSEphpbb/tests
Replace deprecated getMock()
2 parents a4cae64 + 10a7478 commit 2e90f10

6 files changed

Lines changed: 42 additions & 16 deletions

File tree

tests/controller/controller_base.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public function setUp()
5757
$phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
5858

5959
// Constructor arguments
60-
$this->auth = $this->getMock('\phpbb\auth\auth');
60+
$this->auth = $this->getMockBuilder('\phpbb\auth\auth')
61+
->disableOriginalConstructor()
62+
->getMock();
6163
$this->config = new \phpbb\config\config(array('ideas_forum_id' => 2, 'ideas_poster_id' => 2));
6264
$this->controller_helper = $this->getMockBuilder('\phpbb\controller\helper')
6365
->disableOriginalConstructor()
@@ -84,10 +86,17 @@ public function setUp()
8486
$this->pagination = $this->getMockBuilder('\phpbb\pagination')
8587
->disableOriginalConstructor()
8688
->getMock();
87-
$this->request = $request = $this->getMock('\phpbb\request\request');
89+
$this->request = $request = $this->getMockBuilder('\phpbb\request\request')
90+
->disableOriginalConstructor()
91+
->getMock();
8892
$this->template = $this->getMockBuilder('\phpbb\template\template')
8993
->getMock();
90-
$this->user = $this->getMock('\phpbb\user', array(), array($this->lang, '\phpbb\datetime'));
94+
$this->user = $this->getMockBuilder('\phpbb\user')
95+
->setConstructorArgs(array(
96+
$this->lang,
97+
'\phpbb\datetime'
98+
))
99+
->getMock();
91100
$this->root_path = $phpbb_root_path;
92101
$this->php_ext = $phpEx;
93102
}

tests/controller/idea_controller_test.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ public function test_controller($idea_id, $mode, $callback, $is_ajax, $authorise
5858
->will($this->returnValue(array('idea_id' => $idea_id, 'idea_author' => 2)));
5959

6060
// mock a result from each method called by the idea controller
61-
$this->ideas->expects(($callback !== '' ? $this->once() : $this->never()))
62-
->method($callback)
63-
->will($this->returnValue($authorised));
61+
if ($callback !== '')
62+
{
63+
$this->ideas->expects($this->once())
64+
->method(($callback))
65+
->will($this->returnValue($authorised));
66+
}
6467

6568
// set if using ajax or not
6669
$this->request->expects($this->any())

tests/controller/post_controller_test.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ public function setUp()
1717
parent::setUp();
1818

1919
global $db, $phpbb_container;
20-
$db = $this->getMock('\phpbb\db\driver\driver_interface');
21-
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
20+
$db = $this->getMockBuilder('\phpbb\db\driver\driver_interface')
21+
->disableOriginalConstructor()
22+
->getMock();
23+
$phpbb_container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')
24+
->disableOriginalConstructor()
25+
->getMock();
2226
}
2327

2428
/**

tests/event/listener_test.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public function setUp()
4949
global $phpbb_root_path, $phpEx;
5050

5151
// Load/Mock classes required by the event listener class
52-
$this->auth = $this->getMock('\phpbb\auth\auth');
52+
$this->auth = $this->getMockBuilder('\phpbb\auth\auth')
53+
->disableOriginalConstructor()
54+
->getMock();
5355
$this->config = new \phpbb\config\config(array('ideas_forum_id' => 2, 'ideas_poster_id' => 2));
5456
$this->helper = $this->getMockBuilder('\phpbb\controller\helper')
5557
->disableOriginalConstructor()

tests/factory/linkhelper_test.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public function setUp()
4949
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
5050

5151
$phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
52-
$auth = $this->getMock('\phpbb\auth\auth');
52+
$auth = $this->getMockBuilder('\phpbb\auth\auth')
53+
->disableOriginalConstructor()
54+
->getMock();
5355
$auth->expects($this->any())
5456
->method('acl_get')
5557
->with($this->stringContains('_'), $this->anything())

tests/ideas/ideas_base.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ public function setUp()
4646

4747
global $auth, $config, $db, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request;
4848

49-
$this->auth = $auth = $this->getMock('\phpbb\auth\auth');
49+
$this->auth = $auth = $this->getMockBuilder('\phpbb\auth\auth')
50+
->disableOriginalConstructor()
51+
->getMock();
5052
$this->config = $config = new \phpbb\config\config(array(
5153
'posts_per_page' => 10,
5254
'ideas_forum_id' => 2,
@@ -56,12 +58,16 @@ public function setUp()
5658
$phpbb_dispatcher = new \phpbb_mock_event_dispatcher();
5759
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
5860
$this->lang = new \phpbb\language\language($lang_loader);
59-
$this->user = $this->getMock('\phpbb\user', array(), array(
60-
$this->lang,
61-
'\phpbb\datetime'
62-
));
61+
$this->user = $this->getMockBuilder('\phpbb\user')
62+
->setConstructorArgs(array(
63+
$this->lang,
64+
'\phpbb\datetime'
65+
))
66+
->getMock();
6367
$this->php_ext = $phpEx;
64-
$request = $this->getMock('\phpbb\request\request');
68+
$request = $this->getMockBuilder('\phpbb\request\request')
69+
->disableOriginalConstructor()
70+
->getMock();
6571
}
6672

6773
/**

0 commit comments

Comments
 (0)