From eee950be9b2cc214f04cc65f293e584397ebf0f6 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 5 May 2018 16:16:13 +1000 Subject: [PATCH] (NFC) Change getMock to createMock in tests to fix deprecated warning on getMock in phpunit5 --- .../CRM/Core/CommunityMessagesTest.php | 4 +-- tests/phpunit/CRM/Core/JobManagerTest.php | 2 +- tests/phpunit/CRM/Extension/ManagerTest.php | 28 +++++++++---------- tests/phpunit/api/v3/ContactTest.php | 4 +-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/tests/phpunit/CRM/Core/CommunityMessagesTest.php b/tests/phpunit/CRM/Core/CommunityMessagesTest.php index 0ce30a66ab..0732ad1f9d 100644 --- a/tests/phpunit/CRM/Core/CommunityMessagesTest.php +++ b/tests/phpunit/CRM/Core/CommunityMessagesTest.php @@ -377,7 +377,7 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { * @return CRM_Utils_HttpClient|PHPUnit_Framework_MockObject_MockObject */ protected function expectNoHttpRequest() { - $client = $this->getMock('CRM_Utils_HttpClient'); + $client = $this->createMock('CRM_Utils_HttpClient'); $client->expects($this->never()) ->method('get'); return $client; @@ -391,7 +391,7 @@ class CRM_Core_CommunityMessagesTest extends CiviUnitTestCase { * @return CRM_Utils_HttpClient|PHPUnit_Framework_MockObject_MockObject */ protected function expectOneHttpRequest($response) { - $client = $this->getMock('CRM_Utils_HttpClient'); + $client = $this->createMock('CRM_Utils_HttpClient'); $client->expects($this->once()) ->method('get') ->will($this->returnValue($response)); diff --git a/tests/phpunit/CRM/Core/JobManagerTest.php b/tests/phpunit/CRM/Core/JobManagerTest.php index f67aa2635e..3b5453fd3b 100644 --- a/tests/phpunit/CRM/Core/JobManagerTest.php +++ b/tests/phpunit/CRM/Core/JobManagerTest.php @@ -36,7 +36,7 @@ class CRM_Core_JobManagerTest extends CiviUnitTestCase { } public function testHookCron() { - $hook = $this->getMock('stdClass', array('civicrm_cron')); + $hook = $this->createMock('stdClass', array('civicrm_cron')); $hook->expects($this->once()) ->method('civicrm_cron') ->with($this->isInstanceOf('CRM_Core_JobManager')); diff --git a/tests/phpunit/CRM/Extension/ManagerTest.php b/tests/phpunit/CRM/Extension/ManagerTest.php index ece4e8bf5d..419d48756c 100644 --- a/tests/phpunit/CRM/Extension/ManagerTest.php +++ b/tests/phpunit/CRM/Extension/ManagerTest.php @@ -49,7 +49,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * @expectedException CRM_Extension_Exception */ public function testInstallInvalidType() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $testingTypeManager->expects($this->never()) ->method('onPreInstall'); $manager = $this->_createManager(array( @@ -66,7 +66,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * "the first row" or "all rows". */ public function testInstall_Disable_Uninstall() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -110,7 +110,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * @throws \CRM_Extension_Exception */ public function test_InstallAuto_DisableDownstream_UninstallDownstream() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -151,7 +151,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * @throws \CRM_Extension_Exception */ public function testInstallAuto_Twice() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -180,7 +180,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { } public function test_InstallAuto_DisableUpstream() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -223,7 +223,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Subseuently disable and uninstall. */ public function testInstall_DirtyRemove_Disable_Uninstall() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -261,7 +261,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Install an extension with a valid type name. */ public function testInstall_Disable_Enable() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -303,7 +303,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Performing 'install' on a 'disabled' extension performs an 'enable' */ public function testInstall_Disable_Install() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -341,7 +341,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Install an extension with a valid type name. */ public function testEnableBare() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -367,7 +367,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Get the status of an unknown extension. */ public function testStatusUnknownKey() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $testingTypeManager->expects($this->never()) ->method('onPreInstall'); $manager = $this->_createManager(array( @@ -380,7 +380,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Replace code for an extension that doesn't exist in the container */ public function testReplace_Unknown() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -406,7 +406,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * Replace code for an extension that doesn't exist in the container */ public function testReplace_Uninstalled() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -437,7 +437,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * file="oddball", and the upgrade has file="newextension". */ public function testReplace_Installed() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); @@ -474,7 +474,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase { * file="oddball", and the upgrade has file="newextension". */ public function testReplace_InstalledMissing() { - $testingTypeManager = $this->getMock('CRM_Extension_Manager_Interface'); + $testingTypeManager = $this->createMock('CRM_Extension_Manager_Interface'); $manager = $this->_createManager(array( self::TESTING_TYPE => $testingTypeManager, )); diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index e7a714b6d6..fb2e19c7ee 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -2036,7 +2036,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { $this->assertTrue(is_numeric($ufMatch->id)); // setup - mock the calls to CRM_Utils_System_*::getUfId - $userSystem = $this->getMock('CRM_Utils_System_UnitTests', array('getUfId')); + $userSystem = $this->createMock('CRM_Utils_System_UnitTests', array('getUfId')); $userSystem->expects($this->once()) ->method('getUfId') ->with($this->equalTo('exampleUser')) @@ -2111,7 +2111,7 @@ class api_v3_ContactTest extends CiviUnitTestCase { */ public function testContactGetByUnknownUsername() { // setup - mock the calls to CRM_Utils_System_*::getUfId - $userSystem = $this->getMock('CRM_Utils_System_UnitTests', array('getUfId')); + $userSystem = $this->createMock('CRM_Utils_System_UnitTests', array('getUfId')); $userSystem->expects($this->once()) ->method('getUfId') ->with($this->equalTo('exampleUser')) -- 2.25.1