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()); }
public function testGetAvatarNoSizeMatch() { $this->folder->method('nodeExists')->will($this->returnValueMap([['avatar.png', true], ['avatar.32.png', false]])); $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png'); $expected2 = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png'); $expected2->resize(32); $file = $this->getMock('\\OCP\\Files\\File'); $file->method('getContent')->willReturn($expected->data()); $this->folder->method('get')->with('avatar.png')->willReturn($file); $newFile = $this->getMock('\\OCP\\Files\\File'); $newFile->expects($this->once())->method('putContent')->with($expected2->data()); $this->folder->expects($this->once())->method('newFile')->with('avatar.32.png')->willReturn($newFile); $this->assertEquals($expected2->data(), $this->avatar->get(32)->data()); }