Check for $this->fileInfo and @depend on testData()

This commit is contained in:
kondou 2013-09-01 15:50:58 +02:00
parent 235638e5ab
commit 2d6a400381
2 changed files with 5 additions and 2 deletions

View File

@ -519,7 +519,7 @@ class OC_Image {
return false;
}
$this->resource = @imagecreatefromstring($str);
if (\OC_Util::fileInfoLoaded()) {
if ($this->fileInfo) {
$this->mimeType = $this->fileInfo->buffer($str);
}
if(is_resource($this->resource)) {
@ -546,7 +546,7 @@ class OC_Image {
$data = base64_decode($str);
if($data) { // try to load from string data
$this->resource = @imagecreatefromstring($data);
if (\OC_Util::fileInfoLoaded()) {
if ($this->fileInfo) {
$this->mimeType = $this->fileInfo->buffer($data);
}
if(!$this->resource) {

View File

@ -135,6 +135,9 @@ class Test_Image extends PHPUnit_Framework_TestCase {
$this->assertEquals($expected, $img->data());
}
/**
* @depends testData
*/
public function testToString() {
$img = new \OC_Image(OC::$SERVERROOT.'/tests/data/testimage.png');
$expected = base64_encode($img->data());