@@ -521,6 +521,17 @@ public function testUpdateAvatarJpegPhotoProvided() {
521521 $ this ->image ->expects ($ this ->once ())
522522 ->method ('centerCrop ' )
523523 ->will ($ this ->returnValue (true ));
524+ $ this ->image ->expects ($ this ->once ())
525+ ->method ('data ' )
526+ ->will ($ this ->returnValue ('this is a photo ' ));
527+
528+ $ this ->config ->expects ($ this ->once ())
529+ ->method ('getUserValue ' )
530+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , '' )
531+ ->willReturn ('' );
532+ $ this ->config ->expects ($ this ->once ())
533+ ->method ('setUserValue ' )
534+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , md5 ('this is a photo ' ));
524535
525536 $ this ->filesystemhelper ->expects ($ this ->once ())
526537 ->method ('isLoaded ' )
@@ -544,6 +555,53 @@ public function testUpdateAvatarJpegPhotoProvided() {
544555 $ this ->user ->updateAvatar ();
545556 }
546557
558+ public function testUpdateAvatarKnownJpegPhotoProvided () {
559+ $ this ->access ->expects ($ this ->once ())
560+ ->method ('readAttribute ' )
561+ ->with ($ this ->equalTo ($ this ->dn ),
562+ $ this ->equalTo ('jpegphoto ' ))
563+ ->will ($ this ->returnValue (['this is a photo ' ]));
564+
565+ $ this ->image ->expects ($ this ->once ())
566+ ->method ('loadFromBase64 ' )
567+ ->willReturn ('imageResource ' );
568+ $ this ->image ->expects ($ this ->never ())
569+ ->method ('valid ' );
570+ $ this ->image ->expects ($ this ->never ())
571+ ->method ('width ' );
572+ $ this ->image ->expects ($ this ->never ())
573+ ->method ('height ' );
574+ $ this ->image ->expects ($ this ->never ())
575+ ->method ('centerCrop ' );
576+ $ this ->image ->expects ($ this ->once ())
577+ ->method ('data ' )
578+ ->will ($ this ->returnValue ('this is a photo ' ));
579+
580+ $ this ->config ->expects ($ this ->once ())
581+ ->method ('getUserValue ' )
582+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , '' )
583+ ->willReturn (md5 ('this is a photo ' ));
584+ $ this ->config ->expects ($ this ->never ())
585+ ->method ('setUserValue ' );
586+
587+ $ this ->filesystemhelper ->expects ($ this ->never ())
588+ ->method ('isLoaded ' );
589+
590+ $ avatar = $ this ->createMock (IAvatar::class);
591+ $ avatar ->expects ($ this ->never ())
592+ ->method ('set ' );
593+
594+ $ this ->avatarManager ->expects ($ this ->never ())
595+ ->method ('getAvatar ' );
596+
597+ $ this ->connection ->expects ($ this ->any ())
598+ ->method ('resolveRule ' )
599+ ->with ('avatar ' )
600+ ->willReturn (['jpegphoto ' , 'thumbnailphoto ' ]);
601+
602+ $ this ->assertTrue ($ this ->user ->updateAvatar ());
603+ }
604+
547605 public function testUpdateAvatarThumbnailPhotoProvided () {
548606 $ this ->access ->expects ($ this ->any ())
549607 ->method ('readAttribute ' )
@@ -575,6 +633,17 @@ public function testUpdateAvatarThumbnailPhotoProvided() {
575633 $ this ->image ->expects ($ this ->once ())
576634 ->method ('centerCrop ' )
577635 ->will ($ this ->returnValue (true ));
636+ $ this ->image ->expects ($ this ->once ())
637+ ->method ('data ' )
638+ ->will ($ this ->returnValue ('this is a photo ' ));
639+
640+ $ this ->config ->expects ($ this ->once ())
641+ ->method ('getUserValue ' )
642+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , '' )
643+ ->willReturn ('' );
644+ $ this ->config ->expects ($ this ->once ())
645+ ->method ('setUserValue ' )
646+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , md5 ('this is a photo ' ));
578647
579648 $ this ->filesystemhelper ->expects ($ this ->once ())
580649 ->method ('isLoaded ' )
@@ -625,6 +694,13 @@ public function testUpdateAvatarCorruptPhotoProvided() {
625694 ->method ('height ' );
626695 $ this ->image ->expects ($ this ->never ())
627696 ->method ('centerCrop ' );
697+ $ this ->image ->expects ($ this ->never ())
698+ ->method ('data ' );
699+
700+ $ this ->config ->expects ($ this ->never ())
701+ ->method ('getUserValue ' );
702+ $ this ->config ->expects ($ this ->never ())
703+ ->method ('setUserValue ' );
628704
629705 $ this ->filesystemhelper ->expects ($ this ->never ())
630706 ->method ('isLoaded ' );
@@ -675,6 +751,16 @@ public function testUpdateAvatarUnsupportedThumbnailPhotoProvided() {
675751 $ this ->image ->expects ($ this ->once ())
676752 ->method ('centerCrop ' )
677753 ->will ($ this ->returnValue (true ));
754+ $ this ->image ->expects ($ this ->once ())
755+ ->method ('data ' )
756+ ->will ($ this ->returnValue ('this is a photo ' ));
757+
758+ $ this ->config ->expects ($ this ->once ())
759+ ->method ('getUserValue ' )
760+ ->with ($ this ->uid , 'user_ldap ' , 'lastAvatarChecksum ' , '' )
761+ ->willReturn ('' );
762+ $ this ->config ->expects ($ this ->never ())
763+ ->method ('setUserValue ' );
678764
679765 $ this ->filesystemhelper ->expects ($ this ->once ())
680766 ->method ('isLoaded ' )
@@ -723,6 +809,13 @@ public function testUpdateAvatarNotProvided() {
723809 ->method ('height ' );
724810 $ this ->image ->expects ($ this ->never ())
725811 ->method ('centerCrop ' );
812+ $ this ->image ->expects ($ this ->never ())
813+ ->method ('data ' );
814+
815+ $ this ->config ->expects ($ this ->never ())
816+ ->method ('getUserValue ' );
817+ $ this ->config ->expects ($ this ->never ())
818+ ->method ('setUserValue ' );
726819
727820 $ this ->filesystemhelper ->expects ($ this ->never ())
728821 ->method ('isLoaded ' );
0 commit comments