Fixed StoredFile constructor to only load metadata when passing in an ID.
Added a test for StoredFile::loadMetadata().
This commit is contained in:
parent
eafd10a669
commit
fc8c964d52
2 changed files with 20 additions and 3 deletions
|
@ -432,8 +432,17 @@ class StoredFile {
|
|||
if (empty($this->gunid)) {
|
||||
$this->gunid = StoredFile::generateGunid();
|
||||
}
|
||||
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
|
||||
$this->md = $this->loadMetadata();
|
||||
else {
|
||||
$this->md = $this->loadMetadata();
|
||||
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For testing only, do not use.
|
||||
*/
|
||||
public function __setGunid($p_guid) {
|
||||
$this->gunid = $p_guid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,8 +62,16 @@ class StoredFileTest extends PHPUnit_TestCase {
|
|||
$this->fail("StoredFile not created correctly. id = ".$id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$f = new StoredFile();
|
||||
$f->__setGunid($storedFile->getGunid());
|
||||
$f->loadMetadata();
|
||||
if (!is_array($md = $f->getMetadata())) {
|
||||
$this->fail("Unable to load metadata.");
|
||||
return;
|
||||
}
|
||||
//var_dump($md);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue