Exemplo n.º 1
0
 public function testSetAvatar()
 {
     $oldFile = $this->getMock('\\OCP\\Files\\File');
     $this->folder->method('get')->will($this->returnValueMap([['avatar.jpg', $oldFile], ['avatar.png', $oldFile]]));
     $oldFile->expects($this->exactly(2))->method('delete');
     $newFile = $this->getMock('\\OCP\\Files\\File');
     $this->folder->expects($this->once())->method('newFile')->with('avatar.png')->willReturn($newFile);
     $image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
     $newFile->expects($this->once())->method('putContent')->with($image->data());
     $this->avatar->set($image->data());
 }
Exemplo n.º 2
0
 public function testAvatar()
 {
     $avatar = new Avatar($this->user);
     $this->assertEquals(false, $avatar->get());
     $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
     $expected->resize(64);
     $avatar->set($expected->data());
     $this->assertEquals($expected->data(), $avatar->get()->data());
     $avatar->remove();
     $this->assertEquals(false, $avatar->get());
 }
Exemplo n.º 3
0
 public function testSetAvatar()
 {
     $avatarFileJPG = $this->getMock('\\OCP\\Files\\File');
     $avatarFileJPG->method('getName')->willReturn('avatar.jpg');
     $avatarFileJPG->expects($this->once())->method('delete');
     $avatarFilePNG = $this->getMock('\\OCP\\Files\\File');
     $avatarFilePNG->method('getName')->willReturn('avatar.png');
     $avatarFilePNG->expects($this->once())->method('delete');
     $resizedAvatarFile = $this->getMock('\\OCP\\Files\\File');
     $resizedAvatarFile->method('getName')->willReturn('avatar.32.jpg');
     $resizedAvatarFile->expects($this->once())->method('delete');
     $nonAvatarFile = $this->getMock('\\OCP\\Files\\File');
     $nonAvatarFile->method('getName')->willReturn('avatarX');
     $nonAvatarFile->expects($this->never())->method('delete');
     $this->folder->method('search')->with('avatar')->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
     $newFile = $this->getMock('\\OCP\\Files\\File');
     $this->folder->expects($this->once())->method('newFile')->with('avatar.png')->willReturn($newFile);
     $image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
     $newFile->expects($this->once())->method('putContent')->with($image->data());
     $this->avatar->set($image->data());
 }
Exemplo n.º 4
0
 public function testSetAvatar()
 {
     $avatarFileJPG = $this->getMock('\\OCP\\Files\\File');
     $avatarFileJPG->method('getName')->willReturn('avatar.jpg');
     $avatarFileJPG->expects($this->once())->method('delete');
     $avatarFilePNG = $this->getMock('\\OCP\\Files\\File');
     $avatarFilePNG->method('getName')->willReturn('avatar.png');
     $avatarFilePNG->expects($this->once())->method('delete');
     $resizedAvatarFile = $this->getMock('\\OCP\\Files\\File');
     $resizedAvatarFile->method('getName')->willReturn('avatar.32.jpg');
     $resizedAvatarFile->expects($this->once())->method('delete');
     $nonAvatarFile = $this->getMock('\\OCP\\Files\\File');
     $nonAvatarFile->method('getName')->willReturn('avatarX');
     $nonAvatarFile->expects($this->never())->method('delete');
     $this->folder->method('getDirectoryListing')->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
     $newFile = $this->getMock('\\OCP\\Files\\File');
     $this->folder->expects($this->once())->method('newFile')->with('avatar.png')->willReturn($newFile);
     $image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
     $newFile->expects($this->once())->method('putContent')->with($image->data());
     // One on remove and once on setting the new avatar
     $this->user->expects($this->exactly(2))->method('triggerChange');
     $this->avatar->set($image->data());
 }