public function find($key, $eagerLoad = false) { $file = new File(); $file->setKey($key); $file->setMapper($this); $adapter = $this->getAdapter(); $result = $adapter->findPaths($key); if (null === $result) { return null; } $file->setPaths($result); if (false !== $eagerLoad) { $info = $adapter->findInfo($key); $file->fromArray($info); } return $file; }
public function testSettersAndGetters() { $file = new File(); $this->assertInstanceOf('MogileFS\\File', $file->setClass('dev')); $this->assertInstanceOf('MogileFS\\File', $file->setDomain('toast')); $this->assertInstanceOf('MogileFS\\File', $file->setFid(123)); $this->assertInstanceOf('MogileFS\\File', $file->setFile($this->getTestFile())); $this->assertInstanceOf('MogileFS\\File', $file->setKey('key')); $this->assertInstanceOf('MogileFS\\File', $file->setMapper(new Mapper())); $this->assertInstanceOf('MogileFS\\File', $file->setPaths(array('http://mypath.com/123.fid'))); $this->assertInstanceOf('MogileFS\\File', $file->setSize(321)); $this->assertEquals('dev', $file->getClass()); $this->assertEquals('toast', $file->getDomain()); $this->assertEquals(123, $file->getFid()); $this->assertEquals($this->getTestFile(), $file->getFile()); $this->assertEquals('key', $file->getKey()); $this->assertEquals(new Mapper(), $file->getMapper()); $this->assertEquals(array('http://mypath.com/123.fid'), $file->getPaths()); $this->assertEquals(321, $file->getSize()); }