예제 #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());
 }
예제 #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());
 }
예제 #3
0
 /**
  * @param Post $post
  */
 public function publish(Post $post)
 {
     $post->setStatus(PostStatus::PUBLISHED);
     $post->setPublishedAt(new DateTime());
     $this->em->persist($post);
     $this->em->flush();
 }
예제 #4
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());
 }
예제 #5
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());
 }
예제 #6
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());
 }
예제 #7
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());
 }
예제 #8
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()));
 }
예제 #9
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());
 }
예제 #10
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());
 }
예제 #11
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());
 }
예제 #12
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']);
 }
예제 #13
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());
 }
예제 #14
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']);
 }
예제 #15
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());
 }
예제 #16
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());
 }
예제 #17
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());
 }
예제 #18
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());
 }
예제 #19
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());
 }
예제 #20
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());
 }
예제 #21
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());
 }
예제 #22
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()));
 }
 /**
  * Save in database the Message entity representation of a MessageInterface instance.
  *
  * @param MessageInterface $message
  */
 public function save(MessageInterface $message)
 {
     $entity = new Message();
     $entity->setContent($message->getContent());
     $entity->setDate($message->getDate());
     $entity->setUser($this->getUserEntity($message->getUser()));
     $entity->setType($message->getType());
     try {
         $this->em->persist($entity);
         $this->em->flush();
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #24
0
파일: Folder.php 프로젝트: jca/AlbumBundle
 /**
  * @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;
 }