/** * {@inheritDoc} */ public function findRevision(RepositoryInterface $repository, $revision) { if ($revision instanceof RevisionInterface) { return $revision; } foreach ($repository->getRevisions() as $current) { if ($current->getId() == $revision) { return $current; } } throw new Exception\RevisionNotFoundException(sprintf('Revision with id "%d" not found.', $revision)); }
public function testCommitRevision() { $repositoryConfig = $this->moduleConfig['permissions']['Athene2Test\\VersioningTest\\Asset\\RepositoryFake']; $permission = $repositoryConfig[ModuleOptions::KEY_PERMISSION_COMMIT]; $data = ['foo' => 'bar']; $this->authorizationService->expects($this->any())->method('getIdentity')->will($this->returnValue($this->identity)); $this->authorizationService->expects($this->once())->method('isGranted')->with($permission)->will($this->returnValue(true)); $this->objectManager->expects($this->atLeastOnce())->method('persist'); $this->eventManager->expects($this->once())->method('trigger')->with(VersioningEvent::COMMIT); $this->repositoryManager->setEventManager($this->eventManager); $revision = $this->repositoryManager->commitRevision($this->repository, $data); $this->assertSame($this->repository, $revision->getRepository()); $this->assertSame($this->identity, $revision->getAuthor()); $this->assertSame('bar', $revision->get('foo')); $this->assertEquals($revision, current($this->repository->getRevisions())); }