|
43 | 43 | use OCA\User_LDAP\LogWrapper; |
44 | 44 | use OCA\User_LDAP\Mapping\UserMapping; |
45 | 45 | use OCA\User_LDAP\User\Manager; |
| 46 | +use OCA\User_LDAP\User\OfflineUser; |
46 | 47 | use OCA\User_LDAP\User\User; |
47 | 48 | use OCP\IAvatarManager; |
48 | 49 | use OCP\IConfig; |
@@ -312,7 +313,7 @@ public function testBatchApplyUserAttributes() { |
312 | 313 | $userMock->expects($this->exactly(count($data))) |
313 | 314 | ->method('processAttributes'); |
314 | 315 |
|
315 | | - $this->userManager->expects($this->exactly(count($data))) |
| 316 | + $this->userManager->expects($this->exactly(count($data) * 2)) |
316 | 317 | ->method('get') |
317 | 318 | ->will($this->returnValue($userMock)); |
318 | 319 |
|
@@ -394,7 +395,7 @@ public function testBatchApplyUserAttributesDontSkip() { |
394 | 395 | $userMock->expects($this->exactly(count($data))) |
395 | 396 | ->method('processAttributes'); |
396 | 397 |
|
397 | | - $this->userManager->expects($this->exactly(count($data))) |
| 398 | + $this->userManager->expects($this->exactly(count($data) * 2)) |
398 | 399 | ->method('get') |
399 | 400 | ->will($this->returnValue($userMock)); |
400 | 401 |
|
@@ -662,6 +663,40 @@ public function testSanitizeUsername($name, $expected) { |
662 | 663 | $this->assertSame($expected, $sanitizedName); |
663 | 664 | } |
664 | 665 |
|
| 666 | + public function testUserStateUpdate() { |
| 667 | + $this->connection->expects($this->any()) |
| 668 | + ->method('__get') |
| 669 | + ->willReturnMap([ |
| 670 | + [ 'ldapUserDisplayName', 'displayName' ], |
| 671 | + [ 'ldapUserDisplayName2', null], |
| 672 | + ]); |
| 673 | + |
| 674 | + $offlineUserMock = $this->createMock(OfflineUser::class); |
| 675 | + $offlineUserMock->expects($this->once()) |
| 676 | + ->method('unmark'); |
| 677 | + |
| 678 | + $regularUserMock = $this->createMock(User::class); |
| 679 | + |
| 680 | + $this->userManager->expects($this->atLeastOnce()) |
| 681 | + ->method('get') |
| 682 | + ->with('detta') |
| 683 | + ->willReturnOnConsecutiveCalls($offlineUserMock, $regularUserMock); |
| 684 | + |
| 685 | + /** @var UserMapping|\PHPUnit_Framework_MockObject_MockObject $mapperMock */ |
| 686 | + $mapperMock = $this->createMock(UserMapping::class); |
| 687 | + $mapperMock->expects($this->any()) |
| 688 | + ->method('getNameByDN') |
| 689 | + ->with('uid=detta,ou=users,dc=hex,dc=ample') |
| 690 | + ->willReturn('detta'); |
| 691 | + $this->access->setUserMapper($mapperMock); |
665 | 692 |
|
| 693 | + $records = [ |
| 694 | + [ |
| 695 | + 'dn' => ['uid=detta,ou=users,dc=hex,dc=ample'], |
| 696 | + 'displayName' => ['Detta Detkova'], |
| 697 | + ] |
| 698 | + ]; |
| 699 | + $this->access->nextcloudUserNames($records); |
| 700 | + } |
666 | 701 |
|
667 | 702 | } |
0 commit comments