FileEntityTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * This file is part of the PHPExiftool package.
  4. *
  5. * (c) Alchemy <support@alchemy.fr>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PHPExiftool\Test;
  11. use PHPExiftool\FileEntity;
  12. use PHPExiftool\RDFParser;
  13. class FileEntityTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @var FileEntity
  17. */
  18. protected $object;
  19. /**
  20. * @covers PHPExiftool\FileEntity::__construct
  21. */
  22. protected function setUp()
  23. {
  24. $dom = new \DOMDocument();
  25. $dom->loadXML(file_get_contents(__DIR__ . '/../../../files/ExifTool.xml'));
  26. $this->object = new FileEntity('testFile', $dom, new RDFParser());
  27. }
  28. /**
  29. * @covers PHPExiftool\FileEntity::getIterator
  30. */
  31. public function testGetIterator()
  32. {
  33. $this->assertInstanceOf('\\Iterator', $this->object->getIterator());
  34. }
  35. /**
  36. * @covers PHPExiftool\FileEntity::getFile
  37. */
  38. public function testGetFile()
  39. {
  40. $this->assertInternalType('string', $this->object->getFile());
  41. }
  42. /**
  43. * @covers PHPExiftool\FileEntity::getMetadatas
  44. */
  45. public function testGetMetadatas()
  46. {
  47. $this->assertInstanceOf('\\PHPExiftool\Driver\Metadata\MetadataBag', $this->object->getMetadatas());
  48. $this->assertEquals(349, count($this->object->getMetadatas()));
  49. }
  50. /**
  51. * @covers PHPExiftool\FileEntity::executeQuery
  52. */
  53. public function testExecuteQuery()
  54. {
  55. $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Mono', $this->object->executeQuery('IFD0:Copyright'));
  56. $this->assertEquals('Copyright 2004 Phil Harvey', $this->object->executeQuery('IFD0:Copyright')->asString());
  57. $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Binary', $this->object->executeQuery('CIFF:FreeBytes'));
  58. $this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Multi', $this->object->executeQuery('XMP-dc:Subject'));
  59. $this->assertEquals(array('ExifTool', 'Test', 'XMP'), $this->object->executeQuery('XMP-dc:Subject')->asArray());
  60. }
  61. }