public function testGetUrl() { $serviceManager = new CM_Service_Manager(); $filesystemDefault = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local()); $filesystemFoo = new CM_File_Filesystem(new CM_File_Filesystem_Adapter_Local()); $serviceManager->registerInstance('filesystem-usercontent-default', $filesystemDefault); $serviceManager->registerInstance('filesystem-usercontent-foo', $filesystemFoo); $serviceConfig = array('default' => array('url' => 'http://example.com/default', 'filesystem' => 'filesystem-usercontent-default'), 'foo' => array('url' => 'http://example.com/foo', 'filesystem' => 'filesystem-usercontent-foo')); $serviceManager->registerInstance('usercontent', new CM_Service_UserContent($serviceConfig)); $userFile = new CM_File_UserContent('foo', 'my.jpg', null, $serviceManager); $this->assertSame('http://example.com/foo/foo/my.jpg', $userFile->getUrl()); $userFile = new CM_File_UserContent('bar', 'my.jpg', null, $serviceManager); $this->assertSame('http://example.com/default/bar/my.jpg', $userFile->getUrl()); }
/** * @param CM_File_UserContent $file * @return string */ public function getUrlUserContent(CM_File_UserContent $file) { return $file->getUrl(); }