Fix deprecated usage of getMock in unit tests

This commit is contained in:
Daniel Hensby 2017-11-24 14:30:47 +00:00
parent 79bba8bfd1
commit 09a003bc13
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
5 changed files with 16 additions and 18 deletions

View File

@ -30,13 +30,10 @@ class ConfigManifestTest extends SapphireTest {
* @return Zend_Cache_Core
*/
protected function getCacheMock() {
return $this->getMock(
'Zend_Cache_Core',
array('load', 'save'),
array(),
'',
false
);
return $this->getMockBuilder('Zend_Cache_Core')
->setMethods(array('load', 'save'))
->disableOriginalConstructor()
->getMock();
}
/**
@ -45,13 +42,10 @@ class ConfigManifestTest extends SapphireTest {
* @return SS_ConfigManifest
*/
protected function getManifestMock($methods) {
return $this->getMock(
'SS_ConfigManifest',
$methods,
array(), // no constructor arguments
'', // default
false // don't call the constructor
);
return $this->getMockBuilder('SS_ConfigManifest')
->setMethods($methods)
->disableOriginalConstructor()
->getMock();
}
/**

View File

@ -605,7 +605,7 @@ class InjectorTest extends SapphireTest {
'service' => array('factory' => 'factory', 'constructor' => array(1, 2, 3))
));
$factory = $this->getMock('SilverStripe\\Framework\\Injector\\Factory');
$factory = $this->getMockBuilder('SilverStripe\\Framework\\Injector\\Factory')->getMock();
$factory
->expects($this->once())
->method('create')

View File

@ -43,7 +43,7 @@ class PaginatedListTest extends SapphireTest {
}
public function testSetPaginationFromQuery() {
$query = $this->getMock('SQLQuery');
$query = $this->getMockBuilder('SQLQuery')->getMock();
$query->expects($this->once())
->method('getLimit')
->will($this->returnValue(array('limit' => 15, 'start' => 30)));

View File

@ -277,7 +277,9 @@ class ShortcodeParserTest extends SapphireTest {
}
public function testNoParseAttemptIfNoCode() {
$stub = $this->getMock('ShortcodeParser', array('replaceElementTagsWithMarkers'));
$stub = $this->getMockBuilder('ShortcodeParser')
->setMethods(array('replaceElementTagsWithMarkers'))
->getMock();
$stub->register('test', function() {
return '';
});

View File

@ -138,7 +138,9 @@ class SSViewerTest extends SapphireTest {
}
public function testRequirements() {
$requirements = $this->getMock("Requirements_Backend", array("javascript", "css"));
$requirements = $this->getMockBuilder("Requirements_Backend")
->setMethods(array("javascript", "css"))
->getMock();
$jsFile = FRAMEWORK_DIR . '/tests/forms/a.js';
$cssFile = FRAMEWORK_DIR . '/tests/forms/a.js';