/**
  * @covers JsonCommandExecutor::executeCommand
  *
  * @expectedException \Xiag\JsonCommand\Exception\RuntimeException
  * @expectedExceptionCode 200
  */
 public function testExecuteCommandInvalidJson()
 {
     $serializer = SerializerBuilder::create()->addDefaultHandlers()->addDefaultSerializationVisitors()->addDefaultDeserializationVisitors()->setDebug(true)->build();
     $commandExecutor = new JsonCommandExecutor($this->execDir . '/invalidjson', $serializer, 'array');
     $commandExecutor->executeCommand();
 }
Exemplo n.º 2
0
class Result
{
    private $key;
    private $result;
    public function getKey()
    {
        return $this->key;
    }
    public function setKey($key)
    {
        $this->key = $key;
    }
    public function getResult()
    {
        return $this->result;
    }
    public function setResult($result)
    {
        $this->result = $result;
    }
}
$serializer = SerializerBuilder::create()->addDefaultHandlers()->addDefaultSerializationVisitors()->addDefaultDeserializationVisitors()->setDebug(true)->addMetadataDir(__DIR__ . '/serializer', 'Xiag\\JsonCommand\\Examples\\NodeJs')->setCacheDir(sys_get_temp_dir())->build();
$executor = new JsonCommandExecutor('node', $serializer, 'array<Xiag\\JsonCommand\\Examples\\NodeJs\\Result>');
$executor->addCommandPrefix(__DIR__ . '/calculator.js');
$executor->addEnvironmentVariable('TZ', 'UTC');
/** @var Result[] $results */
$results = $executor->executeCommand([new Argument('abc', 1000), new Argument('def', 2000)]);
foreach ($results as $result) {
    printf('Key:    %s' . PHP_EOL, $result->getKey());
    printf('Result: %f' . PHP_EOL, $result->getResult());
}
Exemplo n.º 3
0
 /**
  * @param FirstCalculatorArg $arg
  * @return FirstCalculatorResult
  */
 public function calculate(FirstCalculatorArg $arg)
 {
     return $this->executor->executeCommand([$arg]);
 }