/** * @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()); }
/** * @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()); }
/** * @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()); }
/** * @param Post $post */ public function publish(Post $post) { $post->setStatus(PostStatus::PUBLISHED); $post->setPublishedAt(new DateTime()); $this->em->persist($post); $this->em->flush(); }
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); }
/** * @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()); }
/** * @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()); }
/** * @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()); }
/** * @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())); }
/** * @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()); }
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); } }
/** * @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()); }
/** * @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()); }
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']); }
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']); }
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()); }
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()); }
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()); }
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()); }
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()); }
/** * @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()); }
/** * @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()); }
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); } }
/** * @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()); }
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)); }
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())); }
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(); }
public function testCanCreateFormAndBindEntity() { $project = $this->entityManager->find("Project\\Entity\\Project", 1); $projectForm = $this->formService->getForm(null, $project, true); $this->assertInstanceOf('Zend\\Form\\Form', $projectForm); }
/** * @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())); }