public function testInput() { $input = new Input(); $input->setProcessInput('input'); $input->setPostScriptCode('.setpdfwrite'); $input->addFile('/path/to/output/file.pdf'); $input->setFiles(['/path/to/output/file.pdf']); $this->assertSame('input', $input->getProcessInput()); $this->assertSame('.setpdfwrite', $input->getPostScriptCode()); $this->assertInternalType('array', $input->getFiles()); $this->assertCount(1, $input->getFiles()); }
/** * 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; }