Example #1
0
 /**
  * @return void
  */
 public function testAdd()
 {
     $doc = new ExampleData();
     $doc->language = 'php';
     $doc->api = 'simple';
     $doc->format = 'thrift';
     $protocolFactory = new TBinaryProtocolFactory();
     $transport = new TMemoryBuffer();
     $protocol = $protocolFactory->getProtocol($transport);
     $doc->write($protocol);
     $message = $transport->read($transport->available());
     /** @var $client PHPUnit_Framework_MockObject_MockObject|JobPoolIf */
     $client = $this->getMock('JobPoolIf');
     $client->expects($this->once())->method('add')->with($this->equalTo('foo'), $this->equalTo($message));
     $consumer = new jp_producer_Thrift('foo', array('client' => $client));
     $consumer->add($doc);
 }
Example #2
0
#!/usr/bin/php
<?php 
$jpRoot = dirname(__FILE__) . '/../../';
set_include_path(get_include_path() . PATH_SEPARATOR . $jpRoot . 'lib/php' . PATH_SEPARATOR . $jpRoot . 'gen-php/jp');
$GLOBALS['THRIFT_ROOT'] = 'Thrift';
require_once 'jp/producer/Thrift.php';
require_once dirname(__FILE__) . '/../gen-php/example/example_types.php';
$producer = new jp_producer_Thrift('thrift');
$doc = new ExampleData();
$doc->language = 'php';
$doc->api = 'simple';
$doc->format = 'thrift';
for ($i = 0; $i < 100; $i++) {
    $producer->add($doc);
}