This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver\Metadata;
use PHPExiftool\Driver\Metadata\MetadataBag;
class MetadataBagTest extends \PHPUnit_Framework_TestCase
{
/**
* @var MetadataBag
*/
protected $object;
protected function setUp()
{
$this->object = new MetadataBag();
}
/**
* @covers PHPExiftool\Driver\Metadata\MetadataBag::filterKeysByRegExp
*/
public function testFilterKeysByRegExp()
{
$this->object->set('oneKey', 'oneValue');
$this->object->set('oneSecondKey', 'anotherValue');
$this->object->set('thirdKey', 'thirdValue');
$this->assertEquals(2, count($this->object->filterKeysByRegExp('/one.*/')));
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver\Metadata;
use PHPExiftool\Driver\AbstractTag;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Metadata\Metadata;
class MetadataTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Metadata
*/
protected $object;
protected $tag;
protected $value;
/**
* @covers \PHPExiftool\Driver\Metadata\Metadata::__construct
*/
protected function setUp()
{
$this->tag = new TagTest();
$this->value = new Mono('valeur');
$this->object = new Metadata(new TagTest, $this->value, new \SplFileInfo(__FILE__));
}
/**
* @covers \PHPExiftool\Driver\Metadata\Metadata::getTag
*/
public function testGetTag()
{
$this->assertEquals($this->object->getTag(), $this->tag);
}
/**
* @covers \PHPExiftool\Driver\Metadata\Metadata::getValue
*/
public function testGetValue()
{
$this->assertEquals($this->object->getValue(), $this->value);
}
}
class TagTest extends AbstractTag
{
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver;
use PHPExiftool\Driver\TagFactory;
class TagFactoryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var TagFactory
*/
protected $object;
/**
* @covers \PHPExiftool\Driver\TagFactory::GetFromRDFTagname
* @covers \PHPExiftool\Driver\TagFactory::classnameFromTagname
*/
public function testGetFromRDFTagname()
{
$tag = TagFactory::getFromRDFTagname('IPTC:SupplementalCategories');
$this->assertInstanceOf('\PHPExiftool\Driver\Tag\IPTC\SupplementalCategories', $tag);
$tag = TagFactory::getFromRDFTagname('XMPExif:ApertureValue');
$this->assertInstanceOf('\PHPExiftool\Driver\Tag\XMPExif\ApertureValue', $tag);
try {
$tag = TagFactory::getFromRDFTagname('XMPExif:AnunexistingTag');
$this->fail('Should raise a TagUnknown exception');
} catch (\PHPExiftool\Exception\TagUnknown $e) {
}
}
/**
* @covers \PHPExiftool\Driver\TagFactory::GetFromRDFTagname
* @covers \PHPExiftool\Exception\TagUnknown
* @expectedException \PHPExiftool\Exception\TagUnknown
*/
public function testGetFromRDFTagnameFail()
{
TagFactory::getFromRDFTagname('XMPExif:AnunexistingTag');
}
/**
* @covers \PHPExiftool\Driver\TagFactory::HasFromRDFTagname
*/
public function testHasFromRDFTagname()
{
$this->assertTrue(TagFactory::hasFromRDFTagname('IPTC:SupplementalCategories'));
$this->assertFalse(TagFactory::hasFromRDFTagname('XMPExif:AnunexistingTag'));
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver;
use PHPExiftool\Driver\TagProvider;
class TagProviderTest extends \PHPUnit_Framework_TestCase
{
private $object;
protected function setUp()
{
$this->object = new TagProvider;
}
public function testGetAll()
{
$this->assertInternalType('array', $this->object->getAll());
}
public function testGetLookupTable()
{
$this->assertInternalType('array', $this->object->getLookupTable());
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver;
use Symfony\Component\Finder\Finder;
class TagTest extends \PHPUnit_Framework_TestCase {
/**
* @var Tag
*/
protected $object;
/**
* @covers \PHPExiftool\Driver\AbstractTag::getDescription
* @covers \PHPExiftool\Driver\AbstractTag::getGroupName
* @covers \PHPExiftool\Driver\AbstractTag::getName
* @covers \PHPExiftool\Driver\AbstractTag::getTagname
* @covers \PHPExiftool\Driver\AbstractTag::getId
* @covers \PHPExiftool\Driver\AbstractTag::getValues
* @covers \PHPExiftool\Driver\AbstractTag::isMulti
* @covers \PHPExiftool\Driver\AbstractTag::isWritable
* @covers \PHPExiftool\Driver\AbstractTag::isBinary
*/
public function testConsistency()
{return;
$finder = new Finder();
$finder->files()->in(array(__DIR__ . '/../../../../../lib/PHPExiftool/Driver/Tag/'));
foreach ($finder as $file) {
$classname = substr(
str_replace(
array(realpath(__DIR__ . '/../../../../../lib'), '/')
, array('', '\\')
, $file->getRealPath()
), 0, -4);
$tag = new $classname;
/* @var $tag \PHPExiftool\Driver\Tag */
$this->assertTrue(is_scalar($tag->getDescription()));
$this->assertTrue(is_scalar($tag->getGroupName()));
$this->assertTrue(is_scalar($tag->getName()));
$this->assertTrue(is_scalar($tag->getTagname()));
$this->assertTrue(is_scalar($tag->getId()));
if ($tag->getValues() !== null)
$this->assertTrue(is_array($tag->getValues()));
if ($tag->isMulti())
$this->assertTrue($tag->isMulti());
else
$this->assertFalse($tag->isMulti());
if ($tag->isWritable())
$this->assertTrue($tag->isWritable());
else
$this->assertFalse($tag->isWritable(), $tag->getTagname() . " is writable");
if ($tag->isBinary())
$this->assertTrue($tag->isBinary());
else
$this->assertFalse($tag->isBinary());
$tag->getMaxLength();
$this->assertEquals(0, $tag->getMinLength());
unset($tag);
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver\Value;
use PHPExiftool\Driver\Value\Binary;
use PHPExiftool\Driver\Value\ValueInterface;
class BinaryTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Binary
*/
protected $object;
/**
* @covers PHPExiftool\Driver\Value\Binary::__construct
*/
protected function setUp()
{
$this->object = new Binary('Binary');
}
/**
* @covers PHPExiftool\Driver\Value\Binary::getType
*/
public function testGetType()
{
$this->assertEquals(ValueInterface::TYPE_BINARY, $this->object->getType());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::asString
*/
public function testAsString()
{
$this->assertEquals('Binary', $this->object->asString());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::asBase64
*/
public function testAsBase64()
{
$this->assertEquals(base64_encode('Binary'), $this->object->asBase64());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::set
*/
public function testSetValue()
{
$this->object->set('Daisy');
$this->assertEquals('Daisy', $this->object->asString());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::setBase64Value
*/
public function testSetBase64Value()
{
$this->object->setBase64Value('UmlyaSBGaWZpIGV0IExvdWxvdQ==');
$this->assertEquals('Riri Fifi et Loulou', $this->object->asString());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::setBase64Value
* @covers \PHPExiftool\Exception\InvalidArgumentException
* @expectedException \PHPExiftool\Exception\InvalidArgumentException
*/
public function testSetWrongBase64Value()
{
$this->object->setBase64Value('Riri Fifi et Loulou !');
}
/**
* @covers PHPExiftool\Driver\Value\Binary::loadFromBase64
*/
public function testLoadFromBase64()
{
$object = Binary::loadFromBase64('VW5jbGUgU2Nyb29nZQ==');
$this->assertEquals('Uncle Scrooge', $object->asString());
$this->assertEquals('VW5jbGUgU2Nyb29nZQ==', $object->asBase64());
}
/**
* @covers PHPExiftool\Driver\Value\Binary::loadFromBase64
* @covers \PHPExiftool\Exception\InvalidArgumentException
* @expectedException \PHPExiftool\Exception\InvalidArgumentException
*/
public function testLoadFromWrongBase64()
{
$object = Binary::loadFromBase64('Uncle Scrooge !!!');
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver\Value;
use PHPExiftool\Driver\Value\Mono;
use PHPExiftool\Driver\Value\ValueInterface;
class MonoTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Mono
*/
protected $object;
/**
* @covers PHPExiftool\Driver\Value\Mono::__construct
*/
protected function setUp()
{
$this->object = new Mono('Hello !');
}
/**
* @covers PHPExiftool\Driver\Value\Mono::getType
*/
public function testGetType()
{
$this->assertEquals(ValueInterface::TYPE_MONO, $this->object->getType());
}
/**
* @covers PHPExiftool\Driver\Value\Mono::asString
*/
public function testAsString()
{
$this->assertEquals('Hello !', $this->object->asString());
}
/**
* @covers PHPExiftool\Driver\Value\Mono::set
*/
public function testSetValue()
{
$this->object->set('World !');
$this->assertEquals('World !', $this->object->asString());
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* This file is part of the PHPExiftool package.
*
* (c) Alchemy <support@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPExiftool\Test\Driver\Value;
use PHPExiftool\Driver\Value\Multi;
use PHPExiftool\Driver\Value\ValueInterface;
class MultiTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Multi
*/
protected $object;
/**
* @covers PHPExiftool\Driver\Value\Multi::__construct
*/
protected function setUp()
{
$this->object = new Multi(array('hello', 'world !'));
}
/**
* @covers PHPExiftool\Driver\Value\Multi::getType
*/
public function testGetType()
{
$this->assertEquals(ValueInterface::TYPE_MULTI, $this->object->getType());
}
/**
* @covers PHPExiftool\Driver\Value\Multi::asArray
*/
public function testAsArray()
{
$this->assertEquals(array('hello', 'world !'), $this->object->asArray());
}
/**
* @covers PHPExiftool\Driver\Value\Multi::addValue
*/
public function testAddValue()
{
$this->object->addValue('tim');
$this->assertEquals(array('hello', 'world !', 'tim'), $this->object->asArray());
}
/**
* @covers PHPExiftool\Driver\Value\Multi::reset
*/
public function testReset()
{
$this->object->reset();
$this->assertEquals(array(), $this->object->asArray());
}
}