Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace Ghostscript\Tests;
use Ghostscript\GhostscriptServiceProvider;
use Silex\Application;
use Symfony\Component\Process\ExecutableFinder;
class GhostscriptServiceProviderTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
$app = new Application;
$app->register(new GhostscriptServiceProvider());
$this->assertInstanceOf('\\Ghostscript\\Transcoder', $app['ghostscript.transcoder']);
}
public function testRegisterWithCustomTimeout()
{
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'timeout' => 42
),
));
$this->assertEquals(42, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getTimeout());
}
public function testRegisterWithCustomBinary()
{
$finder = new ExecutableFinder();
$MP4Box = $finder->find('MP4Box');
if (null === $MP4Box) {
$this->markTestSkipped('Unable to detect MP4Box, required for this test');
}
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.configuration' => array(
'gs.binaries' => $MP4Box
),
));
$this->assertEquals($MP4Box, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getBinary());
}
public function testRegisterWithCustomLogger()
{
$logger = $this->getMock('Psr\Log\LoggerInterface');
$app = new Application;
$app->register(new GhostscriptServiceProvider(), array(
'ghostscript.logger' => $logger,
));
$this->assertEquals($logger, $app['ghostscript.transcoder']->getProcessRunner()->getLogger());
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Ghostscript\Tests;
use Ghostscript\Transcoder;
class TranscoderTest extends \PHPUnit_Framework_TestCase
{
protected $object;
protected function setUp()
{
$this->object = Transcoder::create();
}
public function testTranscodeToPdf()
{
$dest = tempnam(sys_get_temp_dir(), 'gs_temp') . '.pdf';
$this->object->toPDF(__DIR__ . '/../../files/test.pdf', $dest, 1, 1);
$this->assertTrue(file_exists($dest));
$this->assertGreaterThan(0, filesize($dest));
unlink($dest);
}
public function testTranscodeAIToImage()
{
$dest = tempnam(sys_get_temp_dir(), 'gs_temp') . '.jpg';
$this->object->toImage(__DIR__ . '/../../files/test.pdf', $dest);
$this->assertTrue(file_exists($dest));
$this->assertGreaterThan(0, filesize($dest));
unlink($dest);
}
}