diff --git a/.gitignore b/.gitignore index ed3c1bcfd..280921d4a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ composer.lock /nbproject/ /tests/lib/PHPExiftool/Test/tmp /vendor +/.phpunit.result.cache +/tests/lib/PHPExiftool/tmp +/tests/files/ExifToolCopied.jpg_original diff --git a/.travis.yml b/.travis.yml index f430fa213..49ab22a99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ language: php sudo: false php: - - 5.6 - - 7.0 + - 7.4 + - 8.2 matrix: fast_finish: true diff --git a/README.md b/README.md index d96462710..5e9dd1b09 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The recommended way to install PHP-Exiftool is [through composer](http://getcomp ```JSON { "require": { - "alchemy/phpexiftool": "^0.5.0" + "alchemy/phpexiftool": "^4.0" } } ``` diff --git a/composer.json b/composer.json index f8a2541d1..f4127b791 100644 --- a/composer.json +++ b/composer.json @@ -31,19 +31,19 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.2", "doctrine/cache": "^1.0", "doctrine/collections": "^1.0", "monolog/monolog": "^2.6", "exiftool/exiftool": "*", - "symfony/console": "^5", - "symfony/css-selector": "^5", - "symfony/dom-crawler": "^5", - "symfony/process": "^5", + "symfony/console": "^5 || ^6.2", + "symfony/css-selector": "^5 || ^6.2", + "symfony/dom-crawler": "^5 || ^6.2", + "symfony/process": "^5 || ^6", "ext-dom": "*", "cache/array-adapter": "^1.2", "ext-json": "*", - "symfony/monolog-bridge": "^5.4" + "symfony/monolog-bridge": "^5.4 || ^6.2" }, "suggest": { "jms/serializer": "To serialize tags", @@ -51,9 +51,9 @@ }, "require-dev": { "jms/serializer": "~3", - "phpunit/phpunit": "^5", + "phpunit/phpunit": "^9.6.7", "symfony/finder": "^5", - "symfony/yaml": "^3" + "symfony/yaml": "^5 || ^6" }, "autoload": { "psr-4": { @@ -63,5 +63,8 @@ "autoload-dev": { "psr-4": { } + }, + "scripts": { + "test": "./vendor/bin/phpunit" } } diff --git a/lib/PHPExiftool/Exiftool.php b/lib/PHPExiftool/Exiftool.php index 2552bad62..c2d8a7fbb 100644 --- a/lib/PHPExiftool/Exiftool.php +++ b/lib/PHPExiftool/Exiftool.php @@ -32,11 +32,9 @@ public function __construct(LoggerInterface $logger, ?string $binaryPath = null) /** * {@inheritdoc} */ - public function setLogger(LoggerInterface $logger) + public function setLogger(LoggerInterface $logger): void { $this->logger = $logger; - - return $this; } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ef77ca6c..0411093c9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,7 +7,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" verbose="false" bootstrap="tests/bootstrap.php" > @@ -20,13 +19,5 @@ tests - - - vendor - tests - lib/PHPExiftool/Driver/Tag/* - - - diff --git a/tests/lib/PHPExiftool/PHPExiftoolTest.php b/tests/lib/PHPExiftool/PHPExiftoolTest.php index 1baf3947f..ff00ece3d 100644 --- a/tests/lib/PHPExiftool/PHPExiftoolTest.php +++ b/tests/lib/PHPExiftool/PHPExiftoolTest.php @@ -11,17 +11,12 @@ namespace lib\PHPExiftool; use PHPExiftool\Exception\DirectoryNotFoundException; -use PHPExiftool\Exception\EmptyCollectionException; -use PHPExiftool\Exception\LogicException; -use PHPExiftool\Exception\RuntimeException; use PHPExiftool\PHPExiftool; use PHPExiftool\Reader; -use PHPUnit_Framework_TestCase; -use Symfony\Component\Process\Process; +use PHPUnit\Framework\TestCase; - -class PHPExiftoolTest extends \PHPUnit_Framework_TestCase { +class PHPExiftoolTest extends TestCase { private ?PHPExiftool $PHPExiftool = null; protected static string $tmpDir = ""; diff --git a/tests/lib/PHPExiftool/RDFParserTest.php b/tests/lib/PHPExiftool/RDFParserTest.php index 2ce560a89..8def6498a 100644 --- a/tests/lib/PHPExiftool/RDFParserTest.php +++ b/tests/lib/PHPExiftool/RDFParserTest.php @@ -16,14 +16,15 @@ use PHPExiftool\Exception\LogicException; use PHPExiftool\Exception\ParseErrorException; use PHPExiftool\Exception\RuntimeException; +use PHPUnit\Framework\TestCase; -class RDFParserTest extends \PHPUnit_Framework_TestCase +class RDFParserTest extends TestCase { protected RDFParser $object; protected Logger $logger; - protected function setUp() + protected function setUp(): void { $this->logger = new Logger('Tests'); $this->logger->pushHandler(new NullHandler()); @@ -69,10 +70,10 @@ public function testParseEntities() * @covers RDFParser::getDom * @covers RDFParser::getDomXpath * @covers \PHPExiftool\Exception\LogicException - * @expectedException LogicException */ public function testParseEntitiesWithoutDom() { + $this->expectException(\LogicException::class); $this->object->parseEntities(); } @@ -82,10 +83,10 @@ public function testParseEntitiesWithoutDom() * @covers RDFParser::getDomXpath * @covers \PHPExiftool\Exception\ParseErrorException * @covers \PHPExiftool\Exception\RuntimeException - * @expectedException RuntimeException */ public function testParseEntitiesWrongDom() { + $this->expectException(\RuntimeException::class); $this->object->open('wrong xml')->parseEntities(); } diff --git a/tests/lib/PHPExiftool/ReaderTest.php b/tests/lib/PHPExiftool/ReaderTest.php index 4a06287b0..71a4f2b3a 100644 --- a/tests/lib/PHPExiftool/ReaderTest.php +++ b/tests/lib/PHPExiftool/ReaderTest.php @@ -15,18 +15,18 @@ use PHPExiftool\Exception\RuntimeException; use PHPExiftool\PHPExiftool; use PHPExiftool\Reader; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; -class ReaderTest extends \PHPUnit_Framework_TestCase { +class ReaderTest extends TestCase { private ?PHPExiftool $PHPExiftool = null; protected static string $tmpDir = ""; protected static bool $disableSymLinkTest = false; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -105,7 +105,7 @@ public static function setUpBeforeClass() } - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->PHPExiftool = new PHPExiftool("/tmp"); @@ -119,7 +119,7 @@ private function createReader(): Reader /** * @covers Reader::__destruct */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); } diff --git a/tests/lib/PHPExiftool/Test/AbstractPreviewExtractorTest.php b/tests/lib/PHPExiftool/Test/AbstractPreviewExtractorTest.php index 3c725cf43..9dd12ae64 100644 --- a/tests/lib/PHPExiftool/Test/AbstractPreviewExtractorTest.php +++ b/tests/lib/PHPExiftool/Test/AbstractPreviewExtractorTest.php @@ -11,8 +11,10 @@ namespace lib\PHPExiftool\Test; use lib\PHPExiftool\PreviewExtractor; +use PHPExiftool\Exception\LogicException; +use PHPUnit\Framework\TestCase; -abstract class AbstractPreviewExtractorTest extends \PHPUnit_Framework_TestCase +abstract class AbstractPreviewExtractorTest extends TestCase { /** @@ -49,27 +51,23 @@ public function testExtract() $this->assertEquals(1, $n); } - /** - * @expectedException \lib\PHPExiftool\Exception\LogicException - */ public function testExtractWrongFile() { $extractor = new PreviewExtractor($this->getExiftool()); $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999); + $this->expectException(LogicException::class); $extractor->extract(__DIR__ . '/ExifTool.jpg', $tmpDir); } - /** - * @expectedException \lib\PHPExiftool\Exception\LogicException - */ public function testExtractWrongDir() { $extractor = new PreviewExtractor($this->getExiftool()); $tmpDir = sys_get_temp_dir() . '/tests' . mt_rand(10000, 99999); + $this->expectException(LogicException::class); $extractor->extract(__DIR__ . '/../../../files/ExifTool.jpg', $tmpDir); } diff --git a/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataBagTest.php b/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataBagTest.php index cd7d1c480..467db13fa 100644 --- a/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataBagTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataBagTest.php @@ -11,15 +11,16 @@ namespace lib\PHPExiftool\Test\Driver\Metadata; use PHPExiftool\Driver\Metadata\MetadataBag; +use PHPUnit\Framework\TestCase; -class MetadataBagTest extends \PHPUnit_Framework_TestCase +class MetadataBagTest extends TestCase { /** * @var MetadataBag */ protected $object; - protected function setUp() + protected function setUp(): void { $this->object = new MetadataBag(); } diff --git a/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataTest.php b/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataTest.php index d39416815..801b68c8b 100644 --- a/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/Metadata/MetadataTest.php @@ -13,8 +13,9 @@ use PHPExiftool\Driver\AbstractTagGroup; use PHPExiftool\Driver\Value\Mono; use PHPExiftool\Driver\Metadata\Metadata; +use PHPUnit\Framework\TestCase; -class MetadataTest extends \PHPUnit_Framework_TestCase +class MetadataTest extends TestCase { /** * @var Metadata @@ -26,7 +27,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase /** * @covers Metadata::__construct */ - protected function setUp() + protected function setUp(): void { $this->tag = new TagTest(); $this->value = new Mono('valeur'); diff --git a/tests/lib/PHPExiftool/Test/Driver/TagGroupFactoryTest.php b/tests/lib/PHPExiftool/Test/Driver/TagGroupFactoryTest.php index d8ffde686..0a0b3bec2 100644 --- a/tests/lib/PHPExiftool/Test/Driver/TagGroupFactoryTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/TagGroupFactoryTest.php @@ -14,15 +14,14 @@ use PHPExiftool\Driver\TagGroupInterface; use PHPExiftool\Exception\TagUnknown; use PHPExiftool\PHPExiftool; -use PHPUnit_Framework_TestCase; -// use PHPExiftool\Driver\TagGroup\IPTC\SupplementalCategories; +use PHPUnit\Framework\TestCase; -class TagGroupFactoryTest extends PHPUnit_Framework_TestCase +class TagGroupFactoryTest extends TestCase { protected TagGroupFactory $object; private PHPExiftool $PHPExiftool; - protected function setUp() + protected function setUp(): void { $this->PHPExiftool = new PHPExiftool("/tmp"); } diff --git a/tests/lib/PHPExiftool/Test/Driver/TagGroupTest.php b/tests/lib/PHPExiftool/Test/Driver/TagGroupTest.php index c5c8def29..6ea3255e3 100644 --- a/tests/lib/PHPExiftool/Test/Driver/TagGroupTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/TagGroupTest.php @@ -13,11 +13,12 @@ use PHPExiftool\Driver\HelperInterface; use PHPExiftool\Driver\TagGroupFactory; use PHPExiftool\PHPExiftool; +use PHPUnit\Framework\TestCase; use Symfony\Component\Finder\Finder; use PHPExiftool\Driver\TagGroupInterface; -class TagGroupTest extends \PHPUnit_Framework_TestCase { +class TagGroupTest extends TestCase { /** * @var TagGroupInterface diff --git a/tests/lib/PHPExiftool/Test/Driver/Value/BinaryTest.php b/tests/lib/PHPExiftool/Test/Driver/Value/BinaryTest.php index b37f4053a..2f3d4eb3e 100644 --- a/tests/lib/PHPExiftool/Test/Driver/Value/BinaryTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/Value/BinaryTest.php @@ -13,8 +13,9 @@ use PHPExiftool\Driver\Value\Binary; use PHPExiftool\Driver\Value\ValueInterface; use PHPExiftool\Exception\InvalidArgumentException; +use PHPUnit\Framework\TestCase; -class BinaryTest extends \PHPUnit_Framework_TestCase +class BinaryTest extends TestCase { /** * @var Binary @@ -24,7 +25,7 @@ class BinaryTest extends \PHPUnit_Framework_TestCase /** * @covers Binary::__construct */ - protected function setUp() + protected function setUp(): void { $this->object = new Binary('Binary'); } @@ -74,10 +75,10 @@ public function testSetBase64Value() /** * @covers Binary::setBase64Value * @covers InvalidArgumentException - * @expectedException InvalidArgumentException */ public function testSetWrongBase64Value() { + $this->expectException(InvalidArgumentException::class); $this->object->setBase64Value('Riri Fifi et Loulou !'); } @@ -94,10 +95,10 @@ public function testLoadFromBase64() /** * @covers Binary::loadFromBase64 * @covers InvalidArgumentException - * @expectedException InvalidArgumentException */ public function testLoadFromWrongBase64() { - $object = Binary::loadFromBase64('Uncle Scrooge !!!'); + $this->expectException(InvalidArgumentException::class); + Binary::loadFromBase64('Uncle Scrooge !!!'); } } diff --git a/tests/lib/PHPExiftool/Test/Driver/Value/MonoTest.php b/tests/lib/PHPExiftool/Test/Driver/Value/MonoTest.php index 6c3993346..424a09460 100644 --- a/tests/lib/PHPExiftool/Test/Driver/Value/MonoTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/Value/MonoTest.php @@ -12,8 +12,9 @@ use PHPExiftool\Driver\Value\Mono; use PHPExiftool\Driver\Value\ValueInterface; +use PHPUnit\Framework\TestCase; -class MonoTest extends \PHPUnit_Framework_TestCase +class MonoTest extends TestCase { /** * @var Mono @@ -23,7 +24,7 @@ class MonoTest extends \PHPUnit_Framework_TestCase /** * @covers Mono::__construct */ - protected function setUp() + protected function setUp(): void { $this->object = new Mono('Hello !'); } diff --git a/tests/lib/PHPExiftool/Test/Driver/Value/MultiTest.php b/tests/lib/PHPExiftool/Test/Driver/Value/MultiTest.php index ba83dfc26..d88e7a870 100644 --- a/tests/lib/PHPExiftool/Test/Driver/Value/MultiTest.php +++ b/tests/lib/PHPExiftool/Test/Driver/Value/MultiTest.php @@ -12,8 +12,9 @@ use PHPExiftool\Driver\Value\Multi; use PHPExiftool\Driver\Value\ValueInterface; +use PHPUnit\Framework\TestCase; -class MultiTest extends \PHPUnit_Framework_TestCase +class MultiTest extends TestCase { /** * @var Multi @@ -23,7 +24,7 @@ class MultiTest extends \PHPUnit_Framework_TestCase /** * @covers Multi::__construct */ - protected function setUp() + protected function setUp(): void { $this->object = new Multi(array('hello', 'world !')); } diff --git a/tests/lib/PHPExiftool/Test/ExiftoolTest.php b/tests/lib/PHPExiftool/Test/ExiftoolTest.php index 187f8ed7f..588eec0fa 100644 --- a/tests/lib/PHPExiftool/Test/ExiftoolTest.php +++ b/tests/lib/PHPExiftool/Test/ExiftoolTest.php @@ -16,8 +16,9 @@ use PHPExiftool\Exception\RuntimeException; use PHPExiftool\Exiftool; use lib\PHPExiftool; +use PHPUnit\Framework\TestCase; -class ExiftoolTest extends \PHPUnit_Framework_TestCase +class ExiftoolTest extends TestCase { /** diff --git a/tests/lib/PHPExiftool/Test/FileEntityTest.php b/tests/lib/PHPExiftool/Test/FileEntityTest.php index 6aa06d658..c948a8e9c 100644 --- a/tests/lib/PHPExiftool/Test/FileEntityTest.php +++ b/tests/lib/PHPExiftool/Test/FileEntityTest.php @@ -14,9 +14,9 @@ use Monolog\Logger; use PHPExiftool\FileEntity; use PHPExiftool\RDFParser; -use lib\PHPExiftool; +use PHPUnit\Framework\TestCase; -class FileEntityTest extends \PHPUnit_Framework_TestCase +class FileEntityTest extends TestCase { protected FileEntity $object; protected Logger $logger; @@ -24,7 +24,7 @@ class FileEntityTest extends \PHPUnit_Framework_TestCase /** * @covers FileEntity::__construct */ - protected function setUp() + protected function setUp(): void { $dom = new \DOMDocument(); $dom->loadXML(file_get_contents(__DIR__ . '/../../../files/ExifTool.xml')); @@ -48,7 +48,7 @@ public function testGetIterator() */ public function testGetFile() { - $this->assertInternalType('string', $this->object->getFile()); + $this->assertIsString($this->object->getFile()); } /** @@ -57,7 +57,7 @@ public function testGetFile() public function testGetMetadatas() { $this->assertInstanceOf('\\PHPExiftool\Driver\Metadata\MetadataBag', $this->object->getMetadatas()); - $this->assertEquals(348, count($this->object->getMetadatas())); + $this->assertCount(348, $this->object->getMetadatas()); } /** diff --git a/tests/lib/PHPExiftool/Test/InformationDumperTest.php b/tests/lib/PHPExiftool/Test/InformationDumperTest.php index f62fb8912..971e5d4e8 100644 --- a/tests/lib/PHPExiftool/Test/InformationDumperTest.php +++ b/tests/lib/PHPExiftool/Test/InformationDumperTest.php @@ -16,15 +16,16 @@ use PHPExiftool\InformationDumper; use PHPExiftool\Exiftool; use PHPExiftool\Exception\DirectoryNotFoundException; +use PHPUnit\Framework\TestCase; -class InformationDumperTest extends \PHPUnit_Framework_TestCase +class InformationDumperTest extends TestCase { /** * @var InformationDumper */ protected $object; - protected function setUp() + protected function setUp(): void { $logger = new Logger('Tests'); $logger->pushHandler(new NullHandler()); diff --git a/tests/lib/PHPExiftool/WriterTest.php b/tests/lib/PHPExiftool/WriterTest.php index 5186a1afc..228dd9a63 100644 --- a/tests/lib/PHPExiftool/WriterTest.php +++ b/tests/lib/PHPExiftool/WriterTest.php @@ -16,9 +16,8 @@ use PHPExiftool\PHPExiftool; use PHPExiftool\Writer; use PHPExiftool\Reader; -use PHPExiftool\RDFParser; -use PHPUnit_Framework_TestCase; use PHPExiftool\Exception\EmptyCollectionException; +use PHPUnit\Framework\TestCase; class WriterTester extends Writer { @@ -46,7 +45,7 @@ public function getSyncCommandTester(): array } } -class WriterTest extends PHPUnit_Framework_TestCase +class WriterTest extends TestCase { protected ?PHPExiftool $PHPExiftool = null; protected string $in = ""; @@ -54,7 +53,7 @@ class WriterTest extends PHPUnit_Framework_TestCase protected string $inPlace = ""; protected string $out = ""; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->in = __DIR__ . '/../../files/ExifTool.jpg'; @@ -66,7 +65,7 @@ protected function setUp() $this->PHPExiftool = new PHPExiftool("/tmp"); } - protected function tearDown() + protected function tearDown(): void { if (file_exists($this->out) && is_writable($this->out)) { unlink($this->out);