Skip to content

Commit 0c52aa9

Browse files
committed
fix error with phpunit10 (undefined method setMethods())
Was removed in phpunit10 Error: Call to undefined method PHPUnit\Framework\MockObject\MockBuilder::setMethods()
1 parent 43621f2 commit 0c52aa9

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

tests/codeigniter/core/Loader_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function test_load_view()
322322
$this->assertEquals($content.'undefined', $out);
323323

324324
// Mock output class
325-
$output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock();
325+
$output = $this->getMockBuilder('CI_Output')->onlyMethods(array('append_output'))->getMock();
326326
$output->expects($this->once())->method('append_output')->with($content.$value);
327327
$this->ci_instance_var('output', $output);
328328

@@ -483,7 +483,7 @@ public function test_language()
483483
{
484484
// Mock lang class and test load call
485485
$file = 'test';
486-
$lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
486+
$lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('load'))->getMock();
487487
$lang->expects($this->once())->method('load')->with($file);
488488
$this->ci_instance_var('lang', $lang);
489489
$this->assertInstanceOf('CI_Loader', $this->load->language($file));

tests/codeigniter/helpers/language_helper_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Language_helper_test extends CI_TestCase {
55
public function test_lang()
66
{
77
$this->helper('language');
8-
$lang = $this->getMockBuilder('CI_Lang')->setMethods(array('line'))->getMock();
8+
$lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('line'))->getMock();
99
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
1010
$this->ci_instance_var('lang', $lang);
1111

tests/codeigniter/helpers/number_helper_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function set_up()
1111

1212
// Mock away load, too much going on in there,
1313
// we'll just check for the expected parameter
14-
$lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
14+
$lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('load'))->getMock();
1515
$lang->expects($this->once())
1616
->method('load')
1717
->with($this->equalTo('number'));

tests/codeigniter/libraries/Calendar_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ class Calendar_test extends CI_TestCase {
55
public function set_up()
66
{
77
// Required for get_total_days()
8-
$this->ci_instance_var('load', $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock());
8+
$this->ci_instance_var('load', $this->getMockBuilder('CI_Loader')->onlyMethods(array('helper'))->getMock());
99

10-
$lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
10+
$lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('load', 'line'))->getMock();
1111
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
1212
$this->ci_instance_var('lang', $lang);
1313

tests/codeigniter/libraries/Driver_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function set_up()
1818

1919
// Mock Loader->get_package_paths
2020
$paths = 'get_package_paths';
21-
$ldr = $this->getMockBuilder('CI_Loader')->setMethods(array($paths))->getMock();
21+
$ldr = $this->getMockBuilder('CI_Loader')->onlyMethods(array($paths))->getMock();
2222
$ldr->expects($this->any())->method($paths)->will($this->returnValue(array(APPPATH, BASEPATH)));
2323
$this->ci_instance_var('load', $ldr);
2424

tests/codeigniter/libraries/Form_validation_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ public function set_up()
88

99
// Create a mock loader since load->helper() looks in the wrong directories for unit tests,
1010
// We'll use CI_TestCase->helper() instead
11-
$loader = $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock();
11+
$loader = $this->getMockBuilder('CI_Loader')->onlyMethods(array('helper'))->getMock();
1212

1313
// Same applies for lang
14-
$lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
14+
$lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('load'))->getMock();
1515

1616
$security = new Mock_Core_Security('UTF-8');
1717
$input = new CI_Input($security);

tests/codeigniter/libraries/Upload_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public function set_up()
77
$ci = $this->ci_instance();
88
$ci->upload = new CI_Upload();
99
$ci->security = new Mock_Core_Security('UTF-8');
10-
$ci->lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
10+
$ci->lang = $this->getMockBuilder('CI_Lang')->onlyMethods(array('load', 'line'))->getMock();
1111
$ci->lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
1212
$this->upload = $ci->upload;
1313
}

0 commit comments

Comments
 (0)