예제 #1
0
 public function testFileMetadataFields()
 {
     $file = new File();
     $file->setName('Image');
     $file->setFile(new GridFSFile(__DIR__ . '/file.txt'));
     $file->setFilename('custom_file.txt');
     $this->dm->persist($file);
     $this->dm->flush();
     $this->dm->clear();
     $file = $this->dm->createQueryBuilder('Documents\\File')->getQuery()->getSingleResult();
     $this->assertEquals('Image', $file->getName());
     $this->assertEquals('These are the bytes...', $file->getFile()->getBytes());
     $this->assertEquals('custom_file.txt', $file->getFilename());
     $this->assertEquals(strlen('These are the bytes...'), $file->getLength());
     $this->assertEquals(md5('These are the bytes...'), $file->getMd5());
     $this->assertInstanceOf('DateTime', $file->getUploadDate());
 }