Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/PHPExiftool/FileEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(string $file, DOMDocument $dom, RDFParser $parser)
* @throws InvalidArgumentException
* @throws Exception
*/
public function getIterator()
public function getIterator(): \Traversable
{
return $this->getMetadatas()->getIterator();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/PHPExiftool/InformationDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function setLogger(LoggerInterface $logger)
* @return DOMDocument
* @throws Exception
*/
public function listDatas(string $type = self::LISTTYPE_SUPPORTED_XML, array $options = [], array $lngs): DOMDocument
public function listDatas(string $type = self::LISTTYPE_SUPPORTED_XML, array $options = [], array $lngs = []): DOMDocument
{
if (!is_array($options)) {
throw new InvalidArgumentException('options must be an array');
Expand Down
14 changes: 4 additions & 10 deletions tests/lib/PHPExiftool/PHPExiftoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@

use PHPExiftool\Exception\DirectoryNotFoundException;
use PHPExiftool\PHPExiftool;
use PHPExiftool\Reader;
use PHPUnit\Framework\TestCase;


class PHPExiftoolTest extends TestCase {

private ?PHPExiftool $PHPExiftool = null;
protected static string $tmpDir = "";
protected static bool $disableSymLinkTest = false;

class PHPExiftoolTest extends TestCase
{
/**
* @covers PHPExiftool::__construct
*/
public function testRelativeClassesRootDirectory()
public function testRelativeClassesRootDirectory(): void
{
$this->expectException(DirectoryNotFoundException::class);
new PHPExiftool("./relative_dir");
Expand All @@ -34,7 +28,7 @@ public function testRelativeClassesRootDirectory()
/**
* @covers PHPExiftool::__construct
*/
public function testBadClassesRootDirectory()
public function testBadClassesRootDirectory(): void
{
$this->expectException(DirectoryNotFoundException::class);
new PHPExiftool("/non_existing_dir");
Expand Down
37 changes: 19 additions & 18 deletions tests/lib/PHPExiftool/RDFParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@

namespace lib\PHPExiftool;

use Doctrine\Common\Collections\ArrayCollection;
use Monolog\Handler\NullHandler;
use Monolog\Logger;
use PHPExiftool\Driver\Value\Binary;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Value\Multi;
use PHPExiftool\FileEntity;
use PHPExiftool\RDFParser;
use PHPExiftool\Exception\LogicException;
use PHPExiftool\Exception\ParseErrorException;
use PHPExiftool\Exception\RuntimeException;
use PHPUnit\Framework\TestCase;


class RDFParserTest extends TestCase
{
protected RDFParser $object;
Expand All @@ -35,15 +36,15 @@ protected function setUp(): void
/**
* @covers RDFParser::open
*/
public function testOpen()
public function testOpen(): void
{
$this->object->open(file_get_contents(__DIR__ . '/../../files/simplefile.xml'));
}

/**
* @covers RDFParser::close
*/
public function testClose()
public function testClose(): void
{
$this->object->close();
}
Expand All @@ -54,15 +55,15 @@ public function testClose()
* @covers RDFParser::getDomXpath
* @covers RDFParser::getNamespacesFromXml
*/
public function testParseEntities()
public function testParseEntities(): void
{
$entities = $this->object
->open(file_get_contents(__DIR__ . '/../../files/simplefile.xml'))
->parseEntities();

$this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $entities);
$this->assertEquals(1, count($entities));
$this->assertInstanceOf('\\PHPExiftool\\FileEntity', $entities->first());
$this->assertInstanceOf(ArrayCollection::class, $entities);
$this->assertCount(1, $entities);
$this->assertInstanceOf(FileEntity::class, $entities->first());
}

/**
Expand All @@ -71,7 +72,7 @@ public function testParseEntities()
* @covers RDFParser::getDomXpath
* @covers \PHPExiftool\Exception\LogicException
*/
public function testParseEntitiesWithoutDom()
public function testParseEntitiesWithoutDom(): void
{
$this->expectException(\LogicException::class);
$this->object->parseEntities();
Expand All @@ -84,7 +85,7 @@ public function testParseEntitiesWithoutDom()
* @covers \PHPExiftool\Exception\ParseErrorException
* @covers \PHPExiftool\Exception\RuntimeException
*/
public function testParseEntitiesWrongDom()
public function testParseEntitiesWrongDom(): void
{
$this->expectException(\RuntimeException::class);
$this->object->open('wrong xml')->parseEntities();
Expand All @@ -95,21 +96,21 @@ public function testParseEntitiesWrongDom()
* @covers RDFParser::getDom
* @covers RDFParser::getDomXpath
*/
public function testParseMetadatas()
public function testParseMetadatas(): void
{
$metadatas = $this->object
->open(file_get_contents(__DIR__ . '/../../files/ExifTool.xml'))
->ParseMetadatas();

$this->assertInstanceOf('\\PHPExiftool\\Driver\\Metadata\\MetadataBag', $metadatas);
$this->assertEquals(348, count($metadatas));
$this->assertCount(348, $metadatas);
}

/**
* @covers RDFParser::Query
* @covers RDFParser::readNodeValue
*/
public function testQuery()
public function testQuery(): void
{
$xml = "<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
Expand All @@ -136,9 +137,9 @@ public function testQuery()
$this->assertNull($null_datas);
$this->assertNull($null_datas_2);

$this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Mono', $metadata_simple);
$this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Binary', $metadata_base64);
$this->assertInstanceOf('\\PHPExiftool\\Driver\\Value\\Multi', $metadata_multi);
$this->assertInstanceOf(Mono::class, $metadata_simple);
$this->assertInstanceOf(Binary::class, $metadata_base64);
$this->assertInstanceOf(Multi::class, $metadata_multi);

$this->assertEquals('Hello World !', $metadata_simple->asString());
$this->assertEquals('Hello base64 !', $metadata_base64->asString());
Expand Down
Loading