GhostscriptServiceProviderTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Ghostscript\Tests;
  3. use Ghostscript\GhostscriptServiceProvider;
  4. use Silex\Application;
  5. use Symfony\Component\Process\ExecutableFinder;
  6. class GhostscriptServiceProviderTest extends \PHPUnit_Framework_TestCase
  7. {
  8. public function testRegister()
  9. {
  10. $app = new Application;
  11. $app->register(new GhostscriptServiceProvider());
  12. $this->assertInstanceOf('\\Ghostscript\\Transcoder', $app['ghostscript.transcoder']);
  13. }
  14. public function testRegisterWithCustomTimeout()
  15. {
  16. $app = new Application;
  17. $app->register(new GhostscriptServiceProvider(), array(
  18. 'ghostscript.configuration' => array(
  19. 'timeout' => 42
  20. ),
  21. ));
  22. $this->assertEquals(42, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getTimeout());
  23. }
  24. public function testRegisterWithCustomBinary()
  25. {
  26. $finder = new ExecutableFinder();
  27. $MP4Box = $finder->find('MP4Box');
  28. if (null === $MP4Box) {
  29. $this->markTestSkipped('Unable to detect MP4Box, required for this test');
  30. }
  31. $app = new Application;
  32. $app->register(new GhostscriptServiceProvider(), array(
  33. 'ghostscript.configuration' => array(
  34. 'gs.binaries' => $MP4Box
  35. ),
  36. ));
  37. $this->assertEquals($MP4Box, $app['ghostscript.transcoder']->getProcessBuilderfactory()->getBinary());
  38. }
  39. public function testRegisterWithCustomLogger()
  40. {
  41. $logger = $this->getMock('Psr\Log\LoggerInterface');
  42. $app = new Application;
  43. $app->register(new GhostscriptServiceProvider(), array(
  44. 'ghostscript.logger' => $logger,
  45. ));
  46. $this->assertEquals($logger, $app['ghostscript.transcoder']->getProcessRunner()->getLogger());
  47. }
  48. }