/** * Setup Method * * Creates an instance of BatchRequestSubscriber */ public function setUp() { $stream = Stream::factory(json_encode(['success' => true])); $mock = new Mock([new Response(200, [], $stream)]); $this->client = new Client(['write_key' => 123, 'max_queue_size' => 1, 'batching' => 'request']); $this->client->getEmitter()->attach($mock); $this->subscriber = new BatchRequestSubscriber($this->client->getDescription(), ['max_queue_size' => 1, 'batch_size' => 1]); }
/** * Creates a SegmentIO\Client * * @param string $key The Segment.io API Write Key * @param boolean $debug Whether or not to use a MockAdapater * * @return Client */ private function createClient($key, $debug = false) { $client = new Client(['write_key' => $key, 'batching' => false]); if ($debug) { $stream = Stream::factory(json_encode(['success' => true])); $mock = new Mock([new Response(200, [], $stream)]); $client->getEmitter()->attach($mock); } return $client; }