Exemplo n.º 1
0
 /**
  * 
  */
 public function testCreateUpdateAndDelete()
 {
     $oCategory = new Category();
     $oCategory->setName('Hardware Category One');
     $this->oEm->persist($oCategory);
     $this->oEm->flush();
     $iCatID = $oCategory->getId();
     $oFetchCategory = $this->oEm->find('\\Helpdesk\\Entity\\Category', $iCatID);
     $this->assertNotNull($oFetchCategory);
     $this->assertEquals('Hardware Category One', $oFetchCategory->getName());
     $oFetchCategory->setName('Category Two');
     $this->oEm->merge($oFetchCategory);
     $this->oEm->flush();
     $oUpdatedCategory = $this->oEm->find('\\Helpdesk\\Entity\\Category', $iCatID);
     $this->assertNotNull($oUpdatedCategory);
     $this->assertEquals('Category Two', $oUpdatedCategory->getName());
     $this->oEm->remove($oUpdatedCategory);
     $this->oEm->flush();
     $oRemovedCategory = $this->oEm->find('\\Helpdesk\\Entity\\Category', $iCatID);
     $this->assertNull($oRemovedCategory);
 }
Exemplo n.º 2
0
 /**
  * 
  */
 public function testCreateUpdateAndDeleteTicket()
 {
     //Create a test group and user
     $uniqueID = \uniqid();
     $oUser = new ApplicationUser();
     $oUser->setUsername('foobar\\' . $uniqueID);
     $oUser->setEmail($uniqueID . '*****@*****.**');
     $oUser->setDisplayName($uniqueID . ' Foobar One');
     $oGroup = new WorkGroup();
     $oGroup->setName($uniqueID . ' Project Manager Group');
     $oUser->addWorkGroup($oGroup);
     $oProject = new Project();
     $oProject->setName('First Line');
     $oProject->setDescription('First line helpdesk assistance.');
     $oProject->setProjectLead($oUser);
     $this->oEm->persist($oProject);
     $this->oEm->persist($oGroup);
     $this->oEm->flush();
     $iGroupId = $oGroup->getId();
     $iUserId = $oUser->getId();
     $iProjectID = $oProject->getId();
     //Create catregories and other records for the ticket
     $oTicketType = new TicketType();
     $oTicketType->setName('Bug');
     $oCategory = new Category();
     $oCategory->setName('Software');
     $oTicketCategory = new TicketCategory();
     $oTicketCategory->setName('Extended Incident');
     $oWorkFlow = new Workflow();
     $oWorkFlow->setName('Open 2');
     $this->oEm->persist($oTicketType);
     $this->oEm->persist($oCategory);
     $this->oEm->persist($oTicketCategory);
     $this->oEm->persist($oWorkFlow);
     $this->oEm->flush();
     $this->assertNotNull($oTicketType->getId());
     $this->assertNotNull($oCategory->getId());
     $this->assertNotNull($oTicketCategory->getId());
     $this->assertNotNull($oWorkFlow->getId());
     $iTicketTypeId = $oTicketType->getId();
     $iCategoryId = $oCategory->getId();
     $iTicketCategoryId = $oTicketCategory->getId();
     $iWorkFlowId = $oWorkFlow->getId();
     $oTicket = new Ticket();
     $oTicket->setCategory($oCategory);
     $oTicket->setAssignee($oUser);
     $oTicket->setDescription('FOOBAR');
     $oTicket->setProject($oProject);
     $oTicket->setReporter($oUser);
     $oTicket->setSummary('Require CSS changes pushed to development env.');
     $oTicket->setTicketKey('INC-1');
     $oTicket->setTicketCategory($oTicketCategory);
     $oTicket->setType($oTicketType);
     $oTicket->setWorkflow($oWorkFlow);
     $this->oEm->persist($oTicket);
     $this->oEm->flush();
     $this->assertNotNull($oTicket->getId());
     $iProjectId = $oTicket->getId();
     $oRepository = $this->oEm->getRepository('Helpdesk\\Entity\\Ticket');
     $oPersistTicket = $oRepository->find($iProjectId);
     $this->assertInstanceOf('\\Helpdesk\\Entity\\Ticket', $oPersistTicket);
     $this->oEm->remove($oPersistTicket);
     $this->oEm->flush();
     $oRemovedTicket = $oRepository->find($iProjectId);
     $this->assertNull($oRemovedTicket);
     $oGroupRepo = $this->oEm->getRepository('Helpdesk\\Entity\\WorkGroup');
     $oUserRepo = $this->oEm->getRepository('Helpdesk\\Entity\\ApplicationUser');
     //Testing that constraints are set properly for the table associations.
     $oPersistGroup = $oGroupRepo->find($iGroupId);
     $this->assertInstanceOf('\\Helpdesk\\Entity\\WorkGroup', $oPersistGroup);
     $oPersistUser = $oUserRepo->find($iUserId);
     $this->assertInstanceOf('\\Helpdesk\\Entity\\ApplicationUser', $oPersistUser);
     $oUpdatedCategory = $this->oEm->find('\\Helpdesk\\Entity\\Category', $iCategoryId);
     $this->assertNotNull($oUpdatedCategory);
     $this->oEm->remove($oUser);
     $this->oEm->remove($oProject);
     $this->oEm->remove($oGroup);
     $this->oEm->remove($oTicketType);
     $this->oEm->remove($oCategory);
     $this->oEm->remove($oTicketCategory);
     $this->oEm->remove($oWorkFlow);
     $this->oEm->flush();
 }