]> source.dussan.org Git - nextcloud-server.git/commitdiff
make tests php 5.4 / phpunit 4.8 compatible 1654/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 7 Oct 2016 13:37:27 +0000 (15:37 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Fri, 7 Oct 2016 14:11:24 +0000 (16:11 +0200)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/tests/User_LDAPTest.php

index 13a4f5854c34ea75b6b2413be5b9e957f003d208..102f5846250e9e95db434cc4547013c52fc2ee84 100644 (file)
@@ -56,11 +56,18 @@ class User_LDAPTest extends TestCase {
         * @return \PHPUnit_Framework_MockObject_MockObject|Access
         */
        private function getAccessMock() {
-               $lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
-               $connector = $this->getMockBuilder('\OCA\User_LDAP\Connection')
-                       ->setMethodsExcept(['getConnection'])
-                       ->setConstructorArgs([$lw, null, null])
-                       ->getMock();
+               static $conMethods;
+               static $accMethods;
+
+               if(is_null($conMethods) || is_null($accMethods)) {
+                                               $conMethods = get_class_methods('\OCA\User_LDAP\Connection');
+                                               $accMethods = get_class_methods('\OCA\User_LDAP\Access');
+                                               unset($accMethods[array_search('getConnection', $accMethods)]);
+               }
+               $lw  = $this->getMock('\OCA\User_LDAP\ILDAPWrapper');
+               $connector = $this->getMock(
+                       '\OCA\User_LDAP\Connection', $conMethods, array($lw, null, null)
+               );
 
                $this->configMock = $this->getMock('\OCP\IConfig');
 
@@ -87,10 +94,10 @@ class User_LDAPTest extends TestCase {
 
                $helper = new Helper();
 
-               $access = $this->getMockBuilder('OCA\User_LDAP\Access')
-                       ->setMethodsExcept(['getConnection'])
-                       ->setConstructorArgs([$connector, $lw, $um, $helper])
-                       ->getMock();
+               $access = $this->getMock('\OCA\User_LDAP\Access',
+                       $accMethods,
+                       array($connector, $lw, $um, $helper)
+               );
 
                $um->setLdapAccess($access);
 
@@ -863,7 +870,7 @@ class User_LDAPTest extends TestCase {
                        ->method('writeToCache')
                        ->with($this->equalTo('loginName2UserName-'.$loginName), $this->equalTo($username));
 
-               $backend = new UserLDAP($access, $this->createMock('\OCP\IConfig'));
+               $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
                $name = $backend->loginName2UserName($loginName);
                $this->assertSame($username, $name);
 
@@ -892,7 +899,7 @@ class User_LDAPTest extends TestCase {
                        ->method('writeToCache')
                        ->with($this->equalTo('loginName2UserName-'.$loginName), false);
 
-               $backend = new UserLDAP($access, $this->createMock('\OCP\IConfig'));
+               $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
                $name = $backend->loginName2UserName($loginName);
                $this->assertSame(false, $name);
 
@@ -937,7 +944,7 @@ class User_LDAPTest extends TestCase {
                        ->method('getUserValue')
                        ->willReturn(1);
 
-               $backend = new UserLDAP($access, $this->createMock('\OCP\IConfig'));
+               $backend = new UserLDAP($access, $this->getMock('\OCP\IConfig'));
                $name = $backend->loginName2UserName($loginName);
                $this->assertSame(false, $name);