get rid of test warnings

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2016-10-06 22:52:45 +02:00
parent a0b34dfd2f
commit 979612fa08
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 22 additions and 21 deletions

View File

@ -28,15 +28,20 @@
namespace OCA\User_LDAP\Tests; namespace OCA\User_LDAP\Tests;
use OCA\User_LDAP\Access;
use OCA\User_LDAP\Connection;
use OCA\User_LDAP\FilesystemHelper; use OCA\User_LDAP\FilesystemHelper;
use OCA\User_LDAP\Helper;
use OCA\User_LDAP\ILDAPWrapper; use OCA\User_LDAP\ILDAPWrapper;
use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\LogWrapper;
use OCA\User_LDAP\User\Manager;
use OCA\User_LDAP\User_LDAP as UserLDAP; use OCA\User_LDAP\User_LDAP as UserLDAP;
use OCP\IAvatarManager; use OCP\IAvatarManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection; use OCP\IDBConnection;
use OCP\Image; use OCP\Image;
use OCP\IUserManager; use OCP\IUserManager;
use Test\TestCase;
/** /**
* Class Test_User_Ldap_Direct * Class Test_User_Ldap_Direct
@ -45,7 +50,7 @@ use OCP\IUserManager;
* *
* @package OCA\User_LDAP\Tests * @package OCA\User_LDAP\Tests
*/ */
class User_LDAPTest extends \Test\TestCase { class User_LDAPTest extends TestCase {
protected $backend; protected $backend;
protected $access; protected $access;
protected $configMock; protected $configMock;
@ -58,23 +63,17 @@ class User_LDAPTest extends \Test\TestCase {
} }
private function getAccessMock() { private function getAccessMock() {
static $conMethods;
static $accMethods; static $accMethods;
static $uMethods;
if(is_null($conMethods) || is_null($accMethods)) { if(is_null($accMethods)) {
$conMethods = get_class_methods('\OCA\User_LDAP\Connection'); $accMethods = get_class_methods(Access::class);
$accMethods = get_class_methods('\OCA\User_LDAP\Access');
unset($accMethods[array_search('getConnection', $accMethods)]); unset($accMethods[array_search('getConnection', $accMethods)]);
$uMethods = get_class_methods('\OCA\User_LDAP\User\User');
unset($uMethods[array_search('getUsername', $uMethods)]);
unset($uMethods[array_search('getDN', $uMethods)]);
unset($uMethods[array_search('__construct', $uMethods)]);
} }
$lw = $this->createMock(ILDAPWrapper::class); $lw = $this->createMock(ILDAPWrapper::class);
$connector = $this->getMock('\OCA\User_LDAP\Connection', $connector = $this->getMockBuilder(Connection::class)
$conMethods, ->setMethodsExcept(['getConnection'])
array($lw, null, null)); ->setConstructorArgs([$lw, null, null])
->getMock();
$this->configMock = $this->createMock(IConfig::class); $this->configMock = $this->createMock(IConfig::class);
@ -82,7 +81,8 @@ class User_LDAPTest extends \Test\TestCase {
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$um = $this->getMockBuilder('\OCA\User_LDAP\User\Manager') /** @var Manager|\PHPUnit_Framework_MockObject_MockObject $um */
$um = $this->getMockBuilder(Manager::class)
->setMethods(['getDeletedUser']) ->setMethods(['getDeletedUser'])
->setConstructorArgs([ ->setConstructorArgs([
$this->configMock, $this->configMock,
@ -99,11 +99,12 @@ class User_LDAPTest extends \Test\TestCase {
->method('getDeletedUser') ->method('getDeletedUser')
->will($this->returnValue($offlineUser)); ->will($this->returnValue($offlineUser));
$helper = new \OCA\User_LDAP\Helper(); $helper = new Helper();
$access = $this->getMock('\OCA\User_LDAP\Access', $access = $this->getMockBuilder(Access::class)
$accMethods, ->setMethodsExcept(['getConnection'])
array($connector, $lw, $um, $helper)); ->setConstructorArgs([$connector, $lw, $um, $helper])
->getMock();
$um->setLdapAccess($access); $um->setLdapAccess($access);
@ -135,7 +136,7 @@ class User_LDAPTest extends \Test\TestCase {
/** /**
* Prepares the Access mock for checkPassword tests * Prepares the Access mock for checkPassword tests
* @param \OCA\User_LDAP\Access $access mock * @param Access $access mock
* @param bool $noDisplayName * @param bool $noDisplayName
* @return void * @return void
*/ */
@ -304,7 +305,7 @@ class User_LDAPTest extends \Test\TestCase {
/** /**
* Prepares the Access mock for getUsers tests * Prepares the Access mock for getUsers tests
* @param \OCA\User_LDAP\Access $access mock * @param Access $access mock
* @return void * @return void
*/ */
private function prepareAccessForGetUsers(&$access) { private function prepareAccessForGetUsers(&$access) {