Exemplo n.º 1
0
 /**
  * @param Gender $gender
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Gender $gender)
 {
     $this->entityManager->persist($gender);
     $this->entityManager->flush();
     $this->assertInstanceOf('General\\Entity\\Gender', $gender);
     $this->assertNotNull($gender->getId());
 }
Exemplo n.º 2
0
 /**
  * @param Program $program
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Program $program)
 {
     $this->entityManager->persist($program);
     $this->entityManager->flush();
     $this->assertInstanceOf('Program\\Entity\\Program', $program);
     $this->assertNotNull($program->getId());
 }
Exemplo n.º 3
0
 /**
  * @param Call $call
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Call $call)
 {
     $this->entityManager->persist($call);
     $this->entityManager->flush();
     $this->assertInstanceOf('Program\\Entity\\Call\\Call', $call);
     $this->assertNotNull($call->getId());
 }
Exemplo n.º 4
0
 /**
  * @param Post $post
  */
 public function publish(Post $post)
 {
     $post->setStatus(PostStatus::PUBLISHED);
     $post->setPublishedAt(new DateTime());
     $this->em->persist($post);
     $this->em->flush();
 }
Exemplo n.º 5
0
 public function testCanRemoveEntity()
 {
     $program = $this->entityManager->find("Program\\Entity\\Program", 2);
     $this->programService->removeEntity($program);
     $reloadProgram = $this->entityManager->find("Program\\Entity\\Program", 2);
     $this->assertNull($reloadProgram);
 }
Exemplo n.º 6
0
 /**
  * @param Type $type
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Type $type)
 {
     $this->entityManager->persist($type);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Document\\Type', $type);
     $this->assertNotNull($type->getId());
     $this->assertNotNull($type->getType());
 }
Exemplo n.º 7
0
 /**
  * @param Country $country
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Country $country)
 {
     $this->entityManager->persist($country);
     $this->entityManager->flush();
     $this->assertInstanceOf('General\\Entity\\Country', $country);
     $this->assertNotNull($country->getId());
     $this->assertNotNull($country->getResourceId());
 }
Exemplo n.º 8
0
 /**
  * @param Title $title
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Title $title)
 {
     $this->entityManager->persist($title);
     $this->entityManager->flush();
     $this->assertInstanceOf('General\\Entity\\Title', $title);
     $this->assertNotNull($title->getId());
     $this->assertNotNull($title->getResourceId());
 }
Exemplo n.º 9
0
 /**
  * @param Web $web
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Web $web)
 {
     $this->entityManager->persist($web);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Web', $web);
     $this->assertNotNull($web->getId());
     $this->assertTrue(is_array($web->getArrayCopy()));
     $this->assertTrue(is_array($web->populate()));
 }
Exemplo n.º 10
0
 /**
  * @param Logo $logo
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Logo $logo)
 {
     $this->entityManager->persist($logo);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Logo', $logo);
     $this->assertNotNull($logo->getId());
     $this->assertTrue(strlen($logo->getHash()) > 0);
     $this->assertNotNull($logo->getCacheFileName());
 }
Exemplo n.º 11
0
 public function testCanFindFunderByCountry()
 {
     $country = $this->entityManager->find("General\\Entity\\Country", 1);
     $funder = $this->programService->findFunderByCountry($country);
     foreach ($funder as $funderResult) {
         $this->assertInstanceOf('Program\\Entity\\Funder', $funderResult);
         $this->assertEquals($funderResult->getCountry()->getId(), 1);
     }
 }
Exemplo n.º 12
0
 /**
  * @param Document $document
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Document $document)
 {
     $this->entityManager->persist($document);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Document\\Document', $document);
     $this->assertNotNull($document->getId());
     $this->assertTrue(is_array($document->getArrayCopy()));
     $this->assertNotNull($document->getDateUpdated());
 }
Exemplo n.º 13
0
 /**
  * @param ContentType $type
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(ContentType $type)
 {
     $this->entityManager->persist($type);
     $this->entityManager->flush();
     //Since we don't save, we give the $contentType a virtual id
     $this->contentType->setId(1);
     $this->assertInstanceOf('General\\Entity\\ContentType', $this->contentType);
     $this->assertNotNull($type->getId());
 }
Exemplo n.º 14
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Contact\\Entity\\AddressType');
     $this->addressType = $hydrator->hydrate($this->addressTypeData, new AddressType());
     $this->entityManager->persist($this->addressType);
     $this->entityManager->flush();
     $this->assertInstanceOf('Contact\\Entity\\AddressType', $this->addressType);
     $this->assertNotNull($this->addressType->getId());
     $this->assertEquals($this->addressType->getType(), $this->addressTypeData['type']);
 }
Exemplo n.º 15
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Contact\\Entity\\Web');
     $this->web = $hydrator->hydrate($this->webData, new Web());
     $this->entityManager->persist($this->web);
     $this->entityManager->flush();
     $this->assertInstanceOf('Contact\\Entity\\Web', $this->web);
     $this->assertNotNull($this->web->getId());
     $this->assertNotNull($this->web->getResourceId());
     $this->assertEquals($this->web->getContact()->getId(), $this->webData['contact']->getId());
     $this->assertEquals($this->web->getWeb(), $this->webData['web']);
 }
Exemplo n.º 16
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Program\\Entity\\Roadmap');
     $this->roadmap = $hydrator->hydrate($this->roadmapData, new Roadmap());
     $this->entityManager->persist($this->roadmap);
     $this->entityManager->flush();
     $this->assertInstanceOf('Program\\Entity\\Roadmap', $this->roadmap);
     $this->assertNotNull($this->roadmap->getId());
     $this->assertSame($this->roadmapData['roadmap'], $this->roadmap->getRoadmap());
     $this->assertSame($this->roadmapData['description'], $this->roadmap->getDescription());
     $this->assertSame($this->roadmapData['dateReleased'], $this->roadmap->getDateReleased());
 }
Exemplo n.º 17
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'General\\Entity\\Eu');
     $this->eu = $hydrator->hydrate($this->euData, new Eu());
     $this->entityManager->persist($this->eu);
     $this->entityManager->flush();
     //Since we don't save, we give the $eu a virtual id
     $this->eu->setId(1);
     $this->assertInstanceOf('General\\Entity\\Eu', $this->eu);
     $this->assertNotNull($this->eu->getId());
     $this->assertEquals($this->eu->getSince(), $this->euData['since']);
     $this->assertEquals($this->eu->getCountry()->getCountry(), $this->euData['country']->getCountry());
 }
Exemplo n.º 18
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Program\\Entity\\Domain');
     $this->domain = $hydrator->hydrate($this->domainData, new Domain());
     $this->entityManager->persist($this->domain);
     $this->entityManager->flush();
     $this->assertInstanceOf('Program\\Entity\\Domain', $this->domain);
     $this->assertNotNull($this->domain->getId());
     $this->assertSame($this->domainData['domain'], $this->domain->getDomain());
     $this->assertSame($this->domainData['roadmap']->getId(), $this->domain->getRoadmap()->getId());
     $this->assertSame($this->domainData['description'], $this->domain->getDescription());
     $this->assertSame($this->domainData['color'], $this->domain->getColor());
     $this->assertSame($this->domainData['mainId'], $this->domain->getMainId());
 }
Exemplo n.º 19
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Contact\\Entity\\Email');
     $this->email = $hydrator->hydrate($this->emailData, new Email());
     $this->entityManager->persist($this->email);
     $this->entityManager->flush();
     $this->assertInstanceOf('Contact\\Entity\\Email', $this->email);
     $this->assertNotNull($this->email->getId());
     $this->assertNotNull($this->email->getDateCreated());
     $this->assertNotNull($this->email->getDateUpdated());
     $this->assertEquals($this->email->getContact()->getId(), $this->emailData['contact']->getId());
     $this->assertEquals($this->email->getEmail(), $this->emailData['email']);
     $this->assertNotNull($this->email->getResourceId());
 }
Exemplo n.º 20
0
 public function testCanSaveEntityInDatabase()
 {
     $hydrator = new DoctrineObject($this->entityManager, 'Contact\\Entity\\Address');
     $this->address = $hydrator->hydrate($this->addressData, new Address());
     $this->entityManager->persist($this->address);
     $this->entityManager->flush();
     $this->assertInstanceOf('Contact\\Entity\\Address', $this->address);
     $this->assertNotNull($this->address->getId());
     $this->assertEquals($this->address->getContact()->getId(), $this->addressData['contact']->getId());
     $this->assertEquals($this->address->getAddress(), $this->addressData['address']);
     $this->assertEquals($this->address->getZipcode(), $this->addressData['zipcode']);
     $this->assertEquals($this->address->getCity(), $this->addressData['city']);
     $this->assertEquals($this->address->getCountry()->getId(), $this->addressData['country']->getId());
     $this->assertNotNull($this->address->getResourceId());
 }
Exemplo n.º 21
0
 /**
  * @param Contact $contact
  *
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Contact $contact)
 {
     $this->entityManager->persist($contact);
     $this->entityManager->flush();
     $this->assertInstanceOf('Contact\\Entity\\Contact', $contact);
     $this->assertNotNull($contact->getId());
     $this->assertNotNull($contact->getDisplayName());
 }
Exemplo n.º 22
0
 /**
  * @param Project $project
  *
  * @dataProvider $project
  */
 public function testCanSaveEntityInDatabase(Project $project)
 {
     $this->entityManager->persist($project);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Project', $project);
     $this->assertNotNull($project->getId());
     $this->assertInstanceOf('Program\\Entity\\Call\\Call', $project->getCall());
     $this->assertInstanceOf('Contact\\Entity\\Contact', $project->getContact());
 }
Exemplo n.º 23
0
 public function testCanFindProjectByNews()
 {
     $news = $this->entityManager->find('News\\Entity\\News', 1);
     $projectsServiceByNews = $this->projectService->findProjectByNews($news);
     $this->assertTrue(is_array($projectsServiceByNews));
     foreach ($projectsServiceByNews as $projectService) {
         $this->assertInstanceOf("Project\\Service\\ProjectService", $projectService);
     }
 }
Exemplo n.º 24
0
 /**
  * @param Version $version ;
  * @dataProvider provider
  */
 public function testCanSaveEntityInDatabase(Version $version)
 {
     $this->entityManager->persist($version);
     $this->entityManager->flush();
     $this->assertInstanceOf('Project\\Entity\\Version\\Version', $version);
     $this->assertNotNull($version->getId());
     $this->assertTrue(is_string($version->getApproved(true)));
     $this->assertInstanceOf('Project\\Entity\\Version\\Type', $version->getVersionType());
     $this->assertInstanceOf('Contact\\Entity\\Contact', $version->getContact());
 }
Exemplo n.º 25
0
 public function testCanAcceptInvite()
 {
     $invite = $this->inviteService->setInviteId(1)->getInvite();
     $contact = $this->entityManager->find('Contact\\Entity\\Contact', 1);
     $organisation = $this->entityManager->find("Organisation\\Entity\\Organisation", 1);
     $contactOrganisation = new ContactOrganisation();
     $contactOrganisation->setContact($contact);
     $contactOrganisation->setOrganisation($organisation);
     $this->assertTrue($this->inviteService->acceptInvitation($invite, $contact, InviteAccept::OPTION_NEW_PARTNER));
     $this->assertTrue($this->inviteService->acceptInvitation($invite, $contact, InviteAccept::OPTION_FINANCIAL_CONTACT));
     $this->assertTrue($this->inviteService->acceptInvitation($invite, $contact, InviteAccept::OPTION_ADDITIONAL_CONTACT));
     $this->assertTrue($this->inviteService->acceptInvitation($invite, $contact, InviteAccept::OPTION_MAIN_TECHNICAL_CONTACT));
 }
Exemplo n.º 26
0
 public function testCanAddMultipleOptInToUser()
 {
     $contact = $this->entityManager->find("Contact\\Entity\\Contact", 1);
     $optIn = new \Contact\Entity\OptIn();
     $optIn->setOptIn(3);
     $optIn->setDescription('This is the description');
     $optIn2 = new \Contact\Entity\OptIn();
     $optIn2->setOptIn(4);
     $optIn2->setDescription('This is the description');
     $contact->setOptIn(array($optIn, $optIn2));
     $this->entityManager->persist($contact);
     $this->entityManager->flush();
     $this->assertEquals(2, sizeof($contact->getOptIn()));
 }
Exemplo n.º 27
0
 public function mergeUsers($user1, $user2)
 {
     //Merge old camdram auth tokens
     $tokens = $this->em->getRepository('ActsCamdramBundle:Access')->findBy(array('uid' => $user2->getId()));
     foreach ($tokens as $token) {
         $token->setUid($user1->getId());
     }
     $this->em->flush();
     $tokens = $this->em->getRepository('ActsCamdramBundle:Access')->findBy(array('issuer_id' => $user2->getId()));
     foreach ($tokens as $token) {
         $token->setIssuerId($user1->getId());
     }
     $this->em->flush();
     $tokens = $this->em->getRepository('ActsCamdramBundle:Access')->findBy(array('revoke_id' => $user2->getId()));
     foreach ($tokens as $token) {
         $token->setRevokeId($user1->getId());
     }
     $this->em->flush();
     //Merge emails
     $emails = $this->em->getRepository('ActsCamdramBundle:Email')->findBy(array('user_id' => $user2->getId()));
     foreach ($emails as $email) {
         $email->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge email aliases
     $aliases = $this->em->getRepository('ActsCamdramBundle:EmailAlias')->findBy(array('user_id' => $user2->getId()));
     foreach ($aliases as $alias) {
         $alias->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge email sigs
     $sigs = $this->em->getRepository('ActsCamdramBundle:EmailSig')->findBy(array('user_id' => $user2->getId()));
     foreach ($sigs as $sig) {
         $sig->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge forum messages
     $msgs = $this->em->getRepository('ActsCamdramBundle:EmailSig')->findBy(array('user_id' => $user2->getId()));
     foreach ($msgs as $msg) {
         $msg->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge knowledge base
     $kbs = $this->em->getRepository('ActsCamdramBundle:KnowledgeBaseRevision')->findBy(array('user_id' => $user2->getId()));
     foreach ($kbs as $kb) {
         $kb->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge mailing list members
     $r = $this->em->getRepository('ActsCamdramBundle:MailingListMember');
     $members = $r->findBy(array('user_id' => $user2->getId()));
     foreach ($members as $member) {
         if ($r->findOneBy(array('list_id' => $member->getListId(), 'user_id' => $user1->getId()))) {
             $this->em->remove($member);
         } else {
             $member->setUserId($user1->getId());
         }
     }
     $this->em->flush();
     //Merge reviews
     $reviews = $this->em->getRepository('ActsCamdramBundle:Review')->findBy(array('user_id' => $user2->getId()));
     foreach ($reviews as $review) {
         $review->setUserId($user1->getId());
     }
     $this->em->flush();
     //Merge user identities
     $identities = $this->em->getRepository('ActsCamdramSecurityBundle:UserIdentity')->findBy(array('user' => $user2));
     foreach ($identities as $identity) {
         $identity->setUser($user1);
     }
     $this->em->flush();
     if ($user2->getPerson() && !$user1->getPerson()) {
         $user1->setPerson($user2->getPerson());
     }
     $this->em->remove($user2);
     $this->em->flush();
 }
Exemplo n.º 28
0
 public function testCanCreateFormAndBindEntity()
 {
     $project = $this->entityManager->find("Project\\Entity\\Project", 1);
     $projectForm = $this->formService->getForm(null, $project, true);
     $this->assertInstanceOf('Zend\\Form\\Form', $projectForm);
 }
Exemplo n.º 29
0
 /**
  * @param \Jcc\Bundle\AlbumBundle\Entity\Folder $folder
  *
  * @return array
  */
 public function crawlFolderPictures(Entity\Folder $folder)
 {
     //Get all it's images and create a hashmap for matching (img > img path)
     $root = $this->parameters['album_root'];
     $all = $pictures = $saved = array();
     foreach ($folder->getPictures() as $picture) {
         $saved[$picture->getHash()] = $picture;
     }
     foreach (new DirectoryIterator($root . '/' . $folder->getPath()) as $file) {
         $all[] = array('filename' => $file->getFilename(), 'pathname' => $file->getPathname());
     }
     usort($all, function ($a, $b) {
         return strcmp($a['filename'], $b['filename']);
     });
     foreach ($all as $file) {
         $extension = strtolower(pathinfo($file['filename'], PATHINFO_EXTENSION));
         if ('jpg' != $extension && 'jpeg' != $extension) {
             continue;
         }
         if (strpos($file['filename'], '.') === 0) {
             continue;
         }
         $hash = substr(md5($file['pathname']), 0, 12);
         if (isset($saved[$hash])) {
             $picture = $saved[$hash];
             unset($saved[$hash]);
         } else {
             $picture = new Entity\Picture();
             $picture->setPath($file['filename']);
             $picture->setHash($hash);
             $picture->setFolder($folder);
             $date = null;
             $exif = @exif_read_data($file['pathname']);
             if (!empty($exif['FileDateTime'])) {
                 $date = new DateTime("@" . $exif['FileDateTime']);
             } else {
                 $output = array();
                 exec(sprintf('exiftool %s', escapeshellarg($file['pathname'])), $output, $error);
                 foreach ($output ?: array() as $line) {
                     if (strpos($line, 'Date/Time Original') === false) {
                         continue;
                     }
                     list($key, $value) = preg_split('/\\s+:\\s+/', $line);
                     if ($key == 'Date/Time Original') {
                         $date = \DateTime::createFromFormat('Y:m:d h:i:s', $value);
                         break;
                     }
                 }
             }
             if ($date) {
                 $picture->setOriginalDate($date);
             }
             $this->em->persist($picture);
         }
         $pictures[] = $picture;
     }
     //Remove inexistant pictures
     foreach ($saved as $picture) {
         $this->em->remove($picture);
     }
     $this->em->flush();
     //Sort pictures by date shot (EXIF)
     usort($pictures, function ($a, $b) {
         if (!$a->getOriginalDate() || !$b->getOriginalDate()) {
             return strcmp($a->getPath(), $b->getPath());
         }
         return $a->getOriginalDate() > $b->getOriginalDate();
     });
     return $pictures;
 }
 /**
  * Get the good User Entity.
  *
  * @param UserInterface $user
  * @return UserInterface
  */
 private function getUserEntity(UserInterface $user)
 {
     return $this->em->getRepository($this->repoUser)->findOneBy(array('username' => $user->getUsername()));
 }