コード例 #1
0
ファイル: MultiFileTest.php プロジェクト: firano/form-bundle
 public function testDefault()
 {
     $entity = new MultiFile();
     $entity->setName('file.txt');
     $entity->setOriginalName('original.txt');
     $entity->setSize(123456);
     $entity->setHash('hash');
     $entity->setTitle('title');
     $entity->setCaption('caption');
     $entity->setDescription('desc');
     $entity->setEnabled(true);
     $entity->setScheduledForDeletion(true);
     $entity->setPosition(1);
     $this->assertNull($entity->getCurrentVersion());
     $this->em->persist($entity);
     $this->em->flush($entity);
     $this->assertNotNull($entity->getId());
     $this->assertSame('file.txt', $entity->getName());
     $this->assertSame('original.txt', $entity->getOriginalName());
     $this->assertSame(123456, $entity->getSize());
     $this->assertSame('hash', $entity->getHash());
     $this->assertSame('title', $entity->getTitle());
     $this->assertSame('caption', $entity->getCaption());
     $this->assertSame('desc', $entity->getDescription());
     $this->assertSame(1, $entity->getVersion());
     $this->assertTrue($entity->isEnabled());
     $this->assertTrue($entity->isScheduledForDeletion());
     $this->assertSame(1, $entity->getPosition());
     $this->assertSame('/media/files/main', $entity->getUploadDir());
     $this->assertSame('/media/files/main/file.txt', $entity->getFilePath());
     $entity->setCurrentVersion(2);
 }
コード例 #2
0
 protected function populate()
 {
     $multiFile = new MultiFile();
     $multiFile->setName('name');
     $multiFile->setHash('hash');
     $multiFile->setPosition(1);
     $this->em->persist($multiFile);
     $this->em->flush();
     $this->em->clear();
 }
コード例 #3
0
 protected function populate()
 {
     $project = new Project();
     $project->setTitle('project');
     $this->em->persist($project);
     for ($i = 1; $i < 5; $i++) {
         $multiFile = new MultiFile();
         $multiFile->setName('name' . $i);
         $multiFile->setHash(md5($i));
         $multiFile->setPosition($i);
         $this->em->persist($multiFile);
         $project->addFile($multiFile);
     }
     $this->em->flush();
     $this->em->clear();
 }