public function testItShouldReturnASessionManager() { $sessionInterface = $this->mock('\\PHPCR\\SessionInterface', null); $repositoryInterface = $this->mock('\\PHPCR\\RepositoryInterface', null); $repository = $this->mock('\\PHPCRAPI\\PHPCR\\Repository')->login($sessionInterface)->getRepository($repositoryInterface)->getParameters(['credentials.username' => 'admin', 'credentials.password' => 'admin'])->new(); $manager = new RepositoryManager($repository); $this->assertTrue($manager->getSessionManager() instanceof SessionManager); }
public function convert($repository, Request $request) { if (is_null($repository)) { return null; } $workspace = $request->attributes->has('workspace') ? $request->attributes->get('workspace') : null; try { $repositoryManager = new RepositoryManager($this->app['phpcr_api.repository_loader']->getRepositories()->get($repository)); $sessionManager = $repositoryManager->getSessionManager($workspace); return $sessionManager; } catch (CollectionUnknownKeyException $e) { throw new ResourceNotFoundException('The repository is unknown'); } }