Delegate all exiftool commands to PHPExiftool

This commit is contained in:
Romain Neutron
2012-05-04 20:17:17 +02:00
parent 26a823dcc2
commit 135420008b
17 changed files with 372 additions and 458 deletions

View File

@@ -4,18 +4,23 @@ require_once __DIR__ . '/PhraseanetPHPUnitAbstract.class.inc';
class unicodeTest extends PhraseanetPHPUnitAbstract
{
/**
* @var unicode
*/
protected $object;
/**
* @covers \unicode::__construct
*/
public function setUp()
{
parent::setUp();
$this->object = new unicode();
}
/**
* @covers \unicode::remove_diacritics
*/
public function testRemove_diacritics()
{
$this->assertEquals('Elephant', $this->object->remove_diacritics('Eléphant'));
@@ -23,6 +28,9 @@ class unicodeTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('PeTARDS', $this->object->remove_diacritics('PéTARDS'));
}
/**
* @covers \unicode::remove_nonazAZ09
*/
public function testRemove_nonazAZ09()
{
$this->assertEquals('Elephant', $this->object->remove_nonazAZ09('Eléphant'));
@@ -33,6 +41,9 @@ class unicodeTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('PeTARDS', $this->object->remove_nonazAZ09('PéTARDS'));
}
/**
* @covers \unicode::remove_first_digits
*/
public function testRemove_first_digits()
{
$this->assertEquals('', $this->object->remove_first_digits('123456789'));
@@ -41,5 +52,44 @@ class unicodeTest extends PhraseanetPHPUnitAbstract
$this->assertEquals('a2b5cdeé', $this->object->remove_first_digits('4a2b5cdeé'));
}
public function testSubstituteCtrlCharacters()
{
$string = 'Hello' . chr(30) . 'World !';
$this->assertEquals('Hello+World !', $this->object->substituteCtrlCharacters($string, '+'));
$string = 'Hello' . chr(9) . 'World !';
$this->assertEquals($string, $this->object->substituteCtrlCharacters($string, '+'));
}
/**
* @covers \unicode::toUTF8
*/
public function testToUTF8()
{
$reference = 'Un éléphant ça trompe énormément !';
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/MacOSRoman.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/ISOLatin1.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/ISOLatin2.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/Latin5.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/UTF-8.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/WindowsLatin1.txt')));
$this->assertEquals($reference, $this->object->toUTF8(file_get_contents(__DIR__ . '/testfiles/WindowsLatin2.txt')));
}
/**
* @covers \unicode::parseDate
*/
public function testparseDate()
{
$date = '2012';
$this->assertEquals('2012/00/00 00:00:00', $this->object->parseDate('2012'));
$this->assertEquals('2012/01/00 00:00:00', $this->object->parseDate('2012-01'));
$this->assertEquals('2012/03/15 00:00:00', $this->object->parseDate('2012-03-15'));
$this->assertEquals('2012/03/15 12:00:00', $this->object->parseDate('2012-03-15 12'));
$this->assertEquals('2012/03/15 12:11:00', $this->object->parseDate('2012-03-15 12:11'));
$this->assertEquals('2012/03/15 12:12:12', $this->object->parseDate('2012-03-15 12-12-12'));
}
}