From dff108e97bea1d1b6e6a639fabd64d400acd4347 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 2 May 2016 10:58:44 +0200 Subject: [PATCH] fix mock builder for old phpunit versions --- tests/core/controller/TokenControllerTest.php | 8 ++++++-- .../token/defaulttokencleanupjobtest.php | 4 +++- .../token/defaulttokenprovidertest.php | 12 +++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/tests/core/controller/TokenControllerTest.php b/tests/core/controller/TokenControllerTest.php index 11ba3bc0532..4635f96f48f 100644 --- a/tests/core/controller/TokenControllerTest.php +++ b/tests/core/controller/TokenControllerTest.php @@ -39,8 +39,12 @@ class TokenControllerTest extends TestCase { parent::setUp(); $this->request = $this->getMock('\OCP\IRequest'); - $this->userManager = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\User\Manager'); - $this->tokenProvider = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultTokenProvider'); + $this->userManager = $this->getMockBuilder('\OC\User\Manager') + ->disableOriginalConstructor() + ->getMock(); + $this->tokenProvider = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider') + ->disableOriginalConstructor() + ->getMock(); $this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom'); $this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider, diff --git a/tests/lib/authentication/token/defaulttokencleanupjobtest.php b/tests/lib/authentication/token/defaulttokencleanupjobtest.php index 53cab00df31..c9082c08b30 100644 --- a/tests/lib/authentication/token/defaulttokencleanupjobtest.php +++ b/tests/lib/authentication/token/defaulttokencleanupjobtest.php @@ -34,7 +34,9 @@ class DefaultTokenCleanupJobTest extends TestCase { protected function setUp() { parent::setUp(); - $this->tokenProvider = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultTokenProvider'); + $this->tokenProvider = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider') + ->disableOriginalConstructor() + ->getMock(); $this->overwriteService('\OC\Authentication\Token\DefaultTokenProvider', $this->tokenProvider); $this->job = new DefaultTokenCleanupJob(); } diff --git a/tests/lib/authentication/token/defaulttokenprovidertest.php b/tests/lib/authentication/token/defaulttokenprovidertest.php index 47bddffa011..54e29a7ef52 100644 --- a/tests/lib/authentication/token/defaulttokenprovidertest.php +++ b/tests/lib/authentication/token/defaulttokenprovidertest.php @@ -40,7 +40,9 @@ class DefaultTokenProviderTest extends TestCase { protected function setUp() { parent::setUp(); - $this->mapper = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultTokenMapper'); + $this->mapper = $this->getMock('\OC\Authentication\Token\DefaultTokenMapper') + ->disableOriginalConstructor() + ->getMock(); $this->crypto = $this->getMock('\OCP\Security\ICrypto'); $this->config = $this->getMock('\OCP\IConfig'); $this->logger = $this->getMock('\OCP\ILogger'); @@ -81,7 +83,9 @@ class DefaultTokenProviderTest extends TestCase { } public function testUpdateToken() { - $tk = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultTokenProvider'); + $tk = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider') + ->disableOriginalConstructor() + ->getMock(); $tk->expects($this->once()) ->method('setLastActivity') ->with(time()); @@ -94,7 +98,9 @@ class DefaultTokenProviderTest extends TestCase { public function testGetPassword() { $token = 'token1234'; - $tk = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultToken'); + $tk = $this->getMockBuilder('\OC\Authentication\Token\DefaultToken') + ->disableOriginalConstructor() + ->getMock(); $tk->expects($this->once()) ->method('getPassword') ->will($this->returnValue('someencryptedvalue'));