mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
EZ-Components
This commit is contained in:
@@ -0,0 +1,818 @@
|
||||
<?php
|
||||
/**
|
||||
* ezcConsoleToolsOutputTest
|
||||
*
|
||||
* @package ImageAnalysis
|
||||
* @version 1.1.3
|
||||
* @subpackage Tests
|
||||
* @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
|
||||
* @license http://ez.no/licenses/new_bsd New BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test suite for ImageAnalyzer class.
|
||||
*
|
||||
* @package ImageAnalysis
|
||||
* @subpackage Tests
|
||||
*/
|
||||
class ezcImageAnalysisAnalyzerTest extends ezcTestCase
|
||||
{
|
||||
|
||||
protected $basePath;
|
||||
|
||||
protected $testFiles = array(
|
||||
'exif_jpeg' => 'jpeg_exif.jpg',
|
||||
'noexif_jpeg' => 'jpeg_noexif.jpg',
|
||||
'exif_tiff' => 'tiff_exif.tiff',
|
||||
'noexif_tiff' => 'tiff_noexif.tiff',
|
||||
'animated_gif' => 'gif_animated.gif',
|
||||
'noanimated_gif' => 'gif_nonanimated.gif',
|
||||
'noanimated_png' => 'png_nonanimated.png',
|
||||
'svg' => 'svg.svg',
|
||||
);
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
return new PHPUnit_Framework_TestSuite( "ezcImageAnalysisAnalyzerTest" );
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if ( !ezcBaseFeatures::hasExtensionSupport( 'exif' ) )
|
||||
{
|
||||
$this->markTestSkipped( 'ext/exif is required to run this test.' );
|
||||
}
|
||||
|
||||
$this->basePath = dirname( __FILE__ ) . '/data/';
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeJpegExif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/jpeg',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeJpegExif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/jpeg',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeJpegNoexif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/jpeg',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeJpegNoexif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/jpeg',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeTiffExif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_tiff'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/tiff',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeTiffExif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_tiff'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/tiff',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeTiffNoexif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_tiff'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/tiff',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeTiffNoexif()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_tiff'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/tiff',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeGifNonanimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_gif'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/gif',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeGifNonanimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_gif'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/gif',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimeGifAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['animated_gif'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/gif',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimeGifAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['animated_gif'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/gif',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerGetMimePngNonanimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_png'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/png',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for PNG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerGetMimePngNonanimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_png'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
'image/png',
|
||||
$analyzer->mime,
|
||||
'MIME-Type was not determined correctly for PNG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerJpegExifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
' ',
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
76383,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerJpegExifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for JPEG.'
|
||||
);
|
||||
// @FIXME: update test case, as soon as Exif works here.
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
76383,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
// @FIXME: update test case, as soon as Exif works here.
|
||||
/*
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for JPEG.'
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
public function testPhpHandlerJpegNoexifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
68802,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerJpegNoexifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
68802,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerTiffExifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_tiff'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
108125,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerTiffExifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_tiff'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for TIFF.'
|
||||
);
|
||||
// FIXME: Exif does not show comment, but ImageMagick does!!!
|
||||
$this->assertSame(
|
||||
'A simple comment in a TIFF file.',
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
108125,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerTiffNoexifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_tiff'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
108043,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerTiffNoexifReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_tiff'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
399,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
600,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isColor,
|
||||
'<isColor> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
null,
|
||||
$analyzer->data->comment,
|
||||
'<comment> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
108043,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for TIFF.'
|
||||
);
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->hasThumbnail,
|
||||
'<hasThumbnail> not extracted correctly for TIFF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerPngReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_png'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
160,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for PNG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
120,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for PNG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
5420,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for PNG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerPngReportsDetails()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_png'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
160,
|
||||
$analyzer->data->width,
|
||||
'<width> not extracted correctly for PNG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
120,
|
||||
$analyzer->data->height,
|
||||
'<height> not extracted correctly for PNG.'
|
||||
);
|
||||
$this->assertSame(
|
||||
5420,
|
||||
$analyzer->data->size,
|
||||
'<size> not extracted correctly for PNG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerAnimatedGifReportsAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['animated_gif'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerAnimatedGifReportsAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['animated_gif'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
true,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerNoexifJpegReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> no extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerNoexifJpegReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noexif_jpeg'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> no extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerNonanimatedGifReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_gif'];
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerNonanimatedGifReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['noanimated_gif'];
|
||||
$analyzer = $this->getAnalyzerImagemagickHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for GIF.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhpHandlerExifJpegReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
|
||||
// Test Php handler
|
||||
$analyzer = $this->getAnalyzerPhpHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerExifJpegReportsNotAnimated()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['exif_jpeg'];
|
||||
|
||||
// Test ImageMagick handler
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
$this->assertSame(
|
||||
false,
|
||||
$analyzer->data->isAnimated,
|
||||
'<isAnimated> not extracted correctly for JPEG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testSvgMimeType()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['svg'];
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
$this->assertEquals(
|
||||
"image/svg+xml",
|
||||
$analyzer->mime,
|
||||
'<mime> not extracted correctly for SVG.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAnalyzerGeneralNotProcessable()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected function getAnalyzerPhpHandler( $file )
|
||||
{
|
||||
ezcImageAnalyzer::setHandlerClasses( array( 'ezcImageAnalyzerPhpHandler' => array() ) );
|
||||
return new ezcImageAnalyzer( $file );
|
||||
}
|
||||
|
||||
protected function getAnalyzerImageMagickHandler( $file )
|
||||
{
|
||||
ezcImageAnalyzer::setHandlerClasses( array( 'ezcImageAnalyzerImagemagickHandler' => array() ) );
|
||||
return new ezcImageAnalyzer( $file );
|
||||
}
|
||||
|
||||
public function testPropertiesGetInvalid()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['svg'];
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
try
|
||||
{
|
||||
$analyzer->no_such_property;
|
||||
$this->fail( 'Expected exception was not thrown.' );
|
||||
}
|
||||
catch ( ezcBasePropertyNotFoundException $e )
|
||||
{
|
||||
$expected = "No such property name 'no_such_property'.";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testPropertiesSetDenied()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['svg'];
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
try
|
||||
{
|
||||
$analyzer->mime = 'some value';
|
||||
$this->fail( 'Expected exception was not thrown.' );
|
||||
}
|
||||
catch ( ezcBasePropertyPermissionException $e )
|
||||
{
|
||||
$expected = "The property 'mime' is read-only.";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testPropertiesSetInvalid()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['svg'];
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
try
|
||||
{
|
||||
$analyzer->no_such_property = 'some value';
|
||||
$this->fail( 'Expected exception was not thrown.' );
|
||||
}
|
||||
catch ( ezcBasePropertyNotFoundException $e )
|
||||
{
|
||||
$expected = "No such property name 'no_such_property'.";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerNonExistentFile()
|
||||
{
|
||||
$fileName = $this->basePath . "no_such_file.svg";
|
||||
try
|
||||
{
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $fileName );
|
||||
$this->fail( 'Expected exception was not thrown' );
|
||||
}
|
||||
catch ( ezcBaseFileNotFoundException $e )
|
||||
{
|
||||
$expected = "The file '{$fileName}' could not be found.";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerUnreadableFile()
|
||||
{
|
||||
$tempDir = $this->createTempDir( 'ezcImageAnalysisAnalyzerTest' );
|
||||
$fileName = $tempDir . "/test-unreadable.svg";
|
||||
$fileHandle = fopen( $fileName, "wb" );
|
||||
fwrite( $fileHandle, "some contents" );
|
||||
fclose( $fileHandle );
|
||||
chmod( $fileName, 0 );
|
||||
|
||||
try
|
||||
{
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $fileName );
|
||||
$this->fail( 'Expected exception was not thrown' );
|
||||
}
|
||||
catch ( ezcBaseFilePermissionException $e )
|
||||
{
|
||||
$this->removeTempDir();
|
||||
$expected = "The file '{$fileName}' can not be opened for reading.";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testImagemagickHandlerNotProcessableFile()
|
||||
{
|
||||
$tempDir = $this->createTempDir( 'ezcImageAnalysisAnalyzerTest' );
|
||||
$fileName = $tempDir . "/test-unreadable.svg";
|
||||
$fileHandle = fopen( $fileName, "wb" );
|
||||
fwrite( $fileHandle, "some contents" );
|
||||
fclose( $fileHandle );
|
||||
|
||||
try
|
||||
{
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $fileName );
|
||||
$this->fail( 'Expected exception was not thrown' );
|
||||
}
|
||||
catch ( ezcImageAnalyzerFileNotProcessableException $e )
|
||||
{
|
||||
$this->removeTempDir();
|
||||
$expected = "Could not process file '{$fileName}'. Reason: Could not determine MIME type of file..";
|
||||
$this->assertEquals( $expected, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetHandlerClasses()
|
||||
{
|
||||
ezcImageAnalyzer::getHandlerClasses();
|
||||
}
|
||||
|
||||
public function testIsSet()
|
||||
{
|
||||
$file = $this->basePath . $this->testFiles['svg'];
|
||||
$analyzer = $this->getAnalyzerImageMagickHandler( $file );
|
||||
$this->assertEquals( true, isset( $analyzer->mime ) );
|
||||
$this->assertEquals( true, isset( $analyzer->data ) );
|
||||
$this->assertEquals( false, isset( $analyzer->no_such_property ) );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://web.resource.org/cc/"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="50"
|
||||
height="10"
|
||||
id="svg2"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.44.1"
|
||||
version="1.0"
|
||||
sodipodi:docbase="/home/dotxp/dev/ez/ezcomponents/trunk/ImageConversion/tests/data/compare"
|
||||
sodipodi:docname="test.svg">
|
||||
<defs
|
||||
id="defs4" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
gridtolerance="10000"
|
||||
guidetolerance="10"
|
||||
objecttolerance="10"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="15.607172"
|
||||
inkscape:cx="22.203569"
|
||||
inkscape:cy="2.3158231"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
width="50px"
|
||||
height="10px"
|
||||
inkscape:window-width="1099"
|
||||
inkscape:window-height="874"
|
||||
inkscape:window-x="180"
|
||||
inkscape:window-y="179" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<path
|
||||
style="font-size:12px;font-style:normal;font-weight:normal;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
|
||||
d="M 11.562077,0.61122227 L 18.962467,0.61122227 L 18.962467,1.607316 L 15.856998,1.607316 L 15.856998,9.3592691 L 14.667545,9.3592691 L 14.667545,1.607316 L 11.562077,1.607316 L 11.562077,0.61122227 M 25.677311,5.8084879 L 25.677311,6.3358316 L 20.72028,6.3358316 C 20.767153,7.0780214 20.989809,7.6444271 21.388248,8.0350504 C 21.790589,8.4217701 22.349183,8.6151293 23.06403,8.6151285 C 23.478088,8.6151293 23.878478,8.5643481 24.265202,8.4627848 C 24.655821,8.3612233 25.042539,8.2088797 25.425358,8.0057535 L 25.425358,9.0252848 C 25.038633,9.1893474 24.642149,9.3143473 24.235905,9.4002848 C 23.82965,9.4862221 23.417541,9.5291908 22.999577,9.529191 C 21.952699,9.5291908 21.122621,9.2245037 20.509342,8.6151285 C 19.899966,8.0057549 19.595279,7.1815369 19.59528,6.1424723 C 19.595279,5.0682578 19.884341,4.2166962 20.462467,3.5877848 C 21.044496,2.9549787 21.827699,2.6385727 22.812077,2.638566 C 23.694884,2.6385727 24.392149,2.9237287 24.903873,3.4940348 C 25.419492,4.0604463 25.677304,4.8319299 25.677311,5.8084879 M 24.599186,5.4920816 C 24.591368,4.9022423 24.425352,4.4315397 24.101139,4.0799723 C 23.780822,3.7284154 23.355041,3.5526343 22.823795,3.5526285 C 22.22223,3.5526343 21.739808,3.722556 21.37653,4.0623941 C 21.017153,4.4022428 20.810122,4.880758 20.755436,5.497941 L 24.599186,5.4920816 M 31.630436,2.9901285 L 31.630436,4.0096598 C 31.325743,3.8534153 31.009338,3.7362279 30.681217,3.6580973 C 30.353088,3.579978 30.013245,3.5409156 29.661686,3.5409098 C 29.126527,3.5409156 28.724184,3.6229468 28.454655,3.7870035 C 28.189028,3.9510714 28.056215,4.1971649 28.056217,4.5252848 C 28.056215,4.7752894 28.151918,4.9725548 28.343327,5.1170816 C 28.534731,5.2577107 28.919496,5.3924762 29.497623,5.5213785 L 29.866764,5.6034098 C 30.632385,5.7674759 31.175353,5.9998975 31.49567,6.3006754 C 31.819884,6.5975532 31.981993,7.0135684 31.981998,7.5487223 C 31.981993,8.1580985 31.739806,8.6405199 31.255436,8.9959879 C 30.774963,9.3514566 30.112854,9.5291908 29.269108,9.529191 C 28.917543,9.5291908 28.550356,9.4940346 28.167545,9.4237223 C 27.788638,9.357316 27.388247,9.2557536 26.966373,9.1190348 L 26.966373,8.0057535 C 27.36481,8.2127859 27.757388,8.3690358 28.144108,8.4745035 C 28.530824,8.5760668 28.913636,8.626848 29.292545,8.6268473 C 29.800354,8.626848 30.190979,8.5409106 30.46442,8.3690348 C 30.737853,8.1932547 30.874572,7.9471612 30.874577,7.6307535 C 30.874572,7.3377868 30.774963,7.1131776 30.575748,6.9569254 C 30.380432,6.800678 29.948792,6.6502875 29.280827,6.5057535 L 28.905827,6.4178629 C 28.237856,6.277241 27.755435,6.0623974 27.458561,5.7733316 C 27.161685,5.4803668 27.013248,5.0799765 27.013248,4.5721598 C 27.013248,3.9549777 27.231998,3.4784156 27.669498,3.1424723 C 28.106997,2.8065413 28.72809,2.6385727 29.53278,2.638566 C 29.931214,2.6385727 30.306213,2.6678696 30.65778,2.7264566 C 31.009338,2.785057 31.333556,2.8729475 31.630436,2.9901285 M 34.771061,0.93348789 L 34.771061,2.7967691 L 36.991764,2.7967691 L 36.991764,3.6346598 L 34.771061,3.6346598 L 34.771061,7.1971598 C 34.771059,7.7323176 34.843324,8.0760673 34.987858,8.2284098 C 35.136293,8.3807545 35.435121,8.4569263 35.884342,8.4569254 L 36.991764,8.4569254 L 36.991764,9.3592691 L 35.884342,9.3592691 C 35.052308,9.3592691 34.47809,9.2049724 34.161686,8.8963785 C 33.845278,8.5838793 33.687075,8.0174736 33.687077,7.1971598 L 33.687077,3.6346598 L 32.896061,3.6346598 L 32.896061,2.7967691 L 33.687077,2.7967691 L 33.687077,0.93348789 L 34.771061,0.93348789"
|
||||
id="text1872" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* ezcImageAnalysisSuite
|
||||
*
|
||||
* @package ImageAnalysis
|
||||
* @subpackage Tests
|
||||
* @version 1.1.3
|
||||
* @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
|
||||
* @license LGPL {@link http://www.gnu.org/copyleft/lesser.html}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Require test suite for ImageAnalyzer class.
|
||||
*/
|
||||
require_once 'analyzer_test.php';
|
||||
|
||||
/**
|
||||
* Test suite for ImageAnalysis package.
|
||||
*
|
||||
* @package ImageAnalysis
|
||||
* @subpackage Tests
|
||||
*/
|
||||
class ezcImageAnalysisSuite extends PHPUnit_Framework_TestSuite
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setName( "ImageAnalysis" );
|
||||
$this->addTest( ezcImageAnalysisAnalyzerTest::suite() );
|
||||
}
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
return new ezcImageAnalysisSuite( "ezcImageAnalysisSuite" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user