Esempio n. 1
0
 public function testGetArgument()
 {
     $instance = new Arguments();
     $instance->setArgument('foo=bar');
     $this->assertInstanceOf(Argument::class, $instance->getArgument('foo'));
     $this->assertSame('bar', $instance->getArgument('foo')->getValue());
     $this->assertNull($instance->getArgument('bar'));
 }
Esempio n. 2
0
 public function testDeviceCreation()
 {
     $ghostscript = new Ghostscript();
     $arguments = new Arguments();
     $device = new NoDisplay($ghostscript, $arguments);
     $this->assertInstanceOf(NoDisplay::class, $device);
     $this->assertInstanceOf(Argument::class, $arguments->getArgument('-dNODISPLAY'));
 }
 public function testGetArgument()
 {
     $instance = new Arguments();
     $instance->setArgument('foo=bar');
     $this->assertInstanceOf('GravityMedia\\Ghostscript\\Process\\Argument', $instance->getArgument('foo'));
     $this->assertSame('bar', $instance->getArgument('foo')->getValue());
     $this->assertNull($instance->getArgument('bar'));
 }
 public function testDeviceCreation()
 {
     $ghostscript = new Ghostscript();
     $arguments = new Arguments();
     $device = new BoundingBoxInfo($ghostscript, $arguments);
     $this->assertInstanceOf(BoundingBoxInfo::class, $device);
     $argument = $arguments->getArgument('-sDEVICE');
     $this->assertInstanceOf(Argument::class, $argument);
     $this->assertEquals('bbox', $argument->getValue());
 }
 public function testArgumentSetter()
 {
     $processBuilder = new ProcessBuilder();
     $processArguments = new ProcessArguments();
     /** @var AbstractDevice $device */
     $device = $this->getMockForAbstractClass('GravityMedia\\Ghostscript\\Device\\AbstractDevice', [$processBuilder, $processArguments]);
     $method = new \ReflectionMethod('GravityMedia\\Ghostscript\\Device\\AbstractDevice', 'setArgument');
     $method->setAccessible(true);
     $method->invoke($device, '-dFoo=/Bar');
     $argument = $processArguments->getArgument('-dFoo');
     $this->assertInstanceOf('GravityMedia\\Ghostscript\\Process\\Argument', $argument);
     $this->assertSame('/Bar', $argument->getValue());
 }
 /**
  * Create process object
  *
  * @param string $inputFile
  *
  * @throws \RuntimeException
  *
  * @return Process
  */
 public function createProcess($inputFile)
 {
     if (!is_file($inputFile)) {
         throw new \RuntimeException('Input file does not exist');
     }
     $arguments = array_values($this->arguments->toArray());
     array_push($arguments, '-f', $inputFile);
     return $this->builder->setArguments($arguments)->getProcess();
 }
 /**
  * Create process arguments.
  *
  * @param Input $input
  *
  * @throws \RuntimeException
  *
  * @return array
  */
 protected function createProcessArguments(Input $input)
 {
     $arguments = array_values($this->arguments->toArray());
     if (null !== $input->getPostScriptCode()) {
         array_push($arguments, '-c', $input->getPostScriptCode());
     }
     if (count($input->getFiles()) > 0) {
         array_push($arguments, '-f');
         foreach ($input->getFiles() as $file) {
             if (!is_file($file)) {
                 throw new \RuntimeException('Input file does not exist');
             }
             array_push($arguments, $file);
         }
     }
     if (null !== $input->getProcessInput()) {
         array_push($arguments, '-');
     }
     return $arguments;
 }
Esempio n. 8
0
 /**
  * Create arguments object.
  *
  * @return Arguments
  */
 protected function createArguments()
 {
     $arguments = new Arguments();
     if ($this->getOption('quiet', true)) {
         $arguments->addArgument('-q');
     }
     return $arguments;
 }
 public function testArgumentSetter()
 {
     $ghostscript = new Ghostscript();
     $arguments = new Arguments();
     /** @var AbstractDevice $device */
     $device = $this->getMockForAbstractClass(AbstractDevice::class, [$ghostscript, $arguments]);
     $method = new \ReflectionMethod(AbstractDevice::class, 'setArgument');
     $method->setAccessible(true);
     $method->invoke($device, '-dFoo=/Bar');
     $argument = $arguments->getArgument('-dFoo');
     $this->assertInstanceOf(Argument::class, $argument);
     $this->assertSame('/Bar', $argument->getValue());
 }
Esempio n. 10
0
 /**
  * Create process arguments object
  *
  * @param array $arguments
  *
  * @return ProcessArguments
  */
 protected function createProcessArguments(array $arguments = [])
 {
     $processArguments = new ProcessArguments();
     $processArguments->addArguments($arguments);
     if ($this->getOption('quiet', true)) {
         $processArguments->addArgument('-q');
     }
     return $processArguments;
 }
Esempio n. 11
0
 /**
  * Create PDF write device object
  *
  * @param ProcessBuilder   $builder
  * @param ProcessArguments $arguments
  */
 public function __construct(ProcessBuilder $builder, ProcessArguments $arguments)
 {
     parent::__construct($builder, $arguments->setArgument('-sDEVICE=pdfwrite'));
     $this->setPdfSettings(PdfSettings::__DEFAULT);
 }
Esempio n. 12
0
 /**
  * Create PDF write device object.
  *
  * @param Ghostscript $ghostscript
  * @param Arguments   $arguments
  */
 public function __construct(Ghostscript $ghostscript, Arguments $arguments)
 {
     parent::__construct($ghostscript, $arguments->setArgument('-sDEVICE=pdfwrite'));
     $this->setPdfSettings(PdfSettings::__DEFAULT);
 }
Esempio n. 13
0
 /**
  * Create no display device object.
  *
  * @param Ghostscript $ghostscript
  * @param Arguments   $arguments
  */
 public function __construct(Ghostscript $ghostscript, Arguments $arguments)
 {
     parent::__construct($ghostscript, $arguments->setArgument('-dNODISPLAY'));
 }