Esempio n. 1
0
 public function testCancelsInFlightRequests()
 {
     $c = $this->getClient();
     $h = new History();
     $c->getEmitter()->attach($h);
     $p = new Pool($c, [$c->createRequest('GET', 'http://foo.com'), $c->createRequest('GET', 'http://foo.com', ['events' => ['before' => ['fn' => function () use(&$p) {
         $this->assertTrue($p->cancel());
     }, 'priority' => RequestEvents::EARLY]]])]);
     ob_start();
     $p->wait();
     $contents = ob_get_clean();
     $this->assertEquals(1, count($h));
     $this->assertEquals('Cancelling', $contents);
 }