PhpBench\Benchmark\Remote\Launcher::payload PHP Method

payload() public method

public payload ( $template, array $tokens )
$tokens array
    public function payload($template, array $tokens)
    {
        $tokens['bootstrap'] = '';
        if (null !== $this->bootstrap) {
            if (!file_exists($this->bootstrap)) {
                throw new \InvalidArgumentException(sprintf('Bootstrap file "%s" does not exist.', $this->bootstrap));
            }
            $tokens['bootstrap'] = $this->bootstrap;
        }
        $phpBinary = $this->resolvePhpBinary();
        $payload = $this->payloadFactory->create($template, $tokens, $phpBinary);
        if ($this->phpWrapper) {
            $payload->setWrapper($this->phpWrapper);
        }
        if ($this->phpConfig) {
            $payload->setPhpConfig($this->phpConfig);
        }
        return $payload;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * It should throw an exception if the bootstrap file does not exist.
  *
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage Bootstrap file
  */
 public function testInvalidBootstrap()
 {
     $launcher = new Launcher($this->factory->reveal(), $this->finder->reveal(), __DIR__ . '/../../../../vendor/notexisting.php');
     $launcher->payload(__DIR__ . '/template/foo.template', ['foo' => 'bar']);
 }
All Usage Examples Of PhpBench\Benchmark\Remote\Launcher::payload