1818use OCA \User_LDAP \User \Manager ;
1919use OCA \User_LDAP \User \OfflineUser ;
2020use OCA \User_LDAP \User \User ;
21+ use OCP \IAppConfig ;
2122use OCP \IAvatarManager ;
2223use OCP \IConfig ;
2324use OCP \Image ;
2425use OCP \IUserManager ;
2526use OCP \Notification \IManager as INotificationManager ;
2627use OCP \Share \IManager ;
28+ use PHPUnit \Framework \MockObject \MockObject ;
2729use Psr \Log \LoggerInterface ;
2830use Test \TestCase ;
2931
@@ -53,10 +55,12 @@ class AccessTest extends TestCase {
5355 private $ config ;
5456 /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
5557 private $ ncUserManager ;
56- /** @var LoggerInterface|MockObject */
57- private $ logger ;
58- /** @var Access */
59- private $ access ;
58+
59+ private LoggerInterface &MockObject $ logger ;
60+
61+ private IAppConfig &MockObject $ appConfig ;
62+
63+ private Access $ access ;
6064
6165 protected function setUp (): void {
6266 $ this ->connection = $ this ->createMock (Connection::class);
@@ -69,28 +73,33 @@ protected function setUp(): void {
6973 $ this ->ncUserManager = $ this ->createMock (IUserManager::class);
7074 $ this ->shareManager = $ this ->createMock (IManager::class);
7175 $ this ->logger = $ this ->createMock (LoggerInterface::class);
76+ $ this ->appConfig = $ this ->createMock (IAppConfig::class);
7277
7378 $ this ->access = new Access (
74- $ this ->connection ,
7579 $ this ->ldap ,
80+ $ this ->connection ,
7681 $ this ->userManager ,
7782 $ this ->helper ,
7883 $ this ->config ,
7984 $ this ->ncUserManager ,
80- $ this ->logger
85+ $ this ->logger ,
86+ $ this ->appConfig ,
8187 );
8288 $ this ->access ->setUserMapper ($ this ->userMapper );
8389 $ this ->access ->setGroupMapper ($ this ->groupMapper );
8490 }
8591
8692 private function getConnectorAndLdapMock () {
93+ /** @var ILDAPWrapper&MockObject */
8794 $ lw = $ this ->createMock (ILDAPWrapper::class);
95+ /** @var Connection&MockObject */
8896 $ connector = $ this ->getMockBuilder (Connection::class)
8997 ->setConstructorArgs ([$ lw , '' , null ])
9098 ->getMock ();
9199 $ connector ->expects ($ this ->any ())
92100 ->method ('getConnectionResource ' )
93101 ->willReturn (ldap_connect ('ldap://example.com ' ));
102+ /** @var Manager&MockObject */
94103 $ um = $ this ->getMockBuilder (Manager::class)
95104 ->setConstructorArgs ([
96105 $ this ->createMock (IConfig::class),
@@ -220,7 +229,7 @@ public function testStringResemblesDN($case) {
220229 [$ lw , $ con , $ um , $ helper ] = $ this ->getConnectorAndLdapMock ();
221230 /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject $config */
222231 $ config = $ this ->createMock (IConfig::class);
223- $ access = new Access ($ con , $ lw , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger );
232+ $ access = new Access ($ lw , $ con , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger , $ this -> appConfig );
224233
225234 $ lw ->expects ($ this ->exactly (1 ))
226235 ->method ('explodeDN ' )
@@ -243,7 +252,7 @@ public function testStringResemblesDNLDAPmod($case) {
243252 /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject $config */
244253 $ config = $ this ->createMock (IConfig::class);
245254 $ lw = new LDAP ();
246- $ access = new Access ($ con , $ lw , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger );
255+ $ access = new Access ($ lw , $ con , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger , $ this -> appConfig );
247256
248257 if (!function_exists ('ldap_explode_dn ' )) {
249258 $ this ->markTestSkipped ('LDAP Module not available ' );
@@ -429,7 +438,7 @@ public function testSanitizeDN($attribute) {
429438 $ attribute => ['count ' => 1 , $ dnFromServer ]
430439 ]);
431440
432- $ access = new Access ($ con , $ lw , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger );
441+ $ access = new Access ($ lw , $ con , $ um , $ helper , $ config , $ this ->ncUserManager , $ this ->logger , $ this -> appConfig );
433442 $ values = $ access ->readAttribute ('uid=whoever,dc=example,dc=org ' , $ attribute );
434443 $ this ->assertSame ($ values [0 ], strtolower ($ dnFromServer ));
435444 }
0 commit comments