public function setUp()
 {
     // Inserting data insures we will have a result > 0
     $em = \ZF\Doctrine\Audit\Module::getModuleOptions()->getEntityManager();
     $entity = new Album();
     $entity->setTitle('Test 1');
     $em->persist($entity);
     $em->flush();
     $entity->setTitle('Change Test 2');
     $em->flush();
     $this->entity = $entity;
 }
 public function setUp()
 {
     // Inserting data insures we will have a result > 0
     $em = Bootstrap::getApplication()->getServiceManager()->get("doctrine.entitymanager.orm_default");
     $entity = new Album();
     $entity->setTitle('Test 1');
     $em->persist($entity);
     $em->flush();
     $entity = new Album();
     $entity->setTitle('Change Test 2');
     $em->persist($entity);
     $em->flush();
 }
 public function testReturnsRevisionEntity()
 {
     $sm = Bootstrap::getApplication()->getServiceManager();
     $em = \ZF\Doctrine\Audit\Module::getModuleOptions()->getEntityManager();
     $helper = $sm->get('viewhelpermanager')->get('auditCurrentRevisionEntity');
     $entity = new Album();
     $entity->setTitle('Test CurrentRevisionEntity View Helper returns revision with more than two entities');
     $em->persist($entity);
     $em->flush();
     $revisionEntity = $helper($entity);
     // Test getRevisionEntities on Revision
     $this->assertEquals(1, sizeof($revisionEntity->getRevision()->getRevisionEntities()));
     $this->assertInstanceOf('ZF\\Doctrine\\Audit\\Entity\\RevisionEntity', $revisionEntity);
 }
 public function testGettersAndSetters()
 {
     $em = Bootstrap::getApplication()->getServiceManager()->get("doctrine.entitymanager.orm_default");
     $sm = Bootstrap::getApplication()->getServiceManager();
     $entity = new Album();
     $entity->setTitle('test 1');
     $em->persist($entity);
     $em->flush();
     $helper = $sm->get('viewhelpermanager')->get('auditCurrentRevisionEntity');
     $revisionEntity = $helper($entity);
     $this->assertEquals('INS', $revisionEntity->getRevisionType());
     $this->assertEquals($entity, $revisionEntity->getTargetEntity());
     $this->assertEquals('ZFTest\\Doctrine\\Audit\\Models\\Bootstrap\\Album', $revisionEntity->getTargetEntityClass());
 }
 public function testGetRevisionEntitiesByEntityClass()
 {
     // Inserting data insures we will have a result > 0
     $em = \ZF\Doctrine\Audit\Module::getModuleOptions()->getEntityManager();
     $service = \ZF\Doctrine\Audit\Module::getModuleOptions()->getAuditService();
     $service->setComment('test 2');
     $entity = new Album();
     $entity->setTitle('Test 1');
     $em->persist($entity);
     $em->flush();
     $entity->setTitle('Test 2');
     $em->flush();
     $serviceEntities = $service->getRevisionEntities($entity);
     $this->assertGreaterThan(1, sizeof($service->getRevisionEntities(get_class($entity))));
 }
 public function testRevisionEntityActionCanBeAccessed()
 {
     $em = Bootstrap::getApplication()->getServiceManager()->get("doctrine.entitymanager.orm_default");
     $sm = Bootstrap::getApplication()->getServiceManager();
     $entity = new Album();
     $entity->setTitle('test 1');
     $em->persist($entity);
     $em->flush();
     $helper = $sm->get('viewhelpermanager')->get('auditCurrentRevisionEntity');
     $revisionEntity = $helper($entity);
     if (!$revisionEntity) {
         die('helper did not return current revision entity');
     }
     $this->routeMatch->setParam('action', 'revision-entity');
     $this->routeMatch->setParam('controller', 'audit');
     $this->routeMatch->setParam('revisionEntityId', $revisionEntity->getId());
     $result = $this->controller->dispatch($this->request);
     $response = $this->controller->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
 }