File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,12 +99,12 @@ class GhostscriptAPI {
9999 protected function __construct (protected FFI $ ffi ) {
100100 }
101101
102- public static function create (string $ lib_path ) : self |false {
103- if (!is_file ($ lib_path )) {
102+ public static function create (string $ gslib_path ) : self |false {
103+ if (!is_file ($ gslib_path )) {
104104 return false ;
105105 }
106106
107- $ ffi = FFI ::cdef (self ::HEADER , $ lib_path );
107+ $ ffi = FFI ::cdef (self ::HEADER , $ gslib_path );
108108
109109 return new self ($ ffi );
110110 }
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace Fawno \PDFOptimizer \Tests ;
5+
6+ use Fawno \Ghostscript \GhostscriptAPI ;
7+ use PHPUnit \Framework \Attributes \RequiresPhpExtension ;;
8+
9+ #[RequiresPhpExtension('ffi ' )]
10+ class GhostscriptAPITest extends TestCase {
11+ public const GSLIB_PATH_LINUX = '/usr/lib/x86_64-linux-gnu/libgs.so ' ;
12+ public const GSLIB_PATH_WINDOWS = '\\usr \\gs \\bin \\gsdll64.dll ' ;
13+ readonly public string $ gslib_path ;
14+
15+ protected function setUp (): void {
16+ $ this ->gslib_path = (PHP_OS == 'Linux ' ) ? self ::GSLIB_PATH_LINUX : self ::GSLIB_PATH_WINDOWS ;
17+
18+ if (!is_file ($ this ->gslib_path )) {
19+ $ this ->markTestSkipped ('Not found GSLIB: ' . $ this ->gslib_path );
20+ }
21+ }
22+
23+ public function testGhostscriptAPILoad () : void {
24+ $ gs = GhostscriptAPI::create ($ this ->gslib_path );
25+
26+ $ this ->assertInstanceOf (GhostscriptAPI::class, $ gs );
27+ }
28+ }
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace Fawno \PDFOptimizer \Tests ;
5+
6+ use Fawno \Ghostscript \Ghostscript ;
7+
8+ class GhostscriptTest extends TestCase {
9+ public const GSBIN_PATH_LINUX = '/usr/bin/gs ' ;
10+ public const GSBIN_PATH_WINDOWS = '\\usr \\gs \\bin \\gswin64c.exe ' ;
11+ readonly public string $ gsbin_path ;
12+
13+ protected function setUp (): void {
14+ $ this ->gsbin_path = (PHP_OS == 'Linux ' ) ? self ::GSBIN_PATH_LINUX : self ::GSBIN_PATH_WINDOWS ;
15+
16+ if (!is_file ($ this ->gsbin_path )) {
17+ $ this ->markTestSkipped ('Not found GSBIN: ' . $ this ->gsbin_path );
18+ }
19+ }
20+
21+ public function testGhostscriptLoad () : void {
22+ $ gs = Ghostscript::create ($ this ->gsbin_path );
23+
24+ $ this ->assertInstanceOf (Ghostscript::class, $ gs );
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments