From 4d719250130006ee483c7ffa54648589ab1fc9ed Mon Sep 17 00:00:00 2001 From: Andreas Heigl Date: Wed, 25 May 2016 07:36:22 +0200 Subject: [PATCH] Modifies lib to namespaces --- .gitignore | 1 + composer.json | 29 +++ phpunit.xml.dist | 27 +++ .../DeviceInterface.php} | 31 +-- .../Heigl/Ghostscript => }/Device/Jpeg.php | 65 +++--- .../Heigl/Ghostscript => }/Device/Png.php | 75 +++---- src/{Org/Heigl => }/Ghostscript.php | 198 +++++++++-------- tests/AllTests.php | 69 ------ tests/Device/JpegTest.php | 79 +++++++ tests/Device/PngTest.php | 86 ++++++++ tests/GhostscriptTest.php | 203 ++++++++++++++++++ tests/Org/Heigl/AllTests.php | 74 ------- .../Heigl/Ghostscript/Device/AbstractTest.php | 77 ------- .../Org/Heigl/Ghostscript/Device/AllTests.php | 76 ------- .../Org/Heigl/Ghostscript/Device/JpegTest.php | 89 -------- .../Org/Heigl/Ghostscript/Device/PngTest.php | 95 -------- tests/Org/Heigl/GhostscriptTest.php | 202 ----------------- tests/TestConfiguration.php | 43 ---- .../Heigl/Ghostscript => }/support/test.pdf | Bin 19 files changed, 605 insertions(+), 914 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 phpunit.xml.dist rename src/{Org/Heigl/Ghostscript/Device/Abstract.php => Device/DeviceInterface.php} (74%) rename src/{Org/Heigl/Ghostscript => }/Device/Jpeg.php (71%) rename src/{Org/Heigl/Ghostscript => }/Device/Png.php (71%) rename src/{Org/Heigl => }/Ghostscript.php (71%) delete mode 100644 tests/AllTests.php create mode 100644 tests/Device/JpegTest.php create mode 100644 tests/Device/PngTest.php create mode 100644 tests/GhostscriptTest.php delete mode 100644 tests/Org/Heigl/AllTests.php delete mode 100644 tests/Org/Heigl/Ghostscript/Device/AbstractTest.php delete mode 100644 tests/Org/Heigl/Ghostscript/Device/AllTests.php delete mode 100644 tests/Org/Heigl/Ghostscript/Device/JpegTest.php delete mode 100644 tests/Org/Heigl/Ghostscript/Device/PngTest.php delete mode 100644 tests/Org/Heigl/GhostscriptTest.php delete mode 100644 tests/TestConfiguration.php rename tests/{Org/Heigl/Ghostscript => }/support/test.pdf (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57872d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8e9fa34 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "org_heigl/ghostscript", + "description": "A PHP-Wrapper around the Ghostscript-CLI", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Andreas Heigl", + "email": "andreas@heigl.org" + } + ], + "autoload" : { + "psr-4" : { + "Org_Heigl\\Ghostscript\\" : "src/" + } + }, + "autoload-dev" : { + "psr-4" : { + "Org_Heigl\\GhostscriptTest\\" : "tests/" + } + }, + "require-dev": { + "phpunit/phpunit": "^4.8||^5.3", + "fabpot/php-cs-fixer": "^1.11" + }, + "scripts" : { + "csfix" : "./vendor/bin/php-cs-fixer fix . --level=psr2" + } +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..99a9003 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,27 @@ + + + + ./tests + + + + + disable + + + + + + src + + + + + + + + diff --git a/src/Org/Heigl/Ghostscript/Device/Abstract.php b/src/Device/DeviceInterface.php similarity index 74% rename from src/Org/Heigl/Ghostscript/Device/Abstract.php rename to src/Device/DeviceInterface.php index 8bdc55b..d25124a 100644 --- a/src/Org/Heigl/Ghostscript/Device/Abstract.php +++ b/src/Device/DeviceInterface.php @@ -1,8 +1,6 @@ + * Copyright (c) Andreas Heigl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,51 +20,40 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl - * @copyright 2008-2009 Andreas Heigl + * @copyright Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ +namespace Org_Heigl\Ghostscript\Device; + /** * This abstract class defines interfaces for Ghostscript devices * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl * @copyright 2008-2009 Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ -abstract class Org_Heigl_Ghostscript_Device_Abstract +interface DeviceInterface { /** * Get the name of the device as Ghostscript expects it * * @return string */ - abstract public function getDevice (); + public function getDevice(); /** * Get the complete parameter string for this device * * @return string */ - public function getParameterString () { - return ''; - } + public function getParameterString(); /** * Get the ending of the file * * @return string */ - abstract function getFileEnding (); - -} \ No newline at end of file + public function getFileEnding(); +} diff --git a/src/Org/Heigl/Ghostscript/Device/Jpeg.php b/src/Device/Jpeg.php similarity index 71% rename from src/Org/Heigl/Ghostscript/Device/Jpeg.php rename to src/Device/Jpeg.php index bf20c64..38b96fa 100644 --- a/src/Org/Heigl/Ghostscript/Device/Jpeg.php +++ b/src/Device/Jpeg.php @@ -1,8 +1,6 @@ + * Copyright (c) Andreas Heigl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,39 +20,37 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl - * @copyright 2008-2009 Andreas Heigl + * @copyright Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ -/** Org_Heigl_Ghostscript_Device_Abstract */ -require_once 'Org/Heigl/Ghostscript/Device/Abstract.php'; + +namespace Org_Heigl\Ghostscript\Device; /** * This abstract class defines interfaces for Ghostscript devices * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl * @copyright 2008-2009 Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ -class Org_Heigl_Ghostscript_Device_Jpeg extends Org_Heigl_Ghostscript_Device_Abstract +class Jpeg implements DeviceInterface { + /** + * The quality of the JPEG + * + * @var int $_quality + */ + protected $_quality = 75; + /** * Get the name of the device as Ghostscript expects it * * @return string */ - public function getDevice () { + public function getDevice() + { return 'jpeg'; } @@ -63,11 +59,12 @@ public function getDevice () { * * @return string */ - public function getParameterString () { + public function getParameterString() + { $string = ''; - $string .= ' -sDEVICE=' . $this -> getDevice (); - $string .= ' -dJPEGQ=' . $this -> getQuality (); - $string .= ' -dQFactor=' . 1 / 100 * $this -> getQuality (); + $string .= ' -sDEVICE=' . $this -> getDevice(); + $string .= ' -dJPEGQ=' . $this -> getQuality(); + $string .= ' -dQFactor=' . 1 / 100 * $this -> getQuality(); return $string; } @@ -79,16 +76,17 @@ public function getParameterString () { * * @param int $quality * - * @return Org_Heigl_Ghostscript_Device_Jpeg + * @return Jpeg */ - public function setQuality ( $quality ) { + public function setQuality($quality) + { $quality = (int) $quality; - if ( 100 < $quality ) { + if (100 < $quality) { $quality = 100; } - if ( 0 > $quality ) { + if (0 > $quality) { $quality = 0; } @@ -102,23 +100,18 @@ public function setQuality ( $quality ) { * * @return int */ - public function getQuality () { + public function getQuality() + { return $this -> _quality; } - /** - * The quality of the JPEG - * - * @var int $_quality - */ - protected $_quality = 75; - /** * Get the file ending * * @return string */ - public function getFileEnding () { + public function getFileEnding() + { return 'jpeg'; } -} \ No newline at end of file +} diff --git a/src/Org/Heigl/Ghostscript/Device/Png.php b/src/Device/Png.php similarity index 71% rename from src/Org/Heigl/Ghostscript/Device/Png.php rename to src/Device/Png.php index 131167d..60445ec 100644 --- a/src/Org/Heigl/Ghostscript/Device/Png.php +++ b/src/Device/Png.php @@ -1,8 +1,6 @@ + * Copyright (c) Andreas Heigl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,32 +20,21 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl - * @copyright 2008-2009 Andreas Heigl + * @copyright Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ -/** Org_Heigl_Ghostscript_Device_Abstract */ -require_once 'Org/Heigl/Ghostscript/Device/Abstract.php'; +namespace Org_Heigl\Ghostscript\Device; /** * This class defines interfaces for the PNG-Driver family for Ghostscript * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage Devices * @author Andreas Heigl * @copyright 2008-2009 Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 04.06.2009 */ -class Org_Heigl_Ghostscript_Device_Png extends Org_Heigl_Ghostscript_Device_Abstract +class Png implements DeviceInterface { /** * Exactly what driver shall be used. @@ -59,12 +46,21 @@ class Org_Heigl_Ghostscript_Device_Png extends Org_Heigl_Ghostscript_Device_Abst */ protected $_device = 'pngalpha'; + /** + * The Background-Color of the PNG + * + * @var string $_color + */ + protected $_color = null; + + /** * Get the name of the device as Ghostscript expects it * * @return string */ - public function getDevice () { + public function getDevice() + { return $this -> _device; } @@ -78,12 +74,12 @@ public function getDevice () { * * @param string $device * - * @return Org_Heigl_Ghostsccript_Driver_Png + * @return Png */ - public function setDevice ( $device ) { - - $device = strtolower ( $device ); - $devices = array ( + public function setDevice($device) + { + $device = strtolower($device); + $devices = array( 'pngalpha', 'png16m', 'png256', @@ -91,7 +87,7 @@ public function setDevice ( $device ) { 'pnggray', 'pngmono' ); - if ( ! in_array ( $device, $devices ) ) { + if (! in_array($device, $devices)) { $this -> _device = 'pngalpha'; } else { $this -> _device = $device; @@ -105,10 +101,11 @@ public function setDevice ( $device ) { * * @return string */ - public function getParameterString () { - $string = ' -sDEVICE=' . $this -> getDevice (); - if ( ( 'pngalpha' === $this -> getDevice () ) && ( null !== $this -> getBackgroundColor () ) ) { - $string .= ' -dBackgroundColor=16#' . $this -> getBackgroundColor (); + public function getParameterString() + { + $string = ' -sDEVICE=' . $this -> getDevice(); + if (('pngalpha' === $this -> getDevice()) && (null !== $this -> getBackgroundColor())) { + $string .= ' -dBackgroundColor=16#' . $this -> getBackgroundColor(); } return $string; @@ -121,11 +118,11 @@ public function getParameterString () { * * @param string $color * - * @return Org_Heigl_Ghostscript_Device_Png + * @return Png */ - public function setBackgroundColor ( $color ) { - - if ( ! preg_match ( '/^[a-fA-F0-9]{6}$/', $color ) ) { + public function setBackgroundColor($color) + { + if (! preg_match('/^[a-fA-F0-9]{6}$/', $color)) { $color = null; } @@ -139,22 +136,18 @@ public function setBackgroundColor ( $color ) { * * @return string */ - public function getBackgroundColor () { + public function getBackgroundColor() + { return $this -> _color; } - /** - * The Background-Color of the PNG - * - * @var string $_color - */ - protected $_color = null; /** * Get the file ending * * @return string */ - public function getFileEnding () { + public function getFileEnding() + { return 'png'; } -} \ No newline at end of file +} diff --git a/src/Org/Heigl/Ghostscript.php b/src/Ghostscript.php similarity index 71% rename from src/Org/Heigl/Ghostscript.php rename to src/Ghostscript.php index acdd2bd..a2644da 100644 --- a/src/Org/Heigl/Ghostscript.php +++ b/src/Ghostscript.php @@ -1,8 +1,6 @@ + * Copyright (c) Andreas Heigl * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,17 +20,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * This is the ant-buildfile - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript * @author Andreas Heigl - * @copyright 2008 Andreas Heigl + * @copyright Andreas Heigl * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 */ +namespace Org_Heigl\Ghostscript; + +use Org_Heigl\Ghostscript\Device\DeviceInterface; + /** * This class contains a wrapper around the Ghostscript-Application. * @@ -106,7 +102,7 @@ * @version SVN: $Revision$ * @since 03.06.2009 */ -class Org_Heigl_Ghostscript +class Ghostscript { /** * This property contains the path to the Ghostscript-Application @@ -140,7 +136,7 @@ class Org_Heigl_Ghostscript * * @var array $supportedMimeTypes */ - private static $supportedMimeTypes = array ( + private static $supportedMimeTypes = array( 'application/eps', 'application/pdf', 'application/ps', @@ -159,14 +155,19 @@ class Org_Heigl_Ghostscript * * @return string */ - public static function setGsPath ( $path = null ) { - if ( null === $path ) { - $path = exec( 'which gs' ); + public static function setGsPath($path = null) + { + if (null === $path) { + $path = exec('which gs', $output); + if (! $output) { + throw new \UnexpectedValueException('No Ghostscript-instance found or running on windows. Please provide Path to the Ghostscript-executable'); + } + $path = $output[0]; } - if ( $path ) { - Org_Heigl_Ghostscript::$PATH = $path; + if ($path) { + Ghostscript::$PATH = $path; } - return Org_Heigl_Ghostscript::$PATH; + return Ghostscript::$PATH; } /** @@ -174,8 +175,9 @@ public static function setGsPath ( $path = null ) { * * @return string */ - public static function getGsPath () { - return Org_Heigl_Ghostscript::$PATH; + public static function getGsPath() + { + return Ghostscript::$PATH; } @@ -188,17 +190,19 @@ public static function getGsPath () { * @param string|SplFileInfo $file The File to use as input. * * @throws InvalidArgumentException when the provided file is not supported - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setInputFile ( $file ) { - if ( ! $file instanceof SplFileInfo ) { - $file = new SplFileInfo ( (string) $file ); + public function setInputFile($file) + { + if (! $file instanceof \SplFileInfo) { + $file = new \SplFileInfo((string) $file); } - if ( extension_loaded ( 'fileinfo' ) ) { - $finfo = new finfo (); - $mime = $finfo -> file ( $file -> getPathName (), FILEINFO_MIME ); - if ( ! in_array ( $mime, Org_Heigl_Ghostscript::$supportedMimeTypes ) ) { - throw new InvalidArgumentException ( 'The provided file seems not to be of a supported MIME-Type' ); + if (extension_loaded('fileinfo') && file_exists($file)) { + $finfo = new \finfo(); + $mime = $finfo->file($file->getPathName(), FILEINFO_MIME); + $mime = explode(';', $mime); + if (! in_array($mime[0], Ghostscript::$supportedMimeTypes)) { + throw new \InvalidArgumentException('The provided file seems not to be of a supported MIME-Type'); } } $this -> _infile = $file; @@ -210,7 +214,8 @@ public function setInputFile ( $file ) { * * @return SplFileInfo */ - public function getInputFile () { + public function getInputFile() + { return $this -> _infile; } @@ -226,11 +231,12 @@ public function getInputFile () { * * @param string $name The filename * - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setOutputFile ( $name = 'output' ) { - if ( 0 !== strpos ( $name, DIRECTORY_SEPARATOR ) ) { - $name = $this -> getBasePath () . DIRECTORY_SEPARATOR . $name; + public function setOutputFile($name = 'output') + { + if (0 !== strpos($name, DIRECTORY_SEPARATOR)) { + $name = $this -> getBasePath() . DIRECTORY_SEPARATOR . $name; } $this -> _outfile = $name; } @@ -244,9 +250,10 @@ public function setOutputFile ( $name = 'output' ) { * * @return string */ - public function getOutputFile () { - if ( 0 !== strpos ( $this -> _outfile, DIRECTORY_SEPARATOR ) ) { - return $this -> getBasePath () . DIRECTORY_SEPARATOR . $this -> _outfile; + public function getOutputFile() + { + if (0 !== strpos($this -> _outfile, DIRECTORY_SEPARATOR)) { + return $this -> getBasePath() . DIRECTORY_SEPARATOR . $this -> _outfile; } return $this -> _outfile; } @@ -261,11 +268,12 @@ public function getOutputFile () { * * @return string */ - public function getBasePath () { - if ( null !== $this -> _infile ) { - return dirname ( $this -> _infile ); + public function getBasePath() + { + if (null !== $this -> _infile) { + return dirname($this -> _infile); } - return sys_get_temp_dir (); + return sys_get_temp_dir(); } /** @@ -273,18 +281,18 @@ public function getBasePath () { * * @return bool */ - public function render () { - - $renderString = $this -> getRenderString (); + public function render() + { + $renderString = $this -> getRenderString(); // We can't render anything without a render string - if ( '' == $renderString ) { + if ('' == $renderString) { return false; } - exec ( $renderString , $returnArray, $returnValue ); + exec($renderString, $returnArray, $returnValue); - if ( 0 !== $returnValue ) { + if (0 !== $returnValue) { return false; } return true; @@ -295,22 +303,23 @@ public function render () { * * @return string */ - public function getRenderString () { - if ( null === $this -> getInputFile () ) { + public function getRenderString() + { + if (null === $this -> getInputFile()) { return ''; } - $string = Org_Heigl_Ghostscript::getGsPath (); + $string = Ghostscript::getGsPath(); $string .= ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH'; - $string .= ' -sOutputFile="' . $this -> getOutputFile () . '.' . $this -> getDevice () -> getFileEnding () . '"'; - $string.= $this -> getDevice () -> getParameterString (); - $string .= ' -r' . $this -> getResolution (); - if ( $this -> isTextAntiAliasingSet () ) { - $string .= ' -dTextAlphaBits=' . $this -> getTextAntiAliasing (); + $string .= ' -sOutputFile="' . $this -> getOutputFile() . '.' . $this -> getDevice() -> getFileEnding() . '"'; + $string.= $this -> getDevice() -> getParameterString(); + $string .= ' -r' . $this -> getResolution(); + if ($this -> isTextAntiAliasingSet()) { + $string .= ' -dTextAlphaBits=' . $this -> getTextAntiAliasing(); } - if ( $this -> isGraphicsAntiAliasingSet () ) { - $string .= ' -dGraphicsAlphaBits=' . $this -> getGraphicsAntiAliasing (); + if ($this -> isGraphicsAntiAliasingSet()) { + $string .= ' -dGraphicsAlphaBits=' . $this -> getGraphicsAntiAliasing(); } - $string .= ' "' . $this -> getInputFile () . '"'; + $string .= ' "' . $this -> getInputFile() . '"'; return $string; } /** @@ -318,8 +327,9 @@ public function getRenderString () { * * @return boolean */ - public function isGraphicsAntiAliasingSet () { - if ( 0 < $this -> _graphicsAntiAliasing ) { + public function isGraphicsAntiAliasingSet() + { + if (0 < $this -> _graphicsAntiAliasing) { return true; } return false; @@ -330,11 +340,11 @@ public function isGraphicsAntiAliasingSet () { * * @param int $level The AntiaAliasing level to set. * - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setGraphicsAntiAliasing ( $level ) { - - if ( $level === 0 || $level === 1 || $level === 2 || $level === 4 ) { + public function setGraphicsAntiAliasing($level) + { + if ($level === 0 || $level === 1 || $level === 2 || $level === 4) { $this -> _graphicsAntiAliasing = $level; } return $this; @@ -352,7 +362,8 @@ public function setGraphicsAntiAliasing ( $level ) { * * @return int */ - public function getGraphicsAntiAliasing () { + public function getGraphicsAntiAliasing() + { return $this -> _graphicsAntiAliasing; } @@ -362,8 +373,9 @@ public function getGraphicsAntiAliasing () { * * @return boolean */ - public function isTextAntiAliasingSet () { - if ( 0 < $this -> _textAntiAliasing ) { + public function isTextAntiAliasingSet() + { + if (0 < $this -> _textAntiAliasing) { return true; } return false; @@ -374,11 +386,11 @@ public function isTextAntiAliasingSet () { * * @param int $level The AntiaAliasing level to set. * - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setTextAntiAliasing ( $level ) { - - if ( $level === 0 || $level === 1 || $level === 2 || $level === 4 ) { + public function setTextAntiAliasing($level) + { + if ($level === 0 || $level === 1 || $level === 2 || $level === 4) { $this -> _textAntiAliasing = $level; } return $this; @@ -396,7 +408,8 @@ public function setTextAntiAliasing ( $level ) { * * @return int */ - public function getTextAntiAliasing () { + public function getTextAntiAliasing() + { return $this -> _textAntiAliasing; } @@ -411,10 +424,11 @@ public function getTextAntiAliasing () { * @param int The horizontal resolution to set * @param int The vertical resolution to set * - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setResolution ( $horizontal, $vertical = null ) { - if ( null !== $vertical ) { + public function setResolution($horizontal, $vertical = null) + { + if (null !== $vertical) { $this -> _resolution = $horizontal . 'x' . $vertical; } else { $this -> _resolution = $horizontal; @@ -435,23 +449,23 @@ public function setResolution ( $horizontal, $vertical = null ) { * * @return string */ - public function getResolution () { + public function getResolution() + { return $this -> _resolution; } /** * Set the output-device * - * @param Org_Heigl_Ghostscript_Device_Abstract $device + * @param DeviceInterface|string $device * - * @return Org_Heigl_Ghostscript + * @return Ghostscript */ - public function setDevice ( $device ) { - - if ( ! $device instanceof Org_Heigl_Ghostscript_Device_Abstract ) { - $classname = 'Org_Heigl_Ghostscript_Device_' . ucfirst ( strtolower ( $device ) ); - include_once str_replace ( '_', '/', $classname) . '.php'; - $device = new $classname(); + public function setDevice($device) + { + if (! $device instanceof DeviceInterface) { + $classname = 'Org_Heigl\\Ghostscript\\Device\\' . ucfirst(strtolower($device)); + $device = new $classname(); } $this -> _device = $device; } @@ -470,8 +484,9 @@ public function setDevice ( $device ) { * * @return void */ - public function __construct () { - $this -> setDevice ( 'png' ); + public function __construct() + { + $this->setDevice('png'); } /** @@ -479,7 +494,8 @@ public function __construct () { * * @return Org_Heigl_Ghostscript_Device_Abstract */ - public function getDevice () { + public function getDevice() + { return $this -> _device; } @@ -490,7 +506,8 @@ public function getDevice () { * * @return Org_Heigl_Ghostscript */ - public function setUseCie ( $useCie = true ) { + public function setUseCie($useCie = true) + { $this -> _useCie = (bool) $useCie; return $this; } @@ -500,7 +517,8 @@ public function setUseCie ( $useCie = true ) { * * @return boolean */ - public function useCie () { + public function useCie() + { return (bool) $this -> _useCie; } @@ -512,4 +530,4 @@ public function useCie () { protected $_useCie = false; } -Org_Heigl_Ghostscript::setGsPath(); +Ghostscript::setGsPath(); diff --git a/tests/AllTests.php b/tests/AllTests.php deleted file mode 100644 index c5d1adf..0000000 --- a/tests/AllTests.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2009 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -error_reporting( E_ALL | E_STRICT ); - -if (!defined('PHPUnit_MAIN_METHOD')) { - define('PHPUnit_MAIN_METHOD', 'AllTests::main'); -} - -require_once dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'TestConfiguration.php'; - -/** PHPUnit_Framework_TestSuite */ -require_once 'PHPUnit/Framework/TestSuite.php'; - -/** PHPUnit_TextUI_TestRunner */ -require_once 'PHPUnit/TextUI/TestRunner.php'; - -class AllTests -{ - public static function main() - { - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() { - $suite = new PHPUnit_Framework_TestSuite( 'Org_Heigl_Ghostscript'); - - require_once 'Org/Heigl/AllTests.php'; - - $suite->addTest ( Org_Heigl_AllTests::suite () ); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'AllTests::main') { - AllTests::main(); -} \ No newline at end of file diff --git a/tests/Device/JpegTest.php b/tests/Device/JpegTest.php new file mode 100644 index 0000000..73b0b3a --- /dev/null +++ b/tests/Device/JpegTest.php @@ -0,0 +1,79 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ + +namespace Org_Heigl\GhostscriptTest\Device; + +use Org_Heigl\Ghostscript\Device\Jpeg; + +/** + * This class tests the Org_Heigl_Ghostscript-Class + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ +class JpegTest extends \PHPUnit_Framework_TestCase +{ + public function testCreationOfJpegClass() + { + $f = new Jpeg(); + $this -> assertTrue($f instanceof Jpeg); + $this -> assertEquals('jpeg', $f -> getDevice()); + } + + public function testSettingQuality() + { + $f = new Jpeg(); + $this -> assertEquals(75, $f -> getQuality()); + $f -> setQuality(50); + $this -> assertEquals(50, $f -> getQuality()); + $f -> setQuality('200'); + $this -> assertEquals(100, $f -> getQuality()); + $f -> setQuality(200); + $this -> assertEquals(100, $f -> getQuality()); + $f -> setQuality(-10); + $this -> assertEquals(0, $f -> getQuality()); + } + + public function testgettingParamString() + { + $f = new Jpeg(); + $this -> assertEquals(' -sDEVICE=jpeg -dJPEGQ=75 -dQFactor=0.75', $f -> getParameterString()); + $f -> setQuality(50); + $this -> assertEquals(' -sDEVICE=jpeg -dJPEGQ=50 -dQFactor=0.5', $f -> getParameterString()); + $f -> setQuality(200); + $this -> assertEquals(' -sDEVICE=jpeg -dJPEGQ=100 -dQFactor=1', $f -> getParameterString()); + $f -> setQuality(-5); + $this -> assertEquals(' -sDEVICE=jpeg -dJPEGQ=0 -dQFactor=0', $f -> getParameterString()); + } + + public function testFileEnding() + { + $f = new Jpeg(); + $this -> assertEquals('jpeg', $f -> getFileEnding()); + } +} diff --git a/tests/Device/PngTest.php b/tests/Device/PngTest.php new file mode 100644 index 0000000..e63b268 --- /dev/null +++ b/tests/Device/PngTest.php @@ -0,0 +1,86 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ + +namespace Org_Heigl\GhostscriptTest\Device; + +use Org_Heigl\Ghostscript\Device\Png; + +/** + * This class tests the Org_Heigl_Ghostscript-Class + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ +class PngTest extends \PHPUnit_Framework_TestCase +{ + public function testCreationOfPngClass() + { + $f = new Png(); + $this -> assertTrue($f instanceof Png); + $this -> assertEquals('pngalpha', $f -> getDevice()); + } + + public function testSettingDifferentDevice() + { + $f = new Png(); + $this -> assertEquals('pngalpha', $f ->getDevice()); + $f -> setDevice('PNG16m'); + $this -> assertEquals('png16m', $f ->getDevice()); + $f -> setDevice('jpeg'); + $this -> assertEquals('pngalpha', $f ->getDevice()); + } + + public function testSettingBackgroundColor() + { + $f = new Png(); + $this -> assertNull($f ->getBackgroundColor()); + $f -> setBackgroundColor('abcd34'); + $this -> assertEquals('abcd34', $f ->getBackgroundColor()); + $f -> setBackgroundColor('orange'); + $this -> assertNull($f ->getBackgroundColor()); + } + + public function testgettingParamString() + { + $f = new Png(); + $this -> assertEquals(' -sDEVICE=pngalpha', $f -> getParameterString()); + $f -> setDevice('png16'); + $this -> assertEquals(' -sDEVICE=png16', $f -> getParameterString()); + $f -> setBackgroundColor('abcd45'); + $this -> assertEquals(' -sDEVICE=png16', $f -> getParameterString()); + $f -> setDevice('png'); + $this -> assertEquals(' -sDEVICE=pngalpha -dBackgroundColor=16#abcd45', $f -> getParameterString()); + } + + + public function testFileEnding() + { + $f = new Png(); + $this -> assertEquals('png', $f -> getFileEnding()); + } +} diff --git a/tests/GhostscriptTest.php b/tests/GhostscriptTest.php new file mode 100644 index 0000000..7fda85c --- /dev/null +++ b/tests/GhostscriptTest.php @@ -0,0 +1,203 @@ + + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ + +namespace Org_Heigl\GhostscriptTest; + +use Org_Heigl\Ghostscript\Device\Png; +use Org_Heigl\Ghostscript\Ghostscript; + +/** + * This class tests the Org_Heigl_Ghostscript-Class + * + * @author Andreas Heigl + * @copyright 2008 Andreas Heigl + * @license http://www.opensource.org/licenses/mit-license.php MIT-License + */ +class GhostscriptTest extends \PHPUnit_Framework_TestCase +{ + public function setup() + { + Ghostscript::setGsPath(); + } + public function testForSetGhostscriptPath() + { + $path = Ghostscript::getGsPath(); + $this -> assertEquals(exec('which gs'), $path); + } + + public function testForNonEmptyGhostscriptPath() + { + $path = Ghostscript::getGsPath(); + $this -> assertNotEquals(null, $path); + } + + public function testSettingOfGhostscriptPath() + { + Ghostscript::setGsPath(); + $this -> assertEquals(exec('which gs'), Ghostscript::getGsPath()); + Ghostscript::setGsPath('This/is/a/fake'); + $this -> assertEquals('This/is/a/fake', Ghostscript::getGsPath()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testSettingFileWorks() + { + $f = new Ghostscript(); + $f -> setInputFile(__FILE__); + $comp = new \SplFileInfo(__FILE__); + $this -> assertEquals($comp, $f -> getInputFile()); + } + + public function testSettingOutfileWorks() + { + $f = new Ghostscript(); + $f -> setOutputFile('test'); + $tmp = sys_Get_Temp_dir(); + $this -> assertEquals($tmp . DIRECTORY_SEPARATOR . 'test', $f -> getOutputFile()); + $f -> setOutputFile('/this/is/a/test'); + $this -> assertEquals('/this/is/a/test', $f -> getOutputFile()); + $f -> setInputFile('/some/other/file'); + $f -> setOutputFile('test'); + $this -> assertEquals('/some/other/test', $f -> getOutputFile()); + } + + public function testDefaultDevice() + { + $f = new Ghostscript(); + $d = $f -> getDevice(); + $this -> assertTrue($d instanceof Png); + $this -> assertEquals('pngalpha', $d -> getDevice()); + } + + public function testUseCie() + { + $f = new Ghostscript(); + $this -> assertFalse($f -> useCie()); + $f -> setUseCie(true); + $this -> assertTrue($f -> useCie()); + $f -> setUseCie(false); + $this -> assertFalse($f -> useCie()); + $f -> setUseCie(); + $this -> assertTrue($f -> useCie()); + $f -> setUseCie('test'); + $this -> assertTrue($f -> useCie()); + $f -> setUseCie(0); + $this -> assertFalse($f -> useCie()); + } + + public function testResolution() + { + $f = new Ghostscript(); + $this -> assertEquals('72', $f -> getResolution()); + $f -> setResolution('92'); + $this -> assertEquals('92', $f -> getResolution()); + $f -> setResolution(12, 14); + $this -> assertEquals('12x14', $f -> getResolution()); + $f -> setResolution(33, null); + $this -> assertEquals('33', $f -> getResolution()); + } + + public function testTextAntiAliasing() + { + $f = new Ghostscript(); + $this -> assertEquals(0, $f -> getTextAntiAliasing()); + $f -> setTextAntiAliasing(5); + $this -> assertFalse($f -> isTextAntiAliasingSet()); + $this -> assertEquals(0, $f -> getTextAntiAliasing()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_HIGH); + $this -> assertTrue($f -> isTextAntiAliasingSet()); + $this -> assertEquals(4, $f -> getTextAntiAliasing()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_MEDIUM); + $this -> assertTrue($f -> isTextAntiAliasingSet()); + $this -> assertEquals(2, $f -> getTextAntiAliasing()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_LOW); + $this -> assertTrue($f -> isTextAntiAliasingSet()); + $this -> assertEquals(1, $f -> getTextAntiAliasing()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_NONE); + $this -> assertFalse($f -> isTextAntiAliasingSet()); + $this -> assertEquals(0, $f -> getTextAntiAliasing()); + } + + public function testGraphicsAntiAliasing() + { + $f = new Ghostscript(); + $this -> assertEquals(0, $f -> getGraphicsAntiAliasing()); + $f -> setGraphicsAntiAliasing(5); + $this -> assertFalse($f -> isGraphicsAntiAliasingSet()); + $this -> assertEquals(0, $f -> getGraphicsAntiAliasing()); + $this -> assertFalse($f -> isGraphicsAntiAliasingSet()); + $f -> setGraphicsAntiAliasing(Ghostscript::ANTIALIASING_HIGH); + $this -> assertEquals(4, $f -> getGraphicsAntiAliasing()); + $this -> assertTrue($f -> isGraphicsAntiAliasingSet()); + $f -> setGraphicsAntiAliasing(Ghostscript::ANTIALIASING_MEDIUM); + $this -> assertEquals(2, $f -> getGraphicsAntiAliasing()); + $this -> assertTrue($f -> isGraphicsAntiAliasingSet()); + $f -> setGraphicsAntiAliasing(Ghostscript::ANTIALIASING_LOW); + $this -> assertEquals(1, $f -> getGraphicsAntiAliasing()); + $this -> assertTrue($f -> isGraphicsAntiAliasingSet()); + $f -> setGraphicsAntiAliasing(Ghostscript::ANTIALIASING_NONE); + $this -> assertEquals(0, $f -> getGraphicsAntiAliasing()); + $this -> assertFalse($f -> isGraphicsAntiAliasingSet()); + } + + public function testRenderingStrings() + { + $f = new Ghostscript(); + $dir = __DIR__ . DIRECTORY_SEPARATOR . 'support' . DIRECTORY_SEPARATOR; + $filename = $dir . 'test.pdf'; + $path = Ghostscript::getGsPath(); + $this -> assertEquals('', $f -> getRenderString()); + $f -> setInputFile($filename); + $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 "' .$filename . '"'; + $this -> assertEquals($expect, $f -> getRenderString()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_HIGH); + $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dTextAlphaBits=4 "' .$filename . '"'; + $this -> assertEquals($expect, $f -> getRenderString()); + $f -> setGraphicsAntiAliasing(Ghostscript::ANTIALIASING_HIGH); + $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "' .$filename . '"'; + $this -> assertEquals($expect, $f -> getRenderString()); + $f -> setTextAntiAliasing(Ghostscript::ANTIALIASING_NONE); + $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dGraphicsAlphaBits=4 "' .$filename . '"'; + $this -> assertEquals($expect, $f -> getRenderString()); + $f -> setDevice('jpeg'); + $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.jpeg" -sDEVICE=jpeg -dJPEGQ=75 -dQFactor=0.75 -r72 -dGraphicsAlphaBits=4 "' .$filename . '"'; + $this -> assertEquals($expect, $f -> getRenderString()); + } + + public function testRendering() + { + Ghostscript::setGsPath(); + $f = new Ghostscript(); + $this -> assertFalse($f -> render()); + $filename = __DIR__ . DIRECTORY_SEPARATOR . 'support' . DIRECTORY_SEPARATOR . 'test.pdf'; + $f -> setInputFile($filename); + $this -> assertTrue($f -> render()); + unlink(dirname($filename) . DIRECTORY_SEPARATOR . 'output.png'); + } +} diff --git a/tests/Org/Heigl/AllTests.php b/tests/Org/Heigl/AllTests.php deleted file mode 100644 index c400947..0000000 --- a/tests/Org/Heigl/AllTests.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This is the ant-buildfile - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** PHPUnit_Framework_TestSuite */ -require_once 'PHPUnit/Framework/TestSuite.php'; - -/** PHPUnit_TextUI_TestRunner */ -require_once 'PHPUnit/TextUI/TestRunner.php'; - -/** - * This class Provides all tests of the Org_Heigl Package - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_AllTests -{ - public static function main () { - PHPUnit_TextUI_TestRunner::run ( self::suite () ); - } - - public static function suite () { - - $suite = new PHPUnit_Framework_TestSuite ( 'Org_Heigl_Ghostscript' ); - - require_once 'Org/Heigl/GhostscriptTest.php'; - require_once 'Org/Heigl/Ghostscript/Device/AllTests.php'; - - $suite->addTestSuite ( 'Org_Heigl_GhostscriptTest' ); - $suite->addTestSuite ( 'Org_Heigl_Ghostscript_Device_AllTests' ); - - return $suite; - - } -} \ No newline at end of file diff --git a/tests/Org/Heigl/Ghostscript/Device/AbstractTest.php b/tests/Org/Heigl/Ghostscript/Device/AbstractTest.php deleted file mode 100644 index 9713edd..0000000 --- a/tests/Org/Heigl/Ghostscript/Device/AbstractTest.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** Org_Heigl_Ghostscript_Device_Abstract */ -require_once 'Org/Heigl/Ghostscript/Device/Abstract.php'; - -/** PHPUnit_Framework_TestCase */ -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * This class tests the Org_Heigl_Ghostscript-Class - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_Ghostscript_Device_AbstractTest extends PHPUnit_Framework_TestCase -{ - public function testCreationOfAbstractClass () { - $f = new TestClass (); - $this -> assertTrue ( $f instanceof Org_Heigl_Ghostscript_Device_Abstract ); - $this -> assertEquals ( 'abstract', $f -> getDevice () ); - } - - public function testgettingParamString () { - $f = new TestClass (); - $this -> assertEquals ( '', $f -> getParameterString () ); - } - - - public function testFileEnding () { - $f = new TestClass (); - $this -> assertEquals ( '', $f -> getFileEnding () ); - } -} - -class TestClass extends Org_Heigl_Ghostscript_Device_Abstract -{ - - public function getDevice () { return 'abstract';} - public function getFileEnding () {return '';} - -} \ No newline at end of file diff --git a/tests/Org/Heigl/Ghostscript/Device/AllTests.php b/tests/Org/Heigl/Ghostscript/Device/AllTests.php deleted file mode 100644 index 3a052fb..0000000 --- a/tests/Org/Heigl/Ghostscript/Device/AllTests.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This is the ant-buildfile - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** PHPUnit_Framework_TestSuite */ -require_once 'PHPUnit/Framework/TestSuite.php'; - -/** PHPUnit_TextUI_TestRunner */ -require_once 'PHPUnit/TextUI/TestRunner.php'; - -/** - * This class Provides all tests of the Org_Heigl Package - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_Ghostscript_Device_AllTests -{ - public static function main () { - PHPUnit_TextUI_TestRunner::run ( self::suite () ); - } - - public static function suite () { - - $suite = new PHPUnit_Framework_TestSuite ( 'Org_Heigl_Ghostscript_Device' ); - - require_once 'Org/Heigl/Ghostscript/Device/PngTest.php'; - require_once 'Org/Heigl/Ghostscript/Device/JpegTest.php'; - require_once 'Org/Heigl/Ghostscript/Device/AbstractTest.php'; - - $suite->addTestSuite ( 'Org_Heigl_Ghostscript_Device_AbstractTest' ); - $suite->addTestSuite ( 'Org_Heigl_Ghostscript_Device_PngTest' ); - $suite->addTestSuite ( 'Org_Heigl_Ghostscript_Device_JpegTest' ); - - return $suite; - - } -} \ No newline at end of file diff --git a/tests/Org/Heigl/Ghostscript/Device/JpegTest.php b/tests/Org/Heigl/Ghostscript/Device/JpegTest.php deleted file mode 100644 index f2703cf..0000000 --- a/tests/Org/Heigl/Ghostscript/Device/JpegTest.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** Org_Heigl_Ghostscript_Device_Png */ -require_once 'Org/Heigl/Ghostscript/Device/Jpeg.php'; - -/** PHPUnit_Framework_TestCase */ -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * This class tests the Org_Heigl_Ghostscript-Class - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_Ghostscript_Device_JpegTest extends PHPUnit_Framework_TestCase -{ - public function testCreationOfJpegClass () { - $f = new Org_Heigl_Ghostscript_Device_Jpeg (); - $this -> assertTrue ( $f instanceof Org_Heigl_Ghostscript_Device_Jpeg ); - $this -> assertEquals ( 'jpeg', $f -> getDevice ()); - } - - public function testSettingQuality () { - $f = new Org_Heigl_Ghostscript_Device_Jpeg (); - $this -> assertEquals ( 75, $f -> getQuality () ); - $f -> setQuality ( 50 ); - $this -> assertEquals ( 50, $f -> getQuality () ); - $f -> setQuality ( '200' ); - $this -> assertEquals ( 100, $f -> getQuality () ); - $f -> setQuality ( 200 ); - $this -> assertEquals ( 100, $f -> getQuality () ); - $f -> setQuality ( -10 ); - $this -> assertEquals ( 0, $f -> getQuality () ); - - } - - public function testgettingParamString () { - $f = new Org_Heigl_Ghostscript_Device_Jpeg (); - $this -> assertEquals ( ' -sDEVICE=jpeg -dJPEGQ=75 -dQFactor=0.75', $f -> getParameterString () ); - $f -> setQuality ( 50 ); - $this -> assertEquals ( ' -sDEVICE=jpeg -dJPEGQ=50 -dQFactor=0.5', $f -> getParameterString () ); - $f -> setQuality ( 200 ); - $this -> assertEquals ( ' -sDEVICE=jpeg -dJPEGQ=100 -dQFactor=1', $f -> getParameterString () ); - $f -> setQuality ( -5 ); - $this -> assertEquals ( ' -sDEVICE=jpeg -dJPEGQ=0 -dQFactor=0', $f -> getParameterString () ); - - } - - public function testFileEnding () { - $f = new Org_Heigl_Ghostscript_Device_Jpeg (); - $this -> assertEquals ( 'jpeg', $f -> getFileEnding () ); - } -} \ No newline at end of file diff --git a/tests/Org/Heigl/Ghostscript/Device/PngTest.php b/tests/Org/Heigl/Ghostscript/Device/PngTest.php deleted file mode 100644 index 2bb98bd..0000000 --- a/tests/Org/Heigl/Ghostscript/Device/PngTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** Org_Heigl_Ghostscript_Device_Png */ -require_once 'Org/Heigl/Ghostscript/Device/Png.php'; - -/** PHPUnit_Framework_TestCase */ -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * This class tests the Org_Heigl_Ghostscript-Class - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_Ghostscript_Device_PngTest extends PHPUnit_Framework_TestCase -{ - public function testCreationOfPngClass () { - $f = new Org_Heigl_Ghostscript_Device_Png (); - $this -> assertTrue ( $f instanceof Org_Heigl_Ghostscript_Device_Png ); - $this -> assertEquals ( 'pngalpha', $f -> getDevice ()); - } - - public function testSettingDifferentDevice () { - $f = new Org_Heigl_Ghostscript_Device_Png (); - $this -> assertEquals ( 'pngalpha', $f ->getDevice () ); - $f -> setDevice ( 'PNG16m' ); - $this -> assertEquals ( 'png16m', $f ->getDevice () ); - $f -> setDevice ( 'jpeg' ); - $this -> assertEquals ( 'pngalpha', $f ->getDevice () ); - } - - public function testSettingBackgroundColor () { - $f = new Org_Heigl_Ghostscript_Device_Png (); - $this -> assertNull ( $f ->getBackgroundColor () ); - $f -> setBackgroundColor ( 'abcd34' ); - $this -> assertEquals ( 'abcd34', $f ->getBackgroundColor () ); - $f -> setBackgroundColor ( 'orange' ); - $this -> assertNull ( $f ->getBackgroundColor () ); - - } - - public function testgettingParamString () { - $f = new Org_Heigl_Ghostscript_Device_Png (); - $this -> assertEquals ( ' -sDEVICE=pngalpha', $f -> getParameterString () ); - $f -> setDevice ( 'png16' ); - $this -> assertEquals ( ' -sDEVICE=png16', $f -> getParameterString () ); - $f -> setBackgroundColor ( 'abcd45' ); - $this -> assertEquals ( ' -sDEVICE=png16', $f -> getParameterString () ); - $f -> setDevice ( 'png' ); - $this -> assertEquals ( ' -sDEVICE=pngalpha -dBackgroundColor=16#abcd45', $f -> getParameterString () ); - - } - - - public function testFileEnding () { - $f = new Org_Heigl_Ghostscript_Device_Png (); - $this -> assertEquals ( 'png', $f -> getFileEnding () ); - } -} \ No newline at end of file diff --git a/tests/Org/Heigl/GhostscriptTest.php b/tests/Org/Heigl/GhostscriptTest.php deleted file mode 100644 index c7a83c5..0000000 --- a/tests/Org/Heigl/GhostscriptTest.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -/** Org_Heigl_Ghostscript */ -require_once 'Org/Heigl/Ghostscript.php'; - -/** PHPUnit_Framework_TestCase */ -require_once 'PHPUnit/Framework/TestCase.php'; - -/** - * This class tests the Org_Heigl_Ghostscript-Class - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @author Andreas Heigl - * @copyright 2008 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ -class Org_Heigl_GhostscriptTest extends PHPUnit_Framework_TestCase -{ - public function setup () { - Org_Heigl_Ghostscript::setGsPath(); - } - public function testForSetGhostscriptPath () { - $path = Org_Heigl_Ghostscript::getGsPath (); - $this -> assertEquals ( exec ( 'which gs'), $path ); - } - - public function testForNonEmptyGhostscriptPath () { - $path = Org_Heigl_Ghostscript::getGsPath (); - $this -> assertNotEquals ( null, $path ); - } - - public function testSettingOfGhostscriptPath () { - Org_Heigl_Ghostscript::setGsPath(); - $this -> assertEquals(exec('which gs'), Org_Heigl_Ghostscript::getGsPath()); - Org_Heigl_Ghostscript::setGsPath('This/is/a/fake'); - $this -> assertEquals('This/is/a/fake', Org_Heigl_Ghostscript::getGsPath()); - } - - /** - * @setExpectedException InvalidArgumentException - */ - public function testSettingFileWorks(){ - $f = new Org_Heigl_Ghostscript(); - $f -> setInputFile(__FILE__); - $comp = new SplFileInfo ( __FILE__); - $this -> assertEquals ($comp, $f -> getInputFile()); - } - - public function testSettingOutfileWorks () { - $f = new Org_Heigl_Ghostscript(); - $f -> setOutputFile ( 'test' ); - $tmp = sys_Get_Temp_dir (); - $this -> assertEquals ( $tmp . DIRECTORY_SEPARATOR . 'test', $f -> getOutputFile () ); - $f -> setOutputFile ( '/this/is/a/test' ); - $this -> assertEquals ( '/this/is/a/test', $f -> getOutputFile () ); - $f -> setInputFile ( '/some/other/file' ); - $f -> setOutputFile ( 'test' ); - $this -> assertEquals ( '/some/other/test', $f -> getOutputFile () ); - } - - public function testDefaultDevice () { - $f = new Org_Heigl_Ghostscript (); - $d = $f -> getDevice (); - $this -> assertTrue ( $d instanceof Org_Heigl_Ghostscript_Device_Png ); - $this -> assertEquals ( 'pngalpha', $d -> getDevice () ); - } - - public function testUseCie () { - $f = new Org_Heigl_Ghostscript (); - $this -> assertFalse ( $f -> useCie () ); - $f -> setUseCie ( true ); - $this -> assertTrue ( $f -> useCie () ); - $f -> setUseCie ( false ); - $this -> assertFalse ( $f -> useCie () ); - $f -> setUseCie (); - $this -> assertTrue ( $f -> useCie () ); - $f -> setUseCie ('test'); - $this -> assertTrue ( $f -> useCie () ); - $f -> setUseCie ( 0 ); - $this -> assertFalse ( $f -> useCie () ); - } - - public function testResolution () { - $f = new Org_Heigl_Ghostscript (); - $this -> assertEquals ( '72', $f -> getResolution () ); - $f -> setResolution ( '92' ); - $this -> assertEquals ( '92', $f -> getResolution () ); - $f -> setResolution ( 12, 14 ); - $this -> assertEquals ( '12x14', $f -> getResolution () ); - $f -> setResolution ( 33, null ); - $this -> assertEquals ( '33', $f -> getResolution () ); - } - - public function testTextAntiAliasing () { - $f = new Org_Heigl_Ghostscript (); - $this -> assertEquals ( 0, $f -> getTextAntiAliasing () ); - $f -> setTextAntiAliasing ( 5 ); - $this -> assertFalse ( $f -> isTextAntiAliasingSet () ); - $this -> assertEquals ( 0, $f -> getTextAntiAliasing () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_HIGH ); - $this -> assertTrue ( $f -> isTextAntiAliasingSet () ); - $this -> assertEquals ( 4, $f -> getTextAntiAliasing () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_MEDIUM ); - $this -> assertTrue ( $f -> isTextAntiAliasingSet () ); - $this -> assertEquals ( 2, $f -> getTextAntiAliasing () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_LOW ); - $this -> assertTrue ( $f -> isTextAntiAliasingSet () ); - $this -> assertEquals ( 1, $f -> getTextAntiAliasing () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_NONE ); - $this -> assertFalse ( $f -> isTextAntiAliasingSet () ); - $this -> assertEquals ( 0, $f -> getTextAntiAliasing () ); - } - - public function testGraphicsAntiAliasing () { - $f = new Org_Heigl_Ghostscript (); - $this -> assertEquals ( 0, $f -> getGraphicsAntiAliasing () ); - $f -> setGraphicsAntiAliasing ( 5 ); - $this -> assertFalse ( $f -> isGraphicsAntiAliasingSet () ); - $this -> assertEquals ( 0, $f -> getGraphicsAntiAliasing () ); - $this -> assertFalse ( $f -> isGraphicsAntiAliasingSet () ); - $f -> setGraphicsAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_HIGH ); - $this -> assertEquals ( 4, $f -> getGraphicsAntiAliasing () ); - $this -> assertTrue ( $f -> isGraphicsAntiAliasingSet () ); - $f -> setGraphicsAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_MEDIUM ); - $this -> assertEquals ( 2, $f -> getGraphicsAntiAliasing () ); - $this -> assertTrue ( $f -> isGraphicsAntiAliasingSet () ); - $f -> setGraphicsAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_LOW ); - $this -> assertEquals ( 1, $f -> getGraphicsAntiAliasing () ); - $this -> assertTrue ( $f -> isGraphicsAntiAliasingSet () ); - $f -> setGraphicsAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_NONE ); - $this -> assertEquals ( 0, $f -> getGraphicsAntiAliasing () ); - $this -> assertFalse ( $f -> isGraphicsAntiAliasingSet () ); - - } - - public function testRenderingStrings () { - $f = new Org_Heigl_Ghostscript (); - $dir = dirname (__FILE__) . DIRECTORY_SEPARATOR . 'Ghostscript' . DIRECTORY_SEPARATOR . 'support' . DIRECTORY_SEPARATOR; - $filename = $dir . 'test.pdf'; - $path = Org_Heigl_Ghostscript::getGsPath (); - $this -> assertEquals ( '', $f -> getRenderString () ); - $f -> setInputFile ( $filename ); - $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 "' .$filename . '"'; - $this -> assertEquals ( $expect, $f -> getRenderString () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_HIGH ); - $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dTextAlphaBits=4 "' .$filename . '"'; - $this -> assertEquals ( $expect, $f -> getRenderString () ); - $f -> setGraphicsAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_HIGH ); - $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "' .$filename . '"'; - $this -> assertEquals ( $expect, $f -> getRenderString () ); - $f -> setTextAntiAliasing ( Org_Heigl_Ghostscript::ANTIALIASING_NONE ); - $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.png" -sDEVICE=pngalpha -r72 -dGraphicsAlphaBits=4 "' .$filename . '"'; - $this -> assertEquals ( $expect, $f -> getRenderString () ); - $f -> setDevice ( 'jpeg' ); - $expect = $path . ' -dSAFER -dQUIET -dNOPLATFONTS -dNOPAUSE -dBATCH -sOutputFile="' . $dir . 'output.jpeg" -sDEVICE=jpeg -dJPEGQ=75 -dQFactor=0.75 -r72 -dGraphicsAlphaBits=4 "' .$filename . '"'; - $this -> assertEquals ( $expect, $f -> getRenderString () ); - } - - public function testRendering () { - $f = new Org_Heigl_Ghostscript (); - $this -> assertFalse ( $f -> render () ); - $filename = dirname (__FILE__) . DIRECTORY_SEPARATOR . 'Ghostscript' . DIRECTORY_SEPARATOR . 'support' . DIRECTORY_SEPARATOR . 'test.pdf'; - $f -> setInputFile ( $filename ); - $this -> assertTrue ( $f -> render () ); - unlink ( dirname ( $filename ) . DIRECTORY_SEPARATOR . 'output.png' ); - } - -} \ No newline at end of file diff --git a/tests/TestConfiguration.php b/tests/TestConfiguration.php deleted file mode 100644 index 69543db..0000000 --- a/tests/TestConfiguration.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @category Org_Heigl - * @package Org_Heigl_Ghostscript - * @subpackage UnitTests - * @author Andreas Heigl - * @copyright 2009 Andreas Heigl - * @license http://www.opensource.org/licenses/mit-license.php MIT-License - * @version SVN: $Revision$ - * @since 03.06.2009 - */ - -define ( 'ORG_HEIGL_LIB_PATH', dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' ); -define ( 'ORG_HEIGL_TEST_PATH', dirname ( __FILE__ ) ); - -set_include_path ('.' . PATH_SEPARATOR - . ORG_HEIGL_LIB_PATH . PATH_SEPARATOR - . ORG_HEIGL_TEST_PATH . PATH_SEPARATOR - . get_include_path()); - -ini_set ('date.timezone', 'Europe/Berlin'); \ No newline at end of file diff --git a/tests/Org/Heigl/Ghostscript/support/test.pdf b/tests/support/test.pdf similarity index 100% rename from tests/Org/Heigl/Ghostscript/support/test.pdf rename to tests/support/test.pdf