Browse Source

fix mock builder for old phpunit versions

tags/v9.1.0beta1
Christoph Wurst 8 years ago
parent
commit
dff108e97b
No account linked to committer's email address

+ 6
- 2
tests/core/controller/TokenControllerTest.php View File

parent::setUp(); parent::setUp();


$this->request = $this->getMock('\OCP\IRequest'); $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->secureRandom = $this->getMock('\OCP\Security\ISecureRandom');


$this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider, $this->tokenController = new TokenController('core', $this->request, $this->userManager, $this->tokenProvider,

+ 3
- 1
tests/lib/authentication/token/defaulttokencleanupjobtest.php View File

protected function setUp() { protected function setUp() {
parent::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->overwriteService('\OC\Authentication\Token\DefaultTokenProvider', $this->tokenProvider);
$this->job = new DefaultTokenCleanupJob(); $this->job = new DefaultTokenCleanupJob();
} }

+ 9
- 3
tests/lib/authentication/token/defaulttokenprovidertest.php View File

protected function setUp() { protected function setUp() {
parent::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->crypto = $this->getMock('\OCP\Security\ICrypto');
$this->config = $this->getMock('\OCP\IConfig'); $this->config = $this->getMock('\OCP\IConfig');
$this->logger = $this->getMock('\OCP\ILogger'); $this->logger = $this->getMock('\OCP\ILogger');
} }


public function testUpdateToken() { public function testUpdateToken() {
$tk = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultTokenProvider');
$tk = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider')
->disableOriginalConstructor()
->getMock();
$tk->expects($this->once()) $tk->expects($this->once())
->method('setLastActivity') ->method('setLastActivity')
->with(time()); ->with(time());


public function testGetPassword() { public function testGetPassword() {
$token = 'token1234'; $token = 'token1234';
$tk = $this->getMockWithoutInvokingTheOriginalConstructor('\OC\Authentication\Token\DefaultToken');
$tk = $this->getMockBuilder('\OC\Authentication\Token\DefaultToken')
->disableOriginalConstructor()
->getMock();
$tk->expects($this->once()) $tk->expects($this->once())
->method('getPassword') ->method('getPassword')
->will($this->returnValue('someencryptedvalue')); ->will($this->returnValue('someencryptedvalue'));

Loading…
Cancel
Save